Re: [PATCH] selinux: use native iterator types

From: Paul Moore
Date: Wed Dec 11 2024 - 14:11:04 EST


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++) {
> | ~ ^ ~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
> ---
> security/selinux/hooks.c | 2 +-
> security/selinux/selinuxfs.c | 2 +-
> security/selinux/ss/sidtab.c | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)

Merged into selinux/dev, thanks Christian.

--
paul-moore.com