RE: [PATCH] selinux: use native iterator types
From: David Laight
Date: Sat Dec 14 2024 - 16:08:40 EST
From: Paul Moore
> Sent: 11 December 2024 18:54
>
> On Nov 25, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@xxxxxxxxxxxxx> wrote:
> >
> > Use types for iterators equal to the type of the to be compared values.
> >
> > Reported by clang:
> >
> > security/selinux/ss/sidtab.c:126:2: warning: comparison of integers of different signs: 'int'
> and 'unsigned long' [-Wsign-compare]
> > 126 | hash_for_each_rcu(sidtab->context_to_sid, i, entry, list) {
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ./include/linux/hashtable.h:139:51: note: expanded from macro 'hash_for_each_rcu'
> > 139 | for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
> > | ~~~ ^ ~~~~~~~~~~~~~~~
> >
> > security/selinux/selinuxfs.c:1520:23: warning: comparison of integers of different signs: 'int'
> and 'unsigned int' [-Wsign-compare]
> > 1520 | for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
> > | ~~~ ^ ~~~~~~~~~~
> >
> > security/selinux/hooks.c:412:16: warning: comparison of integers of different signs: 'int' and
> 'unsigned long' [-Wsign-compare]
> > 412 | for (i = 0; i < ARRAY_SIZE(tokens); i++) {
> > | ~ ^ ~~~~~~~~~~~~~~~~~~
Isn't this an example of why -Wsign-compare is entirely stupid and isn't enabled
in the normal kernel build?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)