Re: [exim] Patch for Exim 4.91 compile warning

Top Pagina
Delete this message
Reply to this message
Auteur: Mike Tubby
Datum:  
Aan: exim-users
Onderwerp: Re: [exim] Patch for Exim 4.91 compile warning

On 16/01/2019 14:31, Heiko Schlittermann via Exim-users wrote:
> Mike Tubby via Exim-users <exim-users@???> (Mi 16 Jan 2019 14:58:07 CET):
>> All,
>>
>> When compiling Exim 4.91 on Ubuntu 16.04.5 LTS I get a gcc warning in the
>> USR1 signal handler:
>>
>> gcc exim.c
>> exim.c: In function ‘usr1_handler’:
>> exim.c:242:1: warning: ignoring return value of ‘write’, declared with
>> attribute warn_unused_result [-Wunused-result]
>>  (void)write(fd, process_info, process_info_len);
>>  ^
>> gcc expand.c
> On a curent Debian this attribute isn't used for the write(2)
> call. Hm. Intentional?
>
>>> if (fd > 0) {
>>>    ssize_t x;
>>>    int y;
>>>
>>>    x = write(fd, process_info, process_info_len);
>>>    y = close(fd);
>>>    }
>> 242,243d252
>> < (void)write(fd, process_info, process_info_len);
>> < (void)close(fd);
> While (void) write(…) seems to express clearly the intention,
> I'm not sure why GCC does not understand it (anymore, not yet?)


Heiko, I completely agree with the intention of:

    (void)function(...)

and have used it many times myself over the years - I can only guess
that the makefile with GCC 5.4.0 options turns back on something that
makes this a warning again.

Here's the GCC version:

root@relay1:~/exim-4.91# gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>
> Beside from your proposal using a dummy variable, I found another
> way
>
>      if (write(…));
>      if (close(…));

>
> But it needs a comment or a macro like
>
>      #define IGNORE_RESULT(x) if(x)
>      …
>      IGNORE_RESULT(write(…))


Agreed but this is getting even more messy ;-)


Regards

Mike


> --
> Heiko
>