Re: [PATCH 3/3] Fix uninitialized variables warnings

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

 



Hi Luiz,

On Tue, Mar 29, 2011 at 7:36 AM,  <luiz.dentz@xxxxxxxxx> wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@xxxxxxxxx>
>
> src/attrib-server.c: In function ‘channel_handler’:
> src/attrib-server.c:297:21: error: ‘cur’ may be used uninitialized in this function
> src/attrib-server.c:502:10: error: ‘format’ may be used uninitialized in this function
> src/attrib-server.c:503:11: error: ‘length’ may be used uninitialized in this function
> make[1]: *** [src/attrib-server.o] Error 1
> ---
>  src/attrib-server.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/attrib-server.c b/src/attrib-server.c
> index dc05d7e..fb89ea5 100644
> --- a/src/attrib-server.c
> +++ b/src/attrib-server.c
> @@ -294,7 +294,7 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start,
>  {
>        struct att_data_list *adl;
>        struct attribute *a;
> -       struct group_elem *cur, *old = NULL;
> +       struct group_elem *cur = NULL, *old = NULL;
>        GSList *l, *groups;
>        uint16_t length, last_handle, last_size = 0;
>        uint8_t status;
> @@ -499,8 +499,8 @@ static int find_info(uint16_t start, uint16_t end, uint8_t *pdu, int len)
>        struct attribute *a;
>        struct att_data_list *adl;
>        GSList *l, *info;
> -       uint8_t format, last_type = BT_UUID_UNSPEC;
> -       uint16_t length, num;
> +       uint8_t format = 0, last_type = BT_UUID_UNSPEC;
> +       uint16_t length = 0, num;

This is due to this block:

///
        if (last_type == BT_UUID16) {
                length = 2;
                format = 0x01;
        } else if (last_type == BT_UUID128) {
                length = 16;
                format = 0x02;
        }
///

I would rather either use an g_assert() for last_type here (because it
is a programming error to have other UUID types on the Attribute
database) ,  or "return 0" (taking care to move this block to before
the if (info == NULL)  check, to avoid a leak).

>        int i;
>
>        if (start > end || start == 0x0000)
> --
> 1.7.4.1
>
> --
> 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
>



-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
--
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