Skip to content

Commit c75c794

Browse files
cgzonespcmoore
authored andcommitted
selinux: use native iterator types
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 <[email protected]> [PM: munged the clang output due to line length concerns] Signed-off-by: Paul Moore <[email protected]>
1 parent b01c939 commit c75c794

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static const struct {
407407

408408
static int match_opt_prefix(char *s, int l, char **arg)
409409
{
410-
int i;
410+
unsigned int i;
411411

412412
for (i = 0; i < ARRAY_SIZE(tokens); i++) {
413413
size_t len = tokens[i].len;

security/selinux/selinuxfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ static const struct file_operations sel_avc_hash_stats_ops = {
15151515
#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
15161516
static struct avc_cache_stats *sel_avc_get_stat_idx(loff_t *idx)
15171517
{
1518-
int cpu;
1518+
loff_t cpu;
15191519

15201520
for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
15211521
if (!cpu_possible(cpu))

security/selinux/ss/sidtab.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ int sidtab_set_initial(struct sidtab *s, u32 sid, struct context *context)
114114

115115
int sidtab_hash_stats(struct sidtab *sidtab, char *page)
116116
{
117-
int i;
117+
unsigned int i;
118118
int chain_len = 0;
119119
int slots_used = 0;
120120
int entries = 0;
121121
int max_chain_len = 0;
122-
int cur_bucket = 0;
122+
unsigned int cur_bucket = 0;
123123
struct sidtab_entry *entry;
124124

125125
rcu_read_lock();

0 commit comments

Comments
 (0)