Skip to contentSkip to conversation

drivers/block/cciss.c (2.6.34.7): Fixed useless compile warning

PATCH In review Poyo VL 3 participants 3 messages Sep 21, 2010

Subsystems (2)
lore
Share & tools
lore

Poyo VL

author
#0 lore raw

PATCH 1/1 drivers/block/cciss.c (2.6.34.7): Fixed useless compile warning

GCC version: gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE Linux)

And I'm sorry, the kernel version is 2.6.34.7 not 2.6.35.7.
But I selected almost all options from "make menuconfig", I think this is important to mention.
All warnings are like this one
drivers/block/cciss.c: In function ‘dev_show_unique_id’:
drivers/block/cciss.c:564:7: warning: ‘sn[0]’ may be used uninitialized in this function
I tried to explain. The sn[] array is initialized here: else memcpy(sn, drv->serial_no, sizeof(sn)); so it is initialized in a conditional expression, and is is used downer. So, the compiler think that it can be used unititialized and it throws that warning.
I fixed the patch, I am sorry, I'm a newbie.

---

drivers/block/cciss.c 2010-09-13 19:54:58.000000000 +0300 renamed from drivers/block/cciss.c 2010-09-17 20:17:49.844010958 +0300 +1 -1
@@ -561,7 +561,7 @@ static ssize_t dev_show_unique_id(struct
 {
     drive_info_struct *drv = to_drv(dev);
     struct ctlr_info *h = to_hba(drv->dev.parent);
-    __u8 sn[16];
+    __u8 sn[16] = {0};
     unsigned long flags;
     int ret = 0;
 

----- Forwarded Message ----
From: Dan Carpenter <[email protected]>
To: Poyo VL <[email protected]>
Cc: [email protected]
Sent: Tue, September 21, 2010 10:05:59 AM
Subject: Re: [PATCH] drivers/block/cciss.c (2.6.35.7): Fixed useless compile warning

Which version of gcc are you using? It doesn't print any error message for me on version 4.3.2 (which is really old).

The idea is fine but the patch is all messed up. First of all the it's reversed. It says '+' where it should say '-' and '-' where it should say '+'.

Also your mail client has completely mangled it. It has removed spaces from the start of lines and changed the tabs to spaces. Please read Documentation/email-clients.txt and send an email to yourself. Save the email as raw text. cat email.txt | patch -p1.

When that works resend it. Add these people to the CC list:

Mike Miller <[email protected]>
Jens Axboe <[email protected]>
"Stephen M. Cameron" <[email protected]> [email protected]

Also you don't need to copy all 16 lines of error messages. Just a couple will do. But do say which version of gcc you are using.

regards,
dan carpenter

#1 lore raw

Re: Fw: [PATCH] drivers/block/cciss.c (2.6.34.7): Fixed useless

Quoted 4 lines · Poyo VL

GCC version: gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE Linux)

And I'm sorry, the kernel version is 2.6.34.7 not 2.6.35.7.

It also applies to the 2.6.36-rc4 kernel with offset 45 so that's ok.

Quoted 2 lines

But I selected almost all options from "make menuconfig", I think this is important to mention.

You can leave this information out.

Quoted 10 lines

All warnings are like this one
drivers/block/cciss.c: In function ‘dev_show_unique_id’:
drivers/block/cciss.c:564:7: warning: ‘sn[0]’ may be used uninitialized in this function
I tried to explain. The sn[] array is initialized here: else memcpy(sn, drv->serial_no, sizeof(sn)); so it is initialized in a conditional expression, and is is used downer. So, the compiler think that it can be used unititialized and it throws that warning.

I fixed the patch, I am sorry, I'm a newbie.

Don't appologize. Kernel-janitors is here to help newbies.

This version was much better, but your email client is still changing all the spaces to tabs. Can you send it again as version 3? Please send the email to yourself and verify that the patch applies. Just save the email as "raw format with headers" or whatever it's called. Then cat raw_email.txt | patch -p1 and send it to us again once that works.

regards,
dan carpenter

Acked-by on v1 1/1
#2 lore raw

RE: [PATCH] drivers/block/cciss.c (2.6.34.7): Fixed useless compile

In reply to Poyo VL
Quoted 36 lines

-----Original Message-----
From: Poyo VL [mailto:[email protected]]
Sent: Tuesday, September 21, 2010 4:48 AM
To: [email protected]
Cc: [email protected]; Miller, Mike (OS Dev); [email protected]; [email protected]; ISS StorageDev; [email protected]
Subject: Fw: [PATCH] drivers/block/cciss.c (2.6.34.7): Fixed useless compile warning

GCC version: gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE
Linux)

And I'm sorry, the kernel version is 2.6.34.7 not 2.6.35.7. But I selected almost all options from "make menuconfig", I think this is important to mention.
All warnings are like this one
drivers/block/cciss.c: In function 'dev_show_unique_id':
drivers/block/cciss.c:564:7: warning: 'sn[0]' may be used uninitialized in this function I tried to explain. The sn[] array is initialized here: else memcpy(sn, drv->serial_no, sizeof(sn)); so it is initialized in a conditional drv->expression,
and is is used downer. So, the compiler think that it can be used unititialized and it throws that warning.
I fixed the patch, I am sorry, I'm a newbie.

---

drivers/block/cciss.c 2010-09-13 19:54:58.000000000 +0300 static ssize_t dev_show_unique_id(struct { · line 565

Quoted 6 lines
drivers/block/cciss.c 2010-09-13 19:54:58.000000000 +0300 renamed from drivers/block/cciss.c 2010-09-17 20:17:49.844010958 +0300 +1 -1
@@ -561,7 +561,7 @@ static ssize_t dev_show_unique_id(struct  {
     drive_info_struct *drv = to_drv(dev);
     struct ctlr_info *h = to_hba(drv->dev.parent);
-    __u8 sn[16];
+    __u8 sn[16] = {0};
     unsigned long flags;
     int ret = 0;
Quoted 45 lines
drivers/block/cciss.c 2010-09-13 19:54:58.000000000 +0300 renamed from drivers/block/cciss.c 2010-09-17 20:17:49.844010958 +0300 +0 -1
----- Forwarded Message ----

From: Dan Carpenter <[email protected]>
To: Poyo VL <[email protected]>
Cc: [email protected]
Sent: Tue, September 21, 2010 10:05:59 AM
Subject: Re: [PATCH] drivers/block/cciss.c (2.6.35.7): Fixed useless compile warning

Which version of gcc are you using? It doesn't print any error message
for me on version 4.3.2 (which is really old).

The idea is fine but the patch is all messed up. First of all the it's
reversed. It says '+' where it should say '-' and '-' where it should say '+'.

Also your mail client has completely mangled it. It has removed spaces
from the start of lines and changed the tabs to spaces. Please read Documentation/email-clients.txt and send an email to yourself. Save the
email as raw text. cat email.txt | patch -p1.

When that works resend it. Add these people to the CC list:

Mike Miller <[email protected]>
Jens Axboe <[email protected]>
"Stephen M. Cameron" <[email protected]> [email protected]

Also you don't need to copy all 16 lines of error messages. Just a couple will do. But do say which version of gcc you are using.

regards,
dan carpenter