* [PATCH] net: bluetooth: hci_core.c: Cleaning up uninitialized variables
@ 2014-06-01 13:57 Rickard Strandqvist
2014-06-01 14:24 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 13:57 UTC (permalink / raw)
To: Marcel Holtmann, Gustavo Padovan
Cc: Rickard Strandqvist, Johan Hedberg, David S. Miller,
linux-bluetooth, netdev, linux-kernel
There is a risk that the variable will be used without being initialized.
This was largely found by using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
net/bluetooth/hci_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1c6ffaa..1d93d2f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -4603,7 +4603,7 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
struct hci_chan *chan = NULL;
unsigned int num = 0, min = ~0, cur_prio = 0;
struct hci_conn *conn;
- int cnt, q, conn_num = 0;
+ int cnt, q = 0, conn_num = 0;
BT_DBG("%s", hdev->name);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: bluetooth: hci_core.c: Cleaning up uninitialized variables
2014-06-01 13:57 [PATCH] net: bluetooth: hci_core.c: Cleaning up uninitialized variables Rickard Strandqvist
@ 2014-06-01 14:24 ` Marcel Holtmann
[not found] ` <AB19A214-D495-44EE-87E0-45332F156767-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2014-06-01 14:24 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Gustavo F. Padovan, Johan Hedberg, David S. Miller,
linux-bluetooth, Network Development, linux-kernel
Hi Rickard,
> There is a risk that the variable will be used without being initialized.
>
> This was largely found by using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> net/bluetooth/hci_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 1c6ffaa..1d93d2f 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -4603,7 +4603,7 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
> struct hci_chan *chan = NULL;
> unsigned int num = 0, min = ~0, cur_prio = 0;
> struct hci_conn *conn;
> - int cnt, q, conn_num = 0;
> + int cnt, q = 0, conn_num = 0;
I have no idea on how the variable will be used without being initialized. Have you actually looked through that function. The only thing we do with q is assign it and then use it. That is it.
Regards
Marcel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: bluetooth: hci_core.c: Cleaning up uninitialized variables
[not found] ` <AB19A214-D495-44EE-87E0-45332F156767-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
@ 2014-06-01 15:41 ` Rickard Strandqvist
0 siblings, 0 replies; 3+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 15:41 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Gustavo F. Padovan, Johan Hedberg, David S. Miller,
linux-bluetooth, Network Development,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Hi Marcel!
Sorry sorry!! This is obviously not necessary!
This is code that was left when I tried to split up my original big patch.
This was part of code trying to solve a possible divided by 0.
int q = 0;
...
if (num)
q = cnt / num;
*quote = q ? q : 1;
But I'm not sure if it can happen in reality...
Guessing it will be caught by in that case by:
if (!chan)
return NULL;
I had actually not planned to submit this divided by 0 patch at all :-/
Best regards
Rickard Strandqvist
2014-06-01 16:24 GMT+02:00 Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>:
> Hi Rickard,
>
>> There is a risk that the variable will be used without being initialized.
>>
>> This was largely found by using a static code analysis program called cppcheck.
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist-IW2WV5XWFqGZkjO+N0TKoMugMpMbD5Xr@public.gmane.org>
>> ---
>> net/bluetooth/hci_core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 1c6ffaa..1d93d2f 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -4603,7 +4603,7 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
>> struct hci_chan *chan = NULL;
>> unsigned int num = 0, min = ~0, cur_prio = 0;
>> struct hci_conn *conn;
>> - int cnt, q, conn_num = 0;
>> + int cnt, q = 0, conn_num = 0;
>
> I have no idea on how the variable will be used without being initialized. Have you actually looked through that function. The only thing we do with q is assign it and then use it. That is it.
>
> Regards
>
> Marcel
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-01 15:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 13:57 [PATCH] net: bluetooth: hci_core.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-01 14:24 ` Marcel Holtmann
[not found] ` <AB19A214-D495-44EE-87E0-45332F156767-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
2014-06-01 15:41 ` Rickard Strandqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).