Re: [PATCH] Cast removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> -	(void) kmem_cache_destroy(cache);
>> +	kmem_cache_destroy(cache);
>> 
>> I believe that the point of the (void) is to prevent lint from
>> squawking, and perhaps some picky ANSI-C compilers. What is the overall
>> Linux policy on this?
>
>IMHO there's another reason to do this which is much more relevant: it
>tells the reader that whoever wrote it knows that it returns a value
>and ignores it on purpose.

And GCC does not care about that, i.e. it still prints foritfy warnings, 
as in:

$ svn co https://svn.sourceforge.net/svnroot/ttyrpld/trunk a && cd a
$ make user/rpld.o EXT_CFLAGS="-D_FORTIFY_SOURCE=2"
user/rpld.c:425: warning: ignoring return value of ‘write’, declared 
with attribute warn_unused_result

Adding (void) to the front to line 425 does not get rid of the warning. 
So doing so does not seem to be the right way to let others know you 
intentionally want to discard the return value. Plus, on top, many 
(sometimes older) C books advise to cast to (void) just because 
something does not return it.



	-`J'
-- 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux