diff options
author | Ruslan Ermilov <ru@nginx.com> | 2012-04-11 17:18:15 +0000 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2012-04-11 17:18:15 +0000 |
commit | a5bb616af4339a3e0be2f22cb7e456cd649aa4ee (patch) | |
tree | 8f74d35f6ff173377ee60ec422084fe468698aef /src/core/ngx_inet.c | |
parent | 62b937b3331add2477d0f6f2d8474aa98fc1218d (diff) | |
download | nginx-a5bb616af4339a3e0be2f22cb7e456cd649aa4ee.tar.gz nginx-a5bb616af4339a3e0be2f22cb7e456cd649aa4ee.zip |
Improved readability of the code that produces bitmask from prefix.
In collaboration with Maxim Dounin.
Diffstat (limited to 'src/core/ngx_inet.c')
-rw-r--r-- | src/core/ngx_inet.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index a6ce9f395..4fccc17ed 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -420,7 +420,7 @@ ngx_ptocidr(ngx_str_t *text, ngx_cidr_t *cidr) s = (shift > 8) ? 8 : shift; shift -= s; - mask[i] = (u_char) (0 - (1 << (8 - s))); + mask[i] = (u_char) (0xffu << (8 - s)); if (addr[i] != (addr[i] & mask[i])) { rc = NGX_DONE; @@ -437,7 +437,7 @@ ngx_ptocidr(ngx_str_t *text, ngx_cidr_t *cidr) } if (shift) { - cidr->u.in.mask = htonl((ngx_uint_t) (0 - (1 << (32 - shift)))); + cidr->u.in.mask = htonl((uint32_t) (0xffffffffu << (32 - shift))); } else { /* x86 compilers use a shl instruction that shifts by modulo 32 */ |