Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95654
b: refs/heads/master
c: 34990cf
h: refs/heads/master
v: v3
  • Loading branch information
David Brownell authored and Linus Torvalds committed May 1, 2008
1 parent 15a1185 commit c542e69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7dffa3c673fbcf835cd7be80bb4aec8ad3f51168
refs/heads/master: 34990cf702bdf2b4964e0629dab4af7669f8b2c5
2 changes: 2 additions & 0 deletions trunk/include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
extern void argv_free(char **argv);

extern bool sysfs_streq(const char *s1, const char *s2);

#endif
#endif /* _LINUX_STRING_H_ */
27 changes: 27 additions & 0 deletions trunk/lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,33 @@ char *strsep(char **s, const char *ct)
EXPORT_SYMBOL(strsep);
#endif

/**
* 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);

#ifndef __HAVE_ARCH_MEMSET
/**
* memset - Fill a region of memory with the given value
Expand Down

0 comments on commit c542e69

Please sign in to comment.