pstore: Use match_string() helper to simplify the code
PATCH 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.
--- fs/pstore/platform.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/pstore/platform.c +4 -5
@@ -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
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on kees/for-next/pstore]
[also build test WARNING on kees/for-next/kspp aegl/next linus/master v7.4-rc2 next-20261109] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pstore-Use-match_string-helper-to-simplify-the-code/20261110-161844 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore patch link: https://lore.kernel.org/r/20261110151844.661926-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 1/1] pstore: Use match_string() helper to simplify the code config: x86_64-kexec (https://download.01.org/0day-ci/archive/20261111/[email protected]/config) compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261111/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> fs/pstore/platform.c:134:13: warning: if statement has empty body [-Wempty-body]
134 | if (i >= 0);
| ^ fs/pstore/platform.c:134:13: note: put the semicolon on a separate line to silence this warning 1 warning generated.
vim +134 fs/pstore/platform.c
128
129 enum pstore_type_id pstore_name_to_type(const char *name)
130 {
131 int i;
132
133 i = match_string(pstore_type_names, PSTORE_TYPE_MAX, name);
> 134 if (i >= 0);
135 return i;
136
137 return PSTORE_TYPE_MAX;
138 }
139 EXPORT_SYMBOL_GPL(pstore_name_to_type);
140
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on kees/for-next/pstore]
[also build test WARNING on kees/for-next/kspp aegl/next linus/master v7.4-rc2 next-20261110] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pstore-Use-match_string-helper-to-simplify-the-code/20261110-161844 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore patch link: https://lore.kernel.org/r/20261110151844.661926-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 1/1] pstore: Use match_string() helper to simplify the code config: arm-randconfig-1002-20261111 (https://download.01.org/0day-ci/archive/20261111/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 15.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261111/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
fs/pstore/platform.c: In function 'pstore_name_to_type':
>> fs/pstore/platform.c:134:20: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
134 | if (i >= 0);
| ^
>> fs/pstore/platform.c:134:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
134 | if (i >= 0);
| ^~
fs/pstore/platform.c:135:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
135 | return i;
| ^~~~~~vim +/if +134 fs/pstore/platform.c
128
129 enum pstore_type_id pstore_name_to_type(const char *name)
130 {
131 int i;
132
133 i = match_string(pstore_type_names, PSTORE_TYPE_MAX, name);
> 134 if (i >= 0);
135 return i;
136
137 return PSTORE_TYPE_MAX;
138 }
139 EXPORT_SYMBOL_GPL(pstore_name_to_type);
140
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki