[PATCH] Fix compilation warnings in usr/kernel code

4 views
Skip to first unread message

Erez Zilber

unread,
Sep 3, 2009, 12:21:27 PM9/3/09
to open-...@googlegroups.com
Fix compilation warnings and modify the Makefiles to treat
warnings as errors.

Signed-off-by: Erez Zilber <erezz...@gmail.com>

0001-Fix-compilation-warnings-in-usr-kernel-code.patch

Erez Zilber

unread,
Sep 3, 2009, 12:24:34 PM9/3/09
to open-...@googlegroups.com

2 comments about this patch:
1. I'm not familiar enough with the fwparam_ibft code, so I didn't add
the -Werror flag to the Makefile. There are still compilation warnings
in that code.
2. I was able to test it on CentOS 5.3 & kubuntu 9.04 only. If anyone
can test it on other kernels and submit fixes, it would be great.

Erez

Mike Christie

unread,
Sep 3, 2009, 1:02:36 PM9/3/09
to open-...@googlegroups.com


Thanks.


I get this compilation error on fedora 10. We used to get a warning about it not being initialized and upstream we did this patch. Is this just a bug in my compiler?


@@ -693,6 +692,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
"Too many iscsi targets. Max "
"number of targets is %d.\n",
ISCSI_MAX_TARGET - 1);
+ err = -EOVERFLOW;
goto release_host;
}
}


make
make -C /lib/modules/2.6.29.4-167.fc11.x86_64/build M=`pwd` KBUILD_OUTPUT= V=0 modules
make[1]: Entering directory `/usr/src/kernels/2.6.29.4-167.fc11.x86_64'
CC [M] /home/mnc/kernel/iscsi/open-iscsi/devel/open-iscsi/kernel/scsi_transport_iscsi.o
cc1: warnings being treated as errors
/home/mnc/kernel/iscsi/open-iscsi/devel/open-iscsi/kernel/scsi_transport_iscsi.c: In function ‘iscsi_add_session’:
/home/mnc/kernel/iscsi/open-iscsi/devel/open-iscsi/kernel/scsi_transport_iscsi.c:678: error: ‘err’ may be used uninitialized in this function
make[2]: *** [/home/mnc/kernel/iscsi/open-iscsi/devel/open-iscsi/kernel/scsi_transport_iscsi.o] Error 1
make[1]: *** [_module_/home/mnc/kernel/iscsi/open-iscsi/devel/open-iscsi/kernel] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.29.4-167.fc11.x86_64'

Erez Zilber

unread,
Sep 6, 2009, 3:11:13 AM9/6/09
to open-...@googlegroups.com

Yeah, this looks strange because err should have been initialized in
the for loop (assuming that ISCSI_MAX_TARGET > 0). Maybe the compiler
doesn't check that (which may be considered a bug/feature ;) ). Do you
want to add this fix also to open-iscsi.git?

Erez

Ulrich Windl

unread,
Sep 7, 2009, 2:18:42 AM9/7/09
to open-...@googlegroups.com
On 6 Sep 2009 at 10:11, Erez Zilber wrote:

> Yeah, this looks strange because err should have been initialized in
> the for loop (assuming that ISCSI_MAX_TARGET > 0). Maybe the compiler
> doesn't check that (which may be considered a bug/feature ;) ). Do you
> want to add this fix also to open-iscsi.git?

Yes, there are some situations where gcc does not detect that a variable is
initialized. However in most cases gcc is right.

Ulrich

Boaz Harrosh

unread,
Sep 7, 2009, 7:06:15 AM9/7/09
to open-...@googlegroups.com
On 09/03/2009 08:02 PM, Mike Christie wrote:
>
> On 09/03/2009 11:21 AM, Erez Zilber wrote:
>> Fix compilation warnings and modify the Makefiles to treat
>> warnings as errors.
>>
>> Signed-off-by: Erez Zilber <erezz...@gmail.com>
>>
>
>
> Thanks.
>
>
> I get this compilation error on fedora 10. We used to get a warning about it not being initialized and upstream we did this patch. Is this just a bug in my compiler?
>
>
> @@ -693,6 +692,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
> "Too many iscsi targets. Max "
> "number of targets is %d.\n",
> ISCSI_MAX_TARGET - 1);
> + err = -EOVERFLOW;

Better use the uninitialized_var() macro on declaration of variable.
1. It does not produce any code in shutting up the warning.
2. There is a scrip laying around that turns the macro off and looks for warning instances
for every uninitialized_var use. So in the future this can be removed when the compilers
we care about stop to complain.
3. Better Programmer's communication of what's up.

Boaz

Mike Christie

unread,
Sep 8, 2009, 2:01:27 PM9/8/09
to open-...@googlegroups.com

I messed up. I thought we already had the fix, so I was wondering why I
get the compilation error with your patch. I mean I thought your patch
added a new failure somehow. Ignore me :)

Erez Zilber

unread,
Sep 9, 2009, 2:31:15 AM9/9/09
to open-...@googlegroups.com

OK, so do you want to apply my patch as is + the required fix in
iscsi_add_session?

Erez

Mike Christie

unread,
Sep 9, 2009, 11:45:09 AM9/9/09
to open-...@googlegroups.com

Yeah, I was going to apply the iscsi_add_session fix (I was acutally
working on resyncing all the upstream code that was sent for 2.6.32 and
2.6.31 with the open-iscsi/kernel stuff) then your patch.

Mike Christie

unread,
Nov 12, 2009, 11:30:48 AM11/12/09
to open-...@googlegroups.com
Erez Zilber wrote:
> Fix compilation warnings and modify the Makefiles to treat
> warnings as errors.
>

Just a update on this patch. I was doing more testing and on Fedora 9, I
get:

isns.c: In function ‘build_dev_reg_req’:
isns.c:146: error: dereferencing pointer ‘lss.24’ does break
strict-aliasing rules
isns.c:146: note: initialized from here
isns.c:153: error: dereferencing pointer ‘lss.24’ does break
strict-aliasing rules
isns.c:153: note: initialized from here
isns.c:157: error: dereferencing pointer ‘lss.27’ does break
strict-aliasing rules
isns.c:157: note: initialized from here
make[1]: *** [isns.o] Error 1
make[1]: Leaving directory
`/home/mnc/kernel/iscsi/open-iscsi/devel/tmp/open-iscsi/usr'

Reply all
Reply to author
Forward
0 new messages