Re: [RFC] network: Reply to extensions at connection setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Frédéric,

On Tue, May 29, 2012 at 1:19 PM, Frédéric Dalleau
<frederic.dalleau@xxxxxxxxxxxxxxx> wrote:
> +       /* Reply to extensions */
> +       if (req->type & BNEP_EXT_HEADER) {
> +               uint8_t pkt[3];
> +               int l;
> +
> +               l = 3 + 2 * req->uuid_size;
> +               ext = packet + l;
> +               n -= l;
> +
> +ext:
> +               if (n <= 3)
> +                       return FALSE;
> +
> +               pkt[0] = BNEP_CONTROL;
> +               pkt[1] = BNEP_CMD_NOT_UNDERSTOOD;
> +               pkt[2] = ext[2];
> +
> +               send(sk, pkt, sizeof(pkt), 0);
> +
> +               if ((ext[0] & BNEP_EXT_HEADER) == 0)
> +                       return FALSE;
> +
> +               l = 2 + ext[1];
> +               ext += l;
> +               n -= l;
> +               goto ext;
> +       }
> +

It looks bad to use goto backwards in the code, specially when you
could use a for loop or something like that. Maybe you should this
part in a separate function where you can initialize the variables and
responding to each extension request, also it would be useful to have
the structures of the extension so you can do sizeof and things like
that to avoid using magic numbers.


-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux