2016-04-22 10:06:09

by Dan Carpenter

[permalink] [raw]
Subject: [patch] Bluetooth: ath3k: Silence uninitialized variable warning

We could print an uninitialized value in the error message.

Signed-off-by: Dan Carpenter <[email protected]>

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 47ca4b3..641c2d1 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -206,7 +206,8 @@ static int ath3k_load_firmware(struct usb_device *udev,
const struct firmware *firmware)
{
u8 *send_buf;
- int err, pipe, len, size, sent = 0;
+ int len = 0;
+ int err, pipe, size, sent = 0;
int count = firmware->size;

BT_DBG("udev %p", udev);
@@ -302,7 +303,8 @@ static int ath3k_load_fwfile(struct usb_device *udev,
const struct firmware *firmware)
{
u8 *send_buf;
- int err, pipe, len, size, count, sent = 0;
+ int len = 0;
+ int err, pipe, size, count, sent = 0;
int ret;

count = firmware->size;


2016-04-22 10:42:55

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [patch] Bluetooth: ath3k: Silence uninitialized variable warning

Hi Dan,

> We could print an uninitialized value in the error message.
>
> Signed-off-by: Dan Carpenter <[email protected]>

patch has been applied to bluetooth-next tree.

Regards

Marcel

2016-04-23 06:48:05

by afzal mohammed

[permalink] [raw]
Subject: Re: [patch] Bluetooth: ath3k: Silence uninitialized variable warning

Hi,

On Fri, Apr 22, 2016 at 01:02:55PM +0300, Dan Carpenter wrote:

> - int err, pipe, len, size, count, sent = 0;
> + int len = 0;
> + int err, pipe, size, count, sent = 0;

Is there any particular reason to avoid more than 1 variable
initialization in definition on a single line ?, like,

int err, pipe, size, count, sent = 0, len = 0;

have observed that none of your uninitialized variable warning fixes
does as mentioned above.

Regards
afzal

2016-04-23 07:22:15

by Dan Carpenter

[permalink] [raw]
Subject: Re: [patch] Bluetooth: ath3k: Silence uninitialized variable warning

On Sat, Apr 23, 2016 at 12:17:45PM +0530, Afzal Mohammed wrote:
> Hi,
>
> On Fri, Apr 22, 2016 at 01:02:55PM +0300, Dan Carpenter wrote:
>
> > - int err, pipe, len, size, count, sent = 0;
> > + int len = 0;
> > + int err, pipe, size, count, sent = 0;
>
> Is there any particular reason to avoid more than 1 variable
> initialization in definition on a single line ?, like,
>
> int err, pipe, size, count, sent = 0, len = 0;
>
> have observed that none of your uninitialized variable warning fixes
> does as mentioned above.

That sort of initialization is slightly less readable...

regards,
dan carpenter