Skip to content

Commit 7719e43

Browse files
hharrisonAl Viro
authored andcommitted
[PATCH 2/2] audit: fix sparse shadowed variable warnings
Use msglen as the identifier. kernel/audit.c:724:10: warning: symbol 'len' shadows an earlier one kernel/audit.c:575:8: originally declared here Don't use ino_f to check the inode field at the end of the functions. kernel/auditfilter.c:429:22: warning: symbol 'f' shadows an earlier one kernel/auditfilter.c:420:21: originally declared here kernel/auditfilter.c:542:22: warning: symbol 'f' shadows an earlier one kernel/auditfilter.c:529:21: originally declared here i always used as a counter for a for loop and initialized to zero before use. Eliminate the inner i variables. kernel/auditsc.c:1295:8: warning: symbol 'i' shadows an earlier one kernel/auditsc.c:1152:6: originally declared here kernel/auditsc.c:1320:7: warning: symbol 'i' shadows an earlier one kernel/auditsc.c:1152:6: originally declared here Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c782f24 commit 7719e43

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

‎kernel/audit.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -813,21 +813,21 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
813813
case AUDIT_MAKE_EQUIV: {
814814
void *bufp = data;
815815
u32 sizes[2];
816-
size_t len = nlmsg_len(nlh);
816+
size_t msglen = nlmsg_len(nlh);
817817
char *old, *new;
818818

819819
err = -EINVAL;
820-
if (len < 2 * sizeof(u32))
820+
if (msglen < 2 * sizeof(u32))
821821
break;
822822
memcpy(sizes, bufp, 2 * sizeof(u32));
823823
bufp += 2 * sizeof(u32);
824-
len -= 2 * sizeof(u32);
825-
old = audit_unpack_string(&bufp, &len, sizes[0]);
824+
msglen -= 2 * sizeof(u32);
825+
old = audit_unpack_string(&bufp, &msglen, sizes[0]);
826826
if (IS_ERR(old)) {
827827
err = PTR_ERR(old);
828828
break;
829829
}
830-
new = audit_unpack_string(&bufp, &len, sizes[1]);
830+
new = audit_unpack_string(&bufp, &msglen, sizes[1]);
831831
if (IS_ERR(new)) {
832832
err = PTR_ERR(new);
833833
kfree(old);

‎kernel/auditfilter.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule)
417417
static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
418418
{
419419
struct audit_entry *entry;
420-
struct audit_field *f;
420+
struct audit_field *ino_f;
421421
int err = 0;
422422
int i;
423423

@@ -499,9 +499,9 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
499499
}
500500
}
501501

502-
f = entry->rule.inode_f;
503-
if (f) {
504-
switch(f->op) {
502+
ino_f = entry->rule.inode_f;
503+
if (ino_f) {
504+
switch(ino_f->op) {
505505
case AUDIT_NOT_EQUAL:
506506
entry->rule.inode_f = NULL;
507507
case AUDIT_EQUAL:
@@ -526,7 +526,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
526526
{
527527
int err = 0;
528528
struct audit_entry *entry;
529-
struct audit_field *f;
529+
struct audit_field *ino_f;
530530
void *bufp;
531531
size_t remain = datasz - sizeof(struct audit_rule_data);
532532
int i;
@@ -654,9 +654,9 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
654654
}
655655
}
656656

657-
f = entry->rule.inode_f;
658-
if (f) {
659-
switch(f->op) {
657+
ino_f = entry->rule.inode_f;
658+
if (ino_f) {
659+
switch(ino_f->op) {
660660
case AUDIT_NOT_EQUAL:
661661
entry->rule.inode_f = NULL;
662662
case AUDIT_EQUAL:

‎kernel/auditsc.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,6 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
12931293
break; }
12941294

12951295
case AUDIT_SOCKETCALL: {
1296-
int i;
12971296
struct audit_aux_data_socketcall *axs = (void *)aux;
12981297
audit_log_format(ab, "nargs=%d", axs->nargs);
12991298
for (i=0; i<axs->nargs; i++)
@@ -1318,7 +1317,6 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
13181317

13191318
for (aux = context->aux_pids; aux; aux = aux->next) {
13201319
struct audit_aux_data_pids *axs = (void *)aux;
1321-
int i;
13221320

13231321
for (i = 0; i < axs->pid_count; i++)
13241322
if (audit_log_pid_context(context, axs->target_pid[i],

0 commit comments

Comments
 (0)