Re: [PATCH v1 4/9] kunit: Add ability to filter attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rae,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 64bd4641310c41a1ecf07c13c67bc0ed61045dfd]

url:    https://github.com/intel-lab-lkp/linux/commits/Rae-Moar/kunit-Add-test-attributes-API-structure/20230720-062623
base:   64bd4641310c41a1ecf07c13c67bc0ed61045dfd
patch link:    https://lore.kernel.org/r/20230719222338.259684-5-rmoar%40google.com
patch subject: [PATCH v1 4/9] kunit: Add ability to filter attributes
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20230722/202307221053.0LbbjwLI-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce: (https://download.01.org/0day-ci/archive/20230722/202307221053.0LbbjwLI-lkp@xxxxxxxxx/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 <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307221053.0LbbjwLI-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> lib/kunit/attributes.c:109:14: warning: variable 'input_val' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
           for (i = 0; input[i]; i++) {
                       ^~~~~~~~
   lib/kunit/attributes.c:116:7: note: uninitialized use occurs here
           if (!input_val) {
                ^~~~~~~~~
   lib/kunit/attributes.c:109:14: note: remove the condition if it is always true
           for (i = 0; input[i]; i++) {
                       ^~~~~~~~
   lib/kunit/attributes.c:107:23: note: initialize the variable 'input_val' to silence this warning
           const char *input_val;
                                ^
                                 = NULL
   lib/kunit/attributes.c:215:47: error: initializer element is not a compile-time constant
   static struct kunit_attr kunit_attr_list[] = {speed_attr, module_attr};
                                                 ^~~~~~~~~~
   1 warning and 1 error generated.


vim +109 lib/kunit/attributes.c

    96	
    97	/*
    98	 * Returns whether the inputted enum value "attr" matches the filter given
    99	 * by the input string. Note: the str_list includes the corresponding string
   100	 * list to the enum values.
   101	 */
   102	static int attr_enum_filter(void *attr, const char *input, int *err,
   103			const char * const str_list[], int max)
   104	{
   105		int i, j, input_int;
   106		long test_val = (long)attr;
   107		const char *input_val;
   108	
 > 109		for (i = 0; input[i]; i++) {
   110			if (!strchr(op_list, input[i])) {
   111				input_val = input + i;
   112				break;
   113			}
   114		}
   115	
   116		if (!input_val) {
   117			*err = -EINVAL;
   118			pr_err("kunit executor: filter value not found: %s\n", input);
   119			return false;
   120		}
   121	
   122		for (j = 0; j <= max; j++) {
   123			if (!strcmp(input_val, str_list[j]))
   124				input_int = j;
   125		}
   126	
   127		if (!input_int) {
   128			*err = -EINVAL;
   129			pr_err("kunit executor: invalid filter input: %s\n", input);
   130			return false;
   131		}
   132	
   133		return int_filter(test_val, input, input_int, err);
   134	}
   135	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux