Compilation errors on Ubuntu 8.10 Intrepid Ibex

Maxim Dounin mdounin at
Tue Nov 11 00:35:40 MSK 2008


On Mon, Nov 10, 2008 at 11:34:37PM +0300, Igor Sysoev wrote:

> On Mon, Nov 10, 2008 at 09:38:39AM -0800, Eric Benson wrote:
> > Compiling either 0.6.32 or 0.7.20 on a new Ubuntu 8.10 installation with gcc 4.3.2 causes errors due to a new compiler warning (when combined with the use of -Werror in CFLAGS). There is now a compiler warning when the return value of write() is ignored. This causes errors in a number of placees in nginx. I have included a log showing the compiler output as well as a patch file showing the changes I made to avoid these errors.
> Thank you.
> However, there is more elegant way to suppress this warning without
> stub variables:
>       (void) write_fd(...)
> Could you test the attached patch ?

No, warn_unused_result warning can't be avoided by casting to 

$ cat unused.c
int foo() __attribute__((warn_unused_result));

        return 1;

        (void) foo();

        return 0;
$ gcc unused.c
unused.c: In function 'main':
unused.c:12: warning: ignoring return value of 'foo', declared with attribute warn_unused_result

More details here:

However I don't think it's a good idea to use stub variables.  
Probably something like

    if (ngx_write_fd(...) == NGX_FILE_ERROR) {
        /* void */

would be better.

Maxim Dounin

p.s. Actually I think that it's glibc's bug.  But we probably have 
to live with it, at least for some time.

More information about the nginx mailing list