linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/string: sysfs_streq works case insensitively
@ 2021-04-12 11:33 Gioh Kim
  2021-04-28  5:41 ` Gioh Kim
  2021-04-28  6:37 ` Rasmus Villemoes
  0 siblings, 2 replies; 8+ messages in thread
From: Gioh Kim @ 2021-04-12 11:33 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: ndesaulniers, gregkh, Gioh Kim

As the name shows, it checks the strings inputed from sysfs.
It should work for both case-sensitive filesystem and
case-insensitive filesystem. Therefore sysfs_streq should work
case-insensitively.

Signed-off-by: Gioh Kim <gi-oh.kim@ionos.com>
---
 lib/string.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/string.c b/lib/string.c
index 7548eb715ddb..d0914dffdaae 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -688,7 +688,8 @@ EXPORT_SYMBOL(strsep);
 #endif
 
 /**
- * sysfs_streq - return true if strings are equal, modulo trailing newline
+ * sysfs_streq - return true if strings are equal case-insentively,
+ *               modulo trailing newline
  * @s1: one string
  * @s2: another string
  *
@@ -696,10 +697,11 @@ EXPORT_SYMBOL(strsep);
  * 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.
+ * And case does not matter for the sysfs input strings comparison.
  */
 bool sysfs_streq(const char *s1, const char *s2)
 {
-	while (*s1 && *s1 == *s2) {
+	while (*s1 && tolower(*s1) == tolower(*s2)) {
 		s1++;
 		s2++;
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-04-28  9:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 11:33 [PATCH] lib/string: sysfs_streq works case insensitively Gioh Kim
2021-04-28  5:41 ` Gioh Kim
     [not found]   ` <CAHp75Vf2yJ5=zdxRcPKmKGCKeF8As=Nv2S9fm0ciVXL5HGbWDg@mail.gmail.com>
2021-04-28  7:31     ` Gioh Kim
2021-04-28  7:46       ` Andy Shevchenko
2021-04-28  7:47       ` Rasmus Villemoes
2021-04-28  8:31         ` Gioh Kim
2021-04-28  9:13           ` Rasmus Villemoes
2021-04-28  6:37 ` Rasmus Villemoes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).