Staging: dgrp: warning: âbufâ is used uninitialized (Was: Re: Staging: dgrp: Refactor the function dgrp_receive() in drrp_net_ops.c)

From: Geert Uytterhoeven
Date: Sun Jan 26 2014 - 05:28:48 EST


On Tue, Jan 21, 2014 at 1:21 AM, Linux Kernel Mailing List
<linux-kernel@xxxxxxxxxxxxxxx> wrote:
> Staging: dgrp: Refactor the function dgrp_receive() in drrp_net_ops.c
>
> The function dgrp_receive() in dgrp_net_ops.c is too long and can be
> refactored. It uses various switch statements and goto labels. I have
> removed a label called data and tried to extract a new function out of
> it called as handle_data_in_packet().
>
> This helps to make the code more modularize and simple to read and
> understand.
>
> Signed-off-by: Rashika Kheria <rashika.kheria@xxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/staging/dgrp/dgrp_net_ops.c | 330 ++++++++++++++++++----------------
> 1 files changed, 175 insertions(+), 155 deletions(-)
>
> diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c
> index 33ac7fb..1f61b89 100644
> --- a/drivers/staging/dgrp/dgrp_net_ops.c
> +++ b/drivers/staging/dgrp/dgrp_net_ops.c
> @@ -2232,6 +2232,177 @@ done:
> return rtn;
> }
>
> +/*
> + * Common Packet Handling code
> + */
> +
> +static void handle_data_in_packet(struct nd_struct *nd, struct ch_struct *ch,
> + long dlen, long plen, int n1, u8 *dbuf)
> +{
> + char *error;
> + long n;
> + long remain;
> + u8 *buf;

> + if (remain < plen) {
> + dlen = plen - remain;
> + b = buf;

drivers/staging/dgrp/dgrp_net_ops.c: In function âhandle_data_in_packetâ:
drivers/staging/dgrp/dgrp_net_ops.c:2392: warning: âbufâ is used
uninitialized in this function

buf is never set in this function.

It is set to nd->nd_iobuf in dgrp_receive(), but this is never passed to
handle_data_in_packet().

> +
> + b[0] = 0x90 + n1;
> + put_unaligned_be16(dlen, b + 1);
> +
> + remain = 3;
> + if (remain > 0 && b != buf)
> + memcpy(buf, b, remain);
> +
> + nd->nd_remain = remain;
> + return;
> + }
> +}

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/