linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: r8192U_core.c:  Cleaning up uninitialized variables
@ 2014-06-01 13:28 Rickard Strandqvist
  2014-06-01 20:37 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 13:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Xenia Ragiadakou
  Cc: Rickard Strandqvist, Peter P Waskiewicz Jr, Ana Rey,
	Dan Carpenter, Teodora Baluta, Andrea Merello, devel,
	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>
---
 drivers/staging/rtl8192u/r8192U_core.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 1bb6143..b88fb6d 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4695,9 +4695,10 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 	u32  PacketShiftBytes = 0;
 	rx_desc_819x_usb_aggr_subframe *RxDescr = NULL;
 	u8  PaddingBytes = 0;
+#ifdef USB_RX_AGGREGATION_SUPPORT
 	//add just for testing
-	u8   testing;
-
+	u8   testing = 0;
+#endif
 #endif
 
 	/* 20 is for ps-poll */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8192u: r8192U_core.c:  Cleaning up uninitialized variables
  2014-06-01 13:28 [PATCH] staging: rtl8192u: r8192U_core.c: Cleaning up uninitialized variables Rickard Strandqvist
@ 2014-06-01 20:37 ` Dan Carpenter
  2014-06-01 21:05   ` Rickard Strandqvist
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-06-01 20:37 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Greg Kroah-Hartman, Xenia Ragiadakou, Peter P Waskiewicz Jr,
	Ana Rey, Teodora Baluta, Andrea Merello, devel, linux-kernel

On Sun, Jun 01, 2014 at 03:28:35PM +0200, Rickard Strandqvist wrote:
> 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.
> 

I've looked at the code, but I don't see this variable actually used
anywhere.  What is the exact cppcheck warning message?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8192u: r8192U_core.c: Cleaning up uninitialized variables
  2014-06-01 20:37 ` Dan Carpenter
@ 2014-06-01 21:05   ` Rickard Strandqvist
  2014-06-02  7:39     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 21:05 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, Xenia Ragiadakou, Peter P Waskiewicz Jr,
	Ana Rey, Teodora Baluta, Andrea Merello, devel, linux-kernel

Hi Dan

I agree, this looks strange.
Have been looking for a while in history with, to see if the code has
been removed. I start my search using cppcheck for over three months
ago.
But could not find anything. Sorry about that :-(

But I'll make a patch that completely removes testing variable then instead?


Best regards
Rickard Strandqvist


2014-06-01 22:37 GMT+02:00 Dan Carpenter <dan.carpenter@oracle.com>:
> On Sun, Jun 01, 2014 at 03:28:35PM +0200, Rickard Strandqvist wrote:
>> 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.
>>
>
> I've looked at the code, but I don't see this variable actually used
> anywhere.  What is the exact cppcheck warning message?
>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8192u: r8192U_core.c: Cleaning up uninitialized variables
  2014-06-01 21:05   ` Rickard Strandqvist
@ 2014-06-02  7:39     ` Dan Carpenter
  2014-06-02 20:16       ` Rickard Strandqvist
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-06-02  7:39 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Greg Kroah-Hartman, Xenia Ragiadakou, Peter P Waskiewicz Jr,
	Ana Rey, Teodora Baluta, Andrea Merello, devel, linux-kernel

On Sun, Jun 01, 2014 at 11:05:39PM +0200, Rickard Strandqvist wrote:
> Hi Dan
> 
> I agree, this looks strange.
> Have been looking for a while in history with, to see if the code has
> been removed. I start my search using cppcheck for over three months
> ago.
> But could not find anything. Sorry about that :-(
> 
> But I'll make a patch that completely removes testing variable then instead?

Yes.  Btw, what do the cppcheck error messages for this look like
anyway?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8192u: r8192U_core.c: Cleaning up uninitialized variables
  2014-06-02  7:39     ` Dan Carpenter
@ 2014-06-02 20:16       ` Rickard Strandqvist
  0 siblings, 0 replies; 5+ messages in thread
From: Rickard Strandqvist @ 2014-06-02 20:16 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, Xenia Ragiadakou, Peter P Waskiewicz Jr,
	Ana Rey, Teodora Baluta, Andrea Merello, devel, linux-kernel

Hi Dan!


Now this is a bad example because there is nothing really wrong, and I
could not find the original error log :-(


But i get for the testing variable:
drivers/staging/rtl8192u/r8192U_core.c : 4747] :  (style) Variable
'testing' is assigned a value that is never used.


And for the this file i now get:

drivers/staging/rtl8192u/r8192U_core.c : 1014] :  (style) Variable
'ret' is assigned a value that is never used.
drivers/staging/rtl8192u/r8192U_core.c : 1258] :  (error) Possible
null pointer dereference :  dev
drivers/staging/rtl8192u/r8192U_core.c : 1411] :  (style) Variable
'rate_config' is assigned a value that is never used.
drivers/staging/rtl8192u/r8192U_core.c : 1908] :  (portability)
'oldaddr' is of type 'void *'. When using void pointers in
calculations, the behaviour is undefined.
drivers/staging/rtl8192u/r8192U_core.c : 1959] :  (style) Unused variable :  i
drivers/staging/rtl8192u/r8192U_core.c : 2040] ->
[drivers/staging/rtl8192u/r8192U.h : 1129] :  (style, inconclusive)
The struct 'r8192_priv' hides a typedef with the same name.
drivers/staging/rtl8192u/r8192U_core.c : 2041] ->
[drivers/staging/rtl8192u/r8192U_core.c : 2048] :  (warning) Possible
null pointer dereference :  priv - otherwise it is redundant to check
it against null.




But why not test yourself, see:


http://cppcheck.sourceforge.net/


Appropriate arguments to start with are:
cppcheck --force --quiet  --enable=all drivers/staging/rtl8192u/r8192U_core.c


Best regards
Rickard Strandqvist


2014-06-02 9:39 GMT+02:00 Dan Carpenter <dan.carpenter@oracle.com>:
> On Sun, Jun 01, 2014 at 11:05:39PM +0200, Rickard Strandqvist wrote:
>> Hi Dan
>>
>> I agree, this looks strange.
>> Have been looking for a while in history with, to see if the code has
>> been removed. I start my search using cppcheck for over three months
>> ago.
>> But could not find anything. Sorry about that :-(
>>
>> But I'll make a patch that completely removes testing variable then instead?
>
> Yes.  Btw, what do the cppcheck error messages for this look like
> anyway?
>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-02 20:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 13:28 [PATCH] staging: rtl8192u: r8192U_core.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-01 20:37 ` Dan Carpenter
2014-06-01 21:05   ` Rickard Strandqvist
2014-06-02  7:39     ` Dan Carpenter
2014-06-02 20:16       ` 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).