# HG changeset patch # User Ruslan Ermilov # Date 1334164695 0 # Node ID a8881886a5f769f8678417615ea5c2223f871f0b # Parent f84a98a03d0dd5b8d6cc3a1307a40041e588a1f0 Improved readability of the code that produces bitmask from prefix. In collaboration with Maxim Dounin. diff -r f84a98a03d0d -r a8881886a5f7 src/core/ngx_inet.c --- a/src/core/ngx_inet.c Wed Apr 11 09:56:30 2012 +0000 +++ b/src/core/ngx_inet.c Wed Apr 11 17:18:15 2012 +0000 @@ -420,7 +420,7 @@ 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 @@ } 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 */