* [palmer:riscv-no_attributes-v2 33/34] lib/test_string.c:237 strncmp_selftest() warn: unsigned 'res' is never less than zero.
@ 2023-02-27 1:57 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-02-27 1:57 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: oe-kbuild-all
tree: https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git riscv-no_attributes-v2
head: 858affb61bd0d79d702fe73d9316fd32693aacc4
commit: 51e24314e0a1f193799351c06af8727ab92fd4d2 [33/34] lib/test_string.c: Add strncmp() tests
config: m68k-randconfig-m031-20230226 (https://download.01.org/0day-ci/archive/20230227/202302270931.S9Ju89sL-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202302270931.S9Ju89sL-lkp@intel.com/
New smatch warnings:
lib/test_string.c:237 strncmp_selftest() warn: unsigned 'res' is never less than zero.
lib/test_string.c:237 strncmp_selftest() warn: always true condition '(s->retval >= 0) => (0-u32max >= 0)'
Old smatch warnings:
lib/test_string.c:14 memset16_selftest() warn: returning -1 instead of -ENOMEM is sloppy
lib/test_string.c:50 memset32_selftest() warn: returning -1 instead of -ENOMEM is sloppy
lib/test_string.c:86 memset64_selftest() warn: returning -1 instead of -ENOMEM is sloppy
vim +/res +237 lib/test_string.c
209
210 static __init int strncmp_selftest(void)
211 {
212 static const struct strncmp_test {
213 const char *str_a;
214 const char *str_b;
215 unsigned long count;
216 unsigned long max_off;
217 size_t retval;
218 } tests[] __initconst = {
219 { "/dev/vda", "/dev/", 5, 4, 0 },
220 { "/dev/vda", "/dev/vdb", 5, 4, 0 },
221 };
222 size_t i;
223
224 for (i = 0; i < ARRAY_SIZE(tests); ++i) {
225 const struct strncmp_test *s = tests + i;
226 size_t off;
227
228 for (off = 0; off <= s->max_off; ++off) {
229 size_t res = strncmp(s->str_a + off,
230 s->str_b + off,
231 s->count - off);
232
233 if (res == 0 && s->retval != 0)
234 return 0x1000 + 0x100*off + 0x10*i + 0x0;
235 if (res > 0 && s->retval <= 0)
236 return 0x1000 + 0x100*off + 0x10*i + 0x1;
> 237 if (res < 0 && s->retval >= 0)
238 return 0x1000 + 0x100*off + 0x10*i + 0x2;
239 }
240 }
241 return 0;
242 }
243
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-27 1:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 1:57 [palmer:riscv-no_attributes-v2 33/34] lib/test_string.c:237 strncmp_selftest() warn: unsigned 'res' is never less than zero kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.