Fix build warning in kernel/auditsc.c
Subsystems (2)
PATCH 1/1 Fix build warning in kernel/auditsc.c
Fix this:
kernel/auditsc.c: In function 'audit_match_perm':kernel/auditsc.c:249: warning: ISO C90 forbids mixed declarations and code
--- kernel/auditsc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/auditsc.c +3 -1
@@ -243,10 +243,12 @@ static inline int open_arg(int flags, int mask)static int audit_match_perm (struct audit_context *ctx,int mask) { +unsigned n; +if (unlikely (!ctx))return 0 ; -unsigned n = ctx->major; + n = ctx->major;switch (audit_classify_syscall (ctx->arch, n)) {case 0 :/* native */ if ((mask & AUDIT_PERM_WRITE) &&
nice catch
I have only an older version here, in that n is constant. maybe you can do a s/n/ctx->major/g ?
removing the need for the whole variable ?!
re,
wh
Quoted 35 lines · Hannes Eder
Fix this:
kernel/auditsc.c: In function 'audit_match_perm':kernel/auditsc.c:249: warning: ISO C90 forbids mixed declarations and codeSigned-off-by Hannes Eder <[email protected]>--- kernel/auditsc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)kernel/auditsc.c +3
-2@@ -243,10 +243,12 @@ static inline int open_arg(int flags, int mask)static int audit_match_perm (struct audit_context *ctx,int mask) { +unsigned n; +if (unlikely (!ctx))return 0 ; -unsigned n = ctx->major; + n = ctx->major;switch (audit_classify_syscall (ctx->arch, n)) {case 0 :/* native */ if ((mask & AUDIT_PERM_WRITE) && --To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Fix the following build warning, by eliminating the variable.
kernel/auditsc.c: In function 'audit_match_perm':kernel/auditsc.c:249: warning: ISO C90 forbids mixed declarations and code
---
Quoted 2 lines · walter harms
maybe you can do a s/n/ctx->major/g ?
removing the need for the whole variable ?!
Here we go. Why is this better than splitting the variable declaration and initialization, as in the previous patch?
kernel/auditsc.c | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-)
kernel/auditsc.c +0 -0
@@ -246,28 +246,27 @@ static int audit_match_perm(struct audit_context
*ctx, int mask)
if (unlikely(!ctx))
return 0;
- unsigned n = ctx->major;
- switch (audit_classify_syscall(ctx->arch, n)) {
+ switch (audit_classify_syscall(ctx->arch, ctx->major)) {
case 0: /* native */
if ((mask & AUDIT_PERM_WRITE) &&
- audit_match_class(AUDIT_CLASS_WRITE, n))
+ audit_match_class(AUDIT_CLASS_WRITE, ctx->major))
return 1;
if ((mask & AUDIT_PERM_READ) &&
- audit_match_class(AUDIT_CLASS_READ, n))
+ audit_match_class(AUDIT_CLASS_READ, ctx->major))
return 1;
if ((mask & AUDIT_PERM_ATTR) &&
- audit_match_class(AUDIT_CLASS_CHATTR, n))
+ audit_match_class(AUDIT_CLASS_CHATTR, ctx->major))
return 1;
return 0;
case 1: /* 32bit on biarch */
if ((mask & AUDIT_PERM_WRITE) &&
- audit_match_class(AUDIT_CLASS_WRITE_32, n))
+ audit_match_class(AUDIT_CLASS_WRITE_32, ctx->major))
return 1;
if ((mask & AUDIT_PERM_READ) &&
- audit_match_class(AUDIT_CLASS_READ_32, n))
+ audit_match_class(AUDIT_CLASS_READ_32, ctx->major))
return 1;
if ((mask & AUDIT_PERM_ATTR) &&
- audit_match_class(AUDIT_CLASS_CHATTR_32, n))
+ audit_match_class(AUDIT_CLASS_CHATTR_32, ctx->major))
return 1;
return 0;
case 2: /* open */
Quoted 5 lines · Hannes Eder
Fix the following build warning, by eliminating the variable.
kernel/auditsc.c: In function 'audit_match_perm':kernel/auditsc.c:249: warning: ISO C90 forbids mixed declarations and code
Quoted 9 lines
Signed-off-by Hannes Eder <[email protected]>---
Quoted 2 lines · walter harms
maybe you can do a s/n/ctx->major/g ?
removing the need for the whole variable ?!Here we go. Why is this better than splitting the variable declaration and initialization, as in the previous patch?
Hi hannes,
removing the variable removes the problem for ever. The Variable itself is used as "shortcut" to ctx->major whar is useful in larger codes to get a better overview (sometimes). In this case the code is short, so there is no advantage in keeping.
re,
wh