Re: [exim] Exim 4.89 compile warning on Ubuntu 14.04

Top Pagina
Delete this message
Reply to this message
Auteur: Phil Pennock
Datum:  
Aan: Michael J. Tubby B.Sc. MIET
CC: exim-users
Onderwerp: Re: [exim] Exim 4.89 compile warning on Ubuntu 14.04
On 2017-03-08 at 09:05 +0000, Michael J. Tubby B.Sc. MIET wrote:
> exim.c: In function ‘usr1_handler’:
> exim.c:235:1: warning: ignoring return value of ‘write’, declared
> with attribute warn_unused_result [-Wunused-result]
> (void)write(fd, process_info, process_info_len);
> ^


> and believing that cleanliness is next to godliness have fixed the
> warning by removing the (void) cast over the write function and
> assigning the return value to variable 'sz'.


No, I object to this change.

Assigning to a variable which is then unused is wrong, and a sign of a
bug. Decent languages treat this as a compile error (Golang). Return
values should either be handled _properly_ or honestly and openly
discarded. In that handler, the decision was made to discard.

The return value is being explicitly discarded via explicit `(void)`
cast of the result. This is as explicit as it gets that we are
knowingly and deliberately not heeding the result.

The compiler treating this as a warning is a compiler bug. I got the
same warning on an Ubuntu box. I ignore it. `-Wunused-result` should
be skipping complaining about explicit void casts. Making the code
deceptive by assigning to a variable is the wrong thing to do here.

-Phil