Nginx 1.0.11 + upload module compile error

Hi all,

This is my nginx setup:

I can compile from source with --add-module flag on:

  • OS X Snow Leopard (gcc version 4.2.1)
  • Ubuntu 10.10 (gcc version 4.4.3)

But compilation failed on Kubuntu 11.10 (gcc version 4.6.1)

It failed because the http upload module defined a variable but the
compiler claimed it wasn’t used and fails compilation.

Below is snippet inside ngx_http_upload_module.c

static ngx_int_t /* {{{ ngx_http_upload_merge_ranges */
ngx_http_upload_merge_ranges(ngx_http_upload_ctx_t *u,
ngx_http_upload_range_t *range_n) {

int result;

/* Some more code .... */

// This is where it is being called.
if(out_buf.file_pos < state_file->info.st_size) { result =

ftruncate(state_file->fd, out_buf.file_pos); }
}

If I change objs/Makefile to ignore warning, compilation works just
fine. But obviously nginx likes to compile with strict rules. Inside
objs/Makefile:

CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter
-Wunused-function -Wunused-variable -Wunused-value -Werror

So my questions are:

  • Is this the module’s fault?

  • Different gcc versions works differently? (I’m a noob in C)

  • Is there a way to fix it without editing objs/Makefile? I prefer to
    keep nginx source code as-is. And I’m ok to change the source code of
    the module because it looks abandoned anyway.

Posted at Nginx Forum: