On 20/11/08 17:58, Dominique Pelle wrote:
> 2008/11/20 Charles Campbell<[EMAIL PROTECTED]>:
>> Bram Moolenaar wrote:
>>> Patch 7.2.041-7.2.048 (not sure which one)
>> Hello!
>>
>> I'm starting to get some warnings that I didn't used to get...
>>
>> gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
>> -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include
>> -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0
>> -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
>> -I/usr/include/freetype2 -I/usr/include/libpng12 -g -O2
>> -D_FORTIFY_SOURCE=1 -I/usr/include64 -D_REENTRANT -D_GNU_SOURCE
>> -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
>> -I/usr/include/gdbm
>> -I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE
>> -I/usr/include/python2.4 -pthread -o objects/spell.o spell.c
>> spell.c: In function 'write_vim_spell':
>> spell.c:7958: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:7969: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8019: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8030: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8116: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8134: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8138: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8163: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8179: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8235: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8238: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c:8262: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>> spell.c: In function 'write_spell_prefcond':
>> spell.c:9909: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>>
>> I tried preceding the calls to fwrite() with (void) casts, but that
>> didn't remove the warnings. Putting
>> int nfw;
>> in the write_vim_spell() and write_spell_prefcond() functions and doing
>> nfw= fwrite(...)
>> did remove the warnings.
>>
>> Regards,
>> Chip Campbell
>
>
> Ah, yes... This is actually related to adding -D_FORTIFY_SOURCE=1
> in patch 7.2.44.
>
> If we put -D_FORTIFY_SOURCE=0, that gets rid of warnings, while
> still fixing the crash (which happened on Ubuntu because gcc on
> Ubuntu is modified to use -D_FORTIFY_SOURCE=2 by default
> and Vim does things that cause a crash with -D_FORTIFY_SOURCE=2).
>
> But by setting -D_FORTIFY_SOURCE=0 instead of 1, we miss
> some possibly useful error detections at compilation time or runtime.
>
> Ignoring return value of fwrite() is dangerous in my opinion.
> I/Os can fail. And if they can fail, they will fail.
>
> But if we want to shut the warning, I would prefer
> -D_FORTIFY_SOURCE=0 than storing the return value
> of fwrite() in a variable which gets ignored. So that:
>
> * code does not get cluttered with warning workarounds;
> * and developers can still override to use -D_FORTIFY_SOURCE=1
> should they want to see those warnings (since those warnings are
> useful in my opinion).
>
> -- Dominique
All the "new" warnings I see, with no exception, are for not using the
result of a function which returns a result of type warn_unused_result.
My first impression was that:
- these warnings were probably related to the new define
FORTIFY_SOURCE=1, which is set at the very end of the configure run.
- type warn_unused_result rather than char, int or whatever might have
been put in there by Bram to tell me that there will be a spurious warning.
So I decided to ignore them all.
Best regards,
Tony.
--
2180, U.S. History question:
What 20th Century U.S. President was almost impeached and what
office did he later hold?
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---