[PATCH] print format for nevents

Maxim Dounin mdounin at mdounin.ru
Wed Aug 6 17:19:59 UTC 2014


Hello!

On Wed, Aug 06, 2014 at 12:28:00PM -0400, crespin wrote:

> Maxim Dounin Wrote:
> -------------------------------------------------------
> > Hello!
> > 
> > On Wed, Aug 06, 2014 at 10:22:10AM -0400, crespin wrote:
> > 
> > > Hello,
> > > 
> > > nevents is an ngx_int_t, so the print format must be "%i".
> > 
> > Both signed and unsigned ngx_[u]int_t has the same size, so that's 
> > more about preferable representation of numbers, not about 
> > correctness of the code.
> 
> Thanks for the link.
> 
> The format %d is used in another call to nevents.
> To be consistent, should not use %ui ?
> 
> Regards,
> 
> yves 
> 
> static ngx_int_t
> ngx_poll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t
> flags)
> ...
>     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
>                    "poll ready %d of %d", ready, nevents);

Yes, %d here is certainly incorrect, as int and ngx_int_t sizes 
may differ.  I don't think there are any platforms with poll() 
where this may cause problems, but nevertheless it's worth fixing.  
Changing this to %ui should be ok.

Care to provide a patch?

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list