net/sunrpc/auth_gss/gss_krb5_mech.c:325 gss_krb5_lookup_enctype() warn: unsigned 'i' is never less than zero.

From: kernel test robot
Date: Fri Jun 30 2023 - 12:59:00 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e55e5df193d247a38a5e1ac65a5316a0adcc22fa
commit: ddd8c1f975ee7c2fc60ea836540b5b10f97ac919 SUNRPC: Export get_gss_krb5_enctype()
date: 4 months ago
config: x86_64-randconfig-m001-20230629 (https://download.01.org/0day-ci/archive/20230701/202307010010.uGvpzuSy-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230701/202307010010.uGvpzuSy-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/202307010010.uGvpzuSy-lkp@xxxxxxxxx/

New smatch warnings:
net/sunrpc/auth_gss/gss_krb5_mech.c:325 gss_krb5_lookup_enctype() warn: unsigned 'i' is never less than zero.
net/sunrpc/auth_gss/gss_krb5_mech.c:325 gss_krb5_lookup_enctype() warn: unsigned 'i' is never less than zero.

Old smatch warnings:
net/sunrpc/auth_gss/gss_krb5_mech.c:301 gss_krb5_prepare_enctype_priority_list() warn: unsigned 'i' is never less than zero.
net/sunrpc/auth_gss/gss_krb5_mech.c:301 gss_krb5_prepare_enctype_priority_list() warn: unsigned 'i' is never less than zero.
net/sunrpc/auth_gss/gss_krb5_mech.c:325 gss_krb5_lookup_enctype() warn: we never enter this loop

vim +/i +325 net/sunrpc/auth_gss/gss_krb5_mech.c

312
313 /**
314 * gss_krb5_lookup_enctype - Retrieve profile information for a given enctype
315 * @etype: ENCTYPE value
316 *
317 * Returns a pointer to a gss_krb5_enctype structure, or NULL if no
318 * matching etype is found.
319 */
320 VISIBLE_IF_KUNIT
321 const struct gss_krb5_enctype *gss_krb5_lookup_enctype(u32 etype)
322 {
323 size_t i;
324
> 325 for (i = 0; i < ARRAY_SIZE(supported_gss_krb5_enctypes); i++)
326 if (supported_gss_krb5_enctypes[i].etype == etype)
327 return &supported_gss_krb5_enctypes[i];
328 return NULL;
329 }
330 EXPORT_SYMBOL_IF_KUNIT(gss_krb5_lookup_enctype);
331

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