[nginx] svn commit: r4583 - trunk/src/core
ru at nginx.com
ru at nginx.com
Wed Apr 11 17:18:15 UTC 2012
Author: ru
Date: 2012-04-11 17:18:15 +0000 (Wed, 11 Apr 2012)
New Revision: 4583
URL: http://trac.nginx.org/nginx/changeset/4583/nginx
Log:
Improved readability of the code that produces bitmask from prefix.
In collaboration with Maxim Dounin.
Modified:
trunk/src/core/ngx_inet.c
Modified: trunk/src/core/ngx_inet.c
===================================================================
--- trunk/src/core/ngx_inet.c 2012-04-11 09:56:30 UTC (rev 4582)
+++ trunk/src/core/ngx_inet.c 2012-04-11 17:18:15 UTC (rev 4583)
@@ -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 */
More information about the nginx-devel
mailing list