Fix this:
kernel/auditsc.c: In function 'audit_match_perm':
kernel/auditsc.c:249: warning: ISO C90 forbids mixed declarations and code
Signed-off-by: Hannes Eder <[email protected]>
---
kernel/auditsc.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 972f8e6..e72b161 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -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
Hannes Eder schrieb:
> Fix this:
>
> kernel/auditsc.c: In function 'audit_match_perm':
> kernel/auditsc.c:249: warning: ISO C90 forbids mixed declarations and code
>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
> kernel/auditsc.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 972f8e6..e72b161 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -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
Signed-off-by: Hannes Eder <[email protected]>
---
walter harms <[email protected]> wrote:
> 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(-)
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 972f8e6..f7d7ad4 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -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 */