]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selinux: use native iterator types
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 25 Nov 2024 11:06:44 +0000 (12:06 +0100)
committerPaul Moore <paul@paul-moore.com>
Wed, 11 Dec 2024 18:54:14 +0000 (13:54 -0500)
Use types for iterators equal to the type of the to be compared values.

Reported by clang:

    ../ss/sidtab.c:126:2: warning: comparison of integers of different
                          signs: 'int' and 'unsigned long'
      126 |  hash_for_each_rcu(sidtab->context_to_sid, i, entry, list) {
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../hashtable.h:139:51: note: expanded from macro 'hash_for_each_rcu'
      139 |  for (... ; obj == NULL && (bkt) < HASH_SIZE(name);\
          |                             ~~~  ^ ~~~~~~~~~~~~~~~

    ../selinuxfs.c:1520:23: warning: comparison of integers of different
                            signs: 'int' and 'unsigned int'
     1520 |  for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
          |                   ~~~ ^ ~~~~~~~~~~

    ../hooks.c:412:16: warning: comparison of integers of different signs:
                       'int' and 'unsigned long'
      412 |  for (i = 0; i < ARRAY_SIZE(tokens); i++) {
          |              ~ ^ ~~~~~~~~~~~~~~~~~~

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
[PM: munged the clang output due to line length concerns]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c
security/selinux/selinuxfs.c
security/selinux/ss/sidtab.c

index f5a08f94e09402b6b0b1538fae1a7a3f5af19fe6..2afc45f355a4a81c9007fdd8a70103f34da6e98e 100644 (file)
@@ -407,7 +407,7 @@ static const struct {
 
 static int match_opt_prefix(char *s, int l, char **arg)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(tokens); i++) {
                size_t len = tokens[i].len;
index 6cd5bb0ba380c87bed52eee9475e74d8f035a410..1efb9a57d1812c71d35f0adefd9c998864f39a7b 100644 (file)
@@ -1515,7 +1515,7 @@ static const struct file_operations sel_avc_hash_stats_ops = {
 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
 static struct avc_cache_stats *sel_avc_get_stat_idx(loff_t *idx)
 {
-       int cpu;
+       loff_t cpu;
 
        for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
                if (!cpu_possible(cpu))
index c8848cbba81f24abbb2e0d07697ece10d2cc6637..cb7125cc7f8ed8a28c1a2402f2e48a2f1962b6e9 100644 (file)
@@ -114,12 +114,12 @@ int sidtab_set_initial(struct sidtab *s, u32 sid, struct context *context)
 
 int sidtab_hash_stats(struct sidtab *sidtab, char *page)
 {
-       int i;
+       unsigned int i;
        int chain_len = 0;
        int slots_used = 0;
        int entries = 0;
        int max_chain_len = 0;
-       int cur_bucket = 0;
+       unsigned int cur_bucket = 0;
        struct sidtab_entry *entry;
 
        rcu_read_lock();