Re: [PATCH 2/6]kernel:audit.c Fix warning: variable 'nlh' set but not used

From: Geert Uytterhoeven
Date: Sat Jun 19 2010 - 04:06:16 EST


On Sat, Jun 19, 2010 at 06:45, Justin P. Mattock
<justinmattock@xxxxxxxxx> wrote:
>> This is not dead code. NLMSG_NEW() sets up an nlmsg in ab->skb.
>> If you remove the code, it's no longer initialized.
>
> I played around with this code some more, but am still getting confused with
> nlmsg_new and NLMSG_NEW. if I remove the nlmsghdr struct I can get a clean

nlmsg_new() allocates a new nlmsg.
NLMSG_NEW() initializes a nlmsg inside an already allocated skbuff.

> build without a warning, but still am a bit confused.
>
> here is an updated patch let me know if it still needs work..
> or if it's legit I can resend this.

Looks OK to me, thanks!

> From 7515a08ba921d3beed33fa5c6b1fbe59cf52e069 Mon Sep 17 00:00:00 2001
> From: Justin P. Mattock <justinmattock@xxxxxxxxx>
> Date: Fri, 18 Jun 2010 19:44:30 -0700
> Subject: [PATCH 4/4] audit
> ÂSigned-off-by: Justin P. Mattock <justinmattock@xxxxxxxxx>
>
> ---
> Âkernel/audit.c | Â Â3 +--
> Â1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/audit.c b/kernel/audit.c
> index c71bd26..1d51258 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1041,7 +1041,6 @@ static struct audit_buffer * audit_buffer_alloc(struct
> audit_context *ctx,
> Â{
> Â Â Â Âunsigned long flags;
> Â Â Â Âstruct audit_buffer *ab = NULL;
> - Â Â Â struct nlmsghdr *nlh;
>
> Â Â Â Âspin_lock_irqsave(&audit_freelist_lock, flags);
> Â Â Â Âif (!list_empty(&audit_freelist)) {
> @@ -1065,7 +1064,7 @@ static struct audit_buffer * audit_buffer_alloc(struct
> audit_context *ctx,
> Â Â Â Âif (!ab->skb)
> Â Â Â Â Â Â Â Âgoto nlmsg_failure;
>
> - Â Â Â nlh = NLMSG_NEW(ab->skb, 0, 0, type, 0, 0);
> + Â Â Â NLMSG_NEW(ab->skb, 0, 0, type, 0, 0);
>
> Â Â Â Âreturn ab;
>
> --
> 1.7.1.rc1.21.gf3bd6

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/