All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Palmer Dabbelt <palmer@rivosinc.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [palmer:riscv-no_attributes-v2 33/34] lib/test_string.c:237 strncmp_selftest() warn: unsigned 'res' is never less than zero.
Date: Mon, 27 Feb 2023 09:57:00 +0800	[thread overview]
Message-ID: <202302270931.S9Ju89sL-lkp@intel.com> (raw)

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

                 reply	other threads:[~2023-02-27  1:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202302270931.S9Ju89sL-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=palmer@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.