Change nevents type in ngx_poll_module.c to ngx_uint_t

Hello,

In ngx_epoll_module.c, nevents is defined as ngx_uint_t and ev->index is
also a ngx_uint_t.
So I proposed to change nevents type.

I’m not sure about variable declaration:

  • ngx_int_t i, nready;
  • ngx_uint_t i;
  • ngx_int_t nready;
    ngx_uint_t found, level;

It’s perhaps better to group variable by type:

  • ngx_int_t i, nready;
  • ngx_int_t nready;
  • ngx_uint_t i, found, level;

regards,

yves

HG changeset patch

User Yves Crespin[email protected]

Date 1407416217 -7200

Node ID b71a279c696bcd18bd6b3c2845fe8e51d57ea1fd

Parent c51d0d718b2177daaf14895840beb528e332418b

change nevents type in ngx_poll_module.c to ngx_uint_t

diff -r c51d0d718b21 -r b71a279c696b src/event/modules/ngx_poll_module.c
— a/src/event/modules/ngx_poll_module.c Thu Aug 07 14:32:24 2014
+0200
+++ b/src/event/modules/ngx_poll_module.c Thu Aug 07 14:56:57 2014
+0200
@@ -22,7 +22,7 @@

static struct pollfd *event_list;
-static ngx_int_t nevents;
+static ngx_uint_t nevents;

static ngx_str_t poll_name = ngx_string(“poll”);
@@ -198,7 +198,7 @@
if (e == NULL || e->index == NGX_INVALID_INDEX) {
nevents–;

  •    if (ev->index < (ngx_uint_t) nevents) {
    
  •    if (ev->index < nevents) {
    
           ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                          "index: copy event %ui to %i", nevents,
    

ev->index);
@@ -212,11 +212,11 @@
“unexpected last event”);

         } else {
  •            if (c->read->index == (ngx_uint_t) nevents) {
    
  •            if (c->read->index == nevents) {
                   c->read->index = ev->index;
               }
    
  •            if (c->write->index == (ngx_uint_t) nevents) {
    
  •            if (c->write->index == nevents) {
                   c->write->index = ev->index;
               }
           }
    

@@ -240,7 +240,8 @@
{
int ready, revents;
ngx_err_t err;

  • ngx_int_t i, nready;
  • ngx_uint_t i;
  • ngx_int_t nready;
    ngx_uint_t found, level;
    ngx_event_t *ev, **queue;
    ngx_connection_t *c;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,252384,252384#msg-252384

Hello!

On Thu, Aug 07, 2014 at 09:16:42AM -0400, crespin wrote:

 ngx_uint_t          found, level;

It’s perhaps better to group variable by type:

  • ngx_int_t i, nready;
  • ngx_int_t nready;
  • ngx_uint_t i, found, level;

Yes, as per style used in nginx sources, variables are grouped by
type. Additionally, types are sorted from shortest to longest.

HG changeset patch

User Yves Crespin[email protected]

Date 1407416217 -7200

Node ID b71a279c696bcd18bd6b3c2845fe8e51d57ea1fd

Parent c51d0d718b2177daaf14895840beb528e332418b

change nevents type in ngx_poll_module.c to ngx_uint_t

Committed with various minor changes, thanks.


Maxim D.
http://nginx.org/