sysfs_streq
Linux/Linux Kernel :
2018. 3. 19. 09:57
반응형
Name
sysfs_streq — return true if strings are equal, modulo trailing newline
문자열을 비교한다. 뒤에 개행이 오던 NULL이 오던 차이는 관계없다.
Synopsis
bool sysfs_streq ( | const char * s1, |
const char * s2) ; |
- /**
- * sysfs_streq - return true if strings are equal, modulo trailing newline
- * @s1: one string
- * @s2: another string
- *
- * This routine returns true iff two strings are equal, treating both
- * NUL and newline-then-NUL as equivalent string terminations. It's
- * geared for use with sysfs input strings, which generally terminate
- * with newlines but are compared against values without newlines.
- */
- bool sysfs_streq(const char *s1, const char *s2)
- {
- while (*s1 && *s1 == *s2) {
- s1++;
- s2++;
- }
- if (*s1 == *s2)
- return true;
- if (!*s1 && *s2 == '\n' && !s2[1])
- return true;
- if (*s1 == '\n' && !s1[1] && !*s2)
- return true;
- return false;
- }
- EXPORT_SYMBOL(sysfs_streq);
반응형
'Linux > Linux Kernel' 카테고리의 다른 글
likely, unlikely 함수란? (0) | 2018.03.19 |
---|---|
container_of (0) | 2018.03.19 |
sysfs 사용하기 (0) | 2018.03.18 |