From: kernel test robot <lkp@intel.com>
To: Ido Schimmel <idosch@nvidia.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [jpirko-mlxsw:combined_queue 4/24] drivers/net/ethernet/mellanox/mlxsw/item.h:221:6: warning: variable 'be_index' is used uninitialized whenever 'if' condition is false
Date: Mon, 8 Jul 2024 02:37:30 +0800 [thread overview]
Message-ID: <202407080205.GiAzZkxA-lkp@intel.com> (raw)
tree: https://github.com/jpirko/linux_mlxsw combined_queue
head: ff8aee5108029aa150fba69c00891450d992c987
commit: ad44ce5de61e6ce62c21243a8dac3ec5d83bd2eb [4/24] Fixup to "mlxsw: Warn about invalid accesses to array fields" ?
config: i386-buildonly-randconfig-002-20240707 (https://download.01.org/0day-ci/archive/20240708/202407080205.GiAzZkxA-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240708/202407080205.GiAzZkxA-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407080205.GiAzZkxA-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/net/ethernet/mellanox/mlxsw/i2c.c:15:
In file included from drivers/net/ethernet/mellanox/mlxsw/cmd.h:7:
>> drivers/net/ethernet/mellanox/mlxsw/item.h:221:6: warning: variable 'be_index' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
221 | if (WARN_ONCE(index > max_index,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
222 | "name=%s,index=%u,max_index=%u\n", item->name, index,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223 | max_index))
| ~~~~~~~~~~
include/asm-generic/bug.h:152:2: note: expanded from macro 'WARN_ONCE'
152 | DO_ONCE_LITE_IF(condition, WARN, 1, format)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/once_lite.h:27:2: note: expanded from macro 'DO_ONCE_LITE_IF'
27 | ({ \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 | bool __ret_do_once = !!(condition); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 | \
| ~
30 | if (__ONCE_LITE_IF(__ret_do_once)) \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 | func(__VA_ARGS__); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 | \
| ~
33 | unlikely(__ret_do_once); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34 | })
| ~~
drivers/net/ethernet/mellanox/mlxsw/item.h:225:11: note: uninitialized use occurs here
225 | offset = be_index * item->element_size >> 3;
| ^~~~~~~~
drivers/net/ethernet/mellanox/mlxsw/item.h:221:2: note: remove the 'if' if its condition is always true
221 | if (WARN_ONCE(index > max_index,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
222 | "name=%s,index=%u,max_index=%u\n", item->name, index,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223 | max_index))
| ~~~~~~~~~~~
224 | be_index = max_index - index;
drivers/net/ethernet/mellanox/mlxsw/item.h:208:25: note: initialize the variable 'be_index' to silence this warning
208 | u16 max_index, be_index;
| ^
| = 0
1 warning generated.
vim +221 drivers/net/ethernet/mellanox/mlxsw/item.h
203
204 static inline u16
205 __mlxsw_item_bit_array_offset(const struct mlxsw_item *item,
206 u16 index, u8 *shift)
207 {
208 u16 max_index, be_index;
209 u16 offset; /* byte offset inside the array */
210 u8 in_byte_index;
211
212 BUG_ON(index && !item->element_size);
213 if (item->offset % sizeof(u32) != 0 ||
214 BITS_PER_BYTE % item->element_size != 0) {
215 pr_err("mlxsw: item bug (name=%s,offset=%x,element_size=%x)\n",
216 item->name, item->offset, item->element_size);
217 BUG();
218 }
219
220 max_index = (item->size.bytes << 3) / item->element_size - 1;
> 221 if (WARN_ONCE(index > max_index,
222 "name=%s,index=%u,max_index=%u\n", item->name, index,
223 max_index))
224 be_index = max_index - index;
225 offset = be_index * item->element_size >> 3;
226 in_byte_index = index % (BITS_PER_BYTE / item->element_size);
227 *shift = in_byte_index * item->element_size;
228
229 return item->offset + offset;
230 }
231
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2024-07-07 18:37 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=202407080205.GiAzZkxA-lkp@intel.com \
--to=lkp@intel.com \
--cc=idosch@nvidia.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/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.