Dan, Z,
I use gcc 4.6.3 with a fairly recent linux stable kernel release.
Here is an example of why I would like the -Wno-unused-result flag to remain. Notice that if you take the
TOB kernel and compile with a pretty recent compiler and kernel you get a bunch of unused result warnings
that are not of much interest. These could be cleaned up by casting the returns from these system calls to
void and these warnings would go away and then we would not need -Wno-unused-result at all. This would
the best way to get rid of the -Wno-unused-result flag and maintain a clean compilation.
Now take a look at what you see with Dan's first patch applied to TOB and -Wno-unused-result flag. You see
will see that 3 new warnings cropped up in ipmi_fru.c that should be fixed, but were not noticed either because the
warnings were lost in the other warnings or by virtue of a compiler/OS that didn't have the extra warning
messages.
With gcc 4.6.3 on ubuntu here are the warnings I get with TOB and no (-Wno-unused-result) flag.
Note: If I have -Wno-unused-result turned on, I don't get any warning messages when I compile ipmitool.
helper.c:633:7: warning: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Wunused-result]
helper.c:642:5: warning: ignoring return value of 'dup', declared with attribute warn_unused_result [-Wunused-result]
helper.c:643:5: warning: ignoring return value of 'dup', declared with attribute warn_unused_result [-Wunused-result]
ipmi_fru.c:1563:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
ipmi_fru.c:1575:9: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
ipmi_hpmfwupg.c:2592:15: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_hpmfwupg.c:1107:10: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2335:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2397:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2411:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2426:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2451:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2454:22: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2465:22: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2475:22: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2554:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2557:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2567:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2619:13: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2639:31: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2668:28: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2681:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2742:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2745:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2754:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:3892:13: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:3908:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:3918:25: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
With gcc 4.6.3 on ubuntu here are the warnings I get with Dan's First patch applied to TOB and no (-Wno-unused-result) flag.
helper.c:633:7: warning: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Wunused-result]
helper.c:642:5: warning: ignoring return value of 'dup', declared with attribute warn_unused_result [-Wunused-result]
helper.c:643:5: warning: ignoring return value of 'dup', declared with attribute warn_unused_result [-Wunused-result]
ipmi_fru.c:2917:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat]
ipmi_fru.c:2917:11: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat]
ipmi_fru.c:2917:11: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat]
ipmi_fru.c:1563:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
ipmi_fru.c:1575:9: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
ipmi_hpmfwupg.c:2592:15: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_hpmfwupg.c:1107:10: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2335:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2397:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2411:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2426:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2451:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2454:22: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2465:22: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2475:22: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2554:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2557:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2567:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2619:13: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2639:31: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2668:28: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2681:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2742:16: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2745:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:2754:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:3892:13: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:3908:19: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
ipmi_ekanalyzer.c:3918:25: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
Post by Dan GoraPost by Zdenek Styblik[...]
Post by Dan GoraI agree, but I think that it's better to fix the warnings if at all
possible. Of course adding -Werror would force people to deal with
their warnings.
Dan,
does it mean to deal with warnings/"errors" left by "others" as well?
Well if you want it to compile cleanly without warnings, that's pretty
much the only way to do it, regardless of who's responsible.
Post by Zdenek StyblikIf so ... yeah, I'd be realistic about this one.
Yeah I agree.. I don't have any problem with the odd warning here and
there, especially since gcc changes what it warns about in some
versions (comparing signed and unsigned chars for example).
Post by Zdenek StyblikIn other words, I despite I agree, I don't think it's going to fly.
:-/ Same for clean compilation - somewhat wishful thinking. Just check
the tracker and never ending queue of tickets.
I agree, but removing -Wno-unused-return doesn't add any new warnings
that I can see. If it does, then I'll fix it, but I didn't see any.
thanks
d