matsumoto-r/ngx_mruby — pull request #16 by cubicdaiya (2013-01-05 17:30:04+00:00)
Title: comparison between signed and unsigned value

If Nginx.errlogger recives 1st args as negative number, ngx_log_error works incorrectly.
I think that Nginx.errlogger output error to log in this case.

The following is ngx_log_error implementation.

```c
void ngx_cdecl
ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...)
{
va_list args;

if (log->log_level >= level) {
va_start(args, fmt);
ngx_log_error_core(level, log, err, fmt, args);
va_end(args);
}
}
```

The problem occcurs in the following line.

```c
if (log->log_level >= level) {
```

It assumes that log->log_level and level are ngx_uint_t(uintptr_t).
But current ngx_mruby pass 1st arg as mrb_int to ngx_log_error.
If level is negative, level becomes max value of ngx_int_t.(because both values are treated unsigned value in operation between signed and unsgined value)

By the way, -Wsign-compare option warns like following.

```
gx_http_mruby_core.c: In function ‘ngx_mrb_errlogger’:
ngx_http_mruby_core.c:206:5: error: comparison between signed and unsigned integer expressions
```

As mruby does not treats unsigned type, I think this options is necessary.(In my environment, this options is default)