Hi,

building with compiler flags "-Wall -O2 -D_FORTIFY_SOURCE=2" throws some
warnings:

[EMAIL PROTECTED]:~/projects/powermanagement/cvs/suspend> make CFLAGS='-Wall 
-O2 -D_FORTIFY_SOURCE=2'
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -c vt.c -o vt.o
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c md5.c -o 
md5.o
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -DHAVE_INTTYPES_H -DHAVE_STDINT_H 
-I/usr/local/include -c encrypt.c -o encrypt.o
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -I/usr/local/include -c config.c -o config.o
cc -g -Wall -O2 -D_FORTIFY_SOURCE=2 -I/usr/local/include -c bootsplash.c -o 
bootsplash.o
cc -g -Wall -O2 -D_FORTIFY_SOURCE=2 -I/usr/local/include -c splash.c -o splash.o
cc -g -Wall -O2 -D_FORTIFY_SOURCE=2 -I/usr/local/include vt.o md5.o encrypt.o 
config.o suspend.c -o s2disk splash.o bootsplash.o -L/usr/local/lib
suspend.c: In function ‘prepare_console’:
suspend.c:816: warning: ignoring return value of ‘write’, declared with 
attribute warn_unused_result
suspend.c: In function ‘get_kernel_console_loglevel’:
suspend.c:886: warning: ignoring return value of ‘fscanf’, declared with 
attribute warn_unused_result
suspend.c: In function ‘get_swappiness’:
suspend.c:919: warning: ignoring return value of ‘fscanf’, declared with 
attribute warn_unused_result
suspend.c: In function ‘main’:
suspend.c:1192: warning: ignoring return value of ‘chdir’, declared with 
attribute warn_unused_result
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -c vbetool/lrmi.c -o vbetool/lrmi.o
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -c vbetool/x86-common.c -o vbetool/x86-common.o
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -DS2RAM -c vbetool/vbetool.c -o 
vbetool/vbetool.o
vbetool/vbetool.c: In function ‘save_state’:
vbetool/vbetool.c:347: warning: ignoring return value of ‘write’, declared with 
attribute warn_unused_result
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -DS2RAM -c radeontool.c -o radeontool.o
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -DS2RAM -c dmidecode.c -o dmidecode.o
cc -g -Wall -O2 -D_FORTIFY_SOURCE=2 -DCONFIG_BOTH -I/usr/local/include md5.o 
encrypt.o config.o suspend.c s2ram.c -o s2both vt.o vbetool/lrmi.o 
vbetool/x86-common.o vbetool/vbetool.o radeontool.o dmidecode.o splash.o 
bootsplash.o -L/usr/local/lib -lpci
suspend.c: In function ‘prepare_console’:
suspend.c:816: warning: ignoring return value of ‘write’, declared with 
attribute warn_unused_result
suspend.c: In function ‘get_kernel_console_loglevel’:
suspend.c:886: warning: ignoring return value of ‘fscanf’, declared with 
attribute warn_unused_result
suspend.c: In function ‘get_swappiness’:
suspend.c:919: warning: ignoring return value of ‘fscanf’, declared with 
attribute warn_unused_result
suspend.c: In function ‘main’:
suspend.c:1192: warning: ignoring return value of ‘chdir’, declared with 
attribute warn_unused_result
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -I/usr/local/include md5.o encrypt.o config.o 
vt.o resume.c splash.o bootsplash.o -static -o resume -L/usr/local/lib
resume.c: In function ‘main’:
resume.c:737: warning: ignoring return value of ‘fgets’, declared with 
attribute warn_unused_result
cc -Wall -O2 -D_FORTIFY_SOURCE=2 -g s2ram.c vt.o vbetool/lrmi.o 
vbetool/x86-common.o vbetool/vbetool.o radeontool.o dmidecode.o -lpci -o s2ram

In our build system, _FORTIFY_SOURCE=2 is mandatory and sooner or later those
warnings will become errors. I can always work around them by casting to void,
but as was pointed out to me by our toolchain team, some of them are probably
real errors.

If we _know_ that this write or fscanf cannot fail because we also _know_ what
we are doing on the kernel side, then we should probably add a comment at the
appropriate places and maybe just add a (void) cast. This is ugly to look at,
but tells everybody else that we did not just forget to check for the values.

Even leaving out the void cast, an comment like "this will throw a warning,
but we know that this cannot fail" is better so i can defend my local patches
against theevil overlords of the buildsystem :-)

Thanks,
-- 
Stefan Seyfried
QA / R&D Team Mobile Devices        |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg  | "Well, surrounding them's out." 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to