Re: [exim] Patch for Exim 4.91 compile warning

Top Page
Delete this message
Reply to this message
Author: Heiko Schlittermann
Date:  
To: exim-users
Subject: Re: [exim] Patch for Exim 4.91 compile warning
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?)

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(…))


--
Heiko