On 2019-02-02, Andrew C Aitchison via Exim-dev <exim-dev@exim.org> wrote:
> On Sat, 2 Feb 2019, admin--- via Exim-dev wrote:
>
>> https://bugs.exim.org/show_bug.cgi?id=2368
>>
>> Jeremy Harris <jgh146...@wizmail.org> changed:
>>
>>           What    |Removed                     |Added
>> ----------------------------------------------------------------------------
>>         Resolution|---                         |WONTFIX
>>           Assignee|ni...@exim.org              |jgh146...@wizmail.org
>>             Status|NEW                         |RESOLVED
>>
>> --- Comment #1 from Jeremy Harris <jgh146...@wizmail.org> ---
>> This is a matter for choosing compiler switches to avoid doing such static
>> analysis.  We refuse to endlessly chase such things by using more-and-more
>> convoluted coding.  Even the cast-to-void could be regarded as such an
>> attempt, but it least its heritage goes back over thirty years.

> This patch makes the code clearer,
> and makes it explicit that we know what we are doing.
> If it makes that the compiler happy at the same time,
> then we can leave the switches set in a way that helps us avoid writing 
> new bugs.

If the optimizer does not spot it you have code that wastes resources
(albeit a small amount in this case). Also now you have two variables
that are assigned a value which is not used: this is potentially another
static analysis violation. (gcc would find that at optimisation level
2 last time I checked)

casting the function result to void is the traditional way to
silence the unused return value warnings:

  /* ignoring the return values here because nothing can be done if this fails 
*/

  (void) write(fd, process_info, process_info_len);
  (void) close(fd);



-- 
  When I tried casting out nines I made a hash of it.

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim 
details at http://www.exim.org/ ##

Reply via email to