Skip to contentSkip to conversation

pstore: Use match_string() helper to simplify the code

PATCH New Andy Shevchenko 1 participant 1 message Nov 19 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pstore: Use match_string() helper to simplify the code

match_string() returns the array index of a matching string. Use it instead of the open-coded implementation.

---

v2: fixed typo (LKP)

 fs/pstore/platform.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/pstore/platform.c +4 -5
index 1ad6e40f4952..f517b229decc 100644
@@ -17,9 +17,9 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/pstore.h>
-#include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/slab.h>
+#include <linux/string_helpers.h>
 #include <linux/uaccess.h>
 #include <linux/jiffies.h>
 #include <linux/vmalloc.h>
@@ -130,10 +130,9 @@ enum pstore_type_id pstore_name_to_type(const char *name)
 {
 	int i;
 
-	for (i = 0; i < PSTORE_TYPE_MAX; i++) {
-		if (!strcmp(pstore_type_names[i], name))
-			return i;
-	}
+	i = match_string(pstore_type_names, PSTORE_TYPE_MAX, name);
+	if (i >= 0)
+		return i;
 
 	return PSTORE_TYPE_MAX;
 }
Signature · 1 line
2.50.1