mirror of
https://github.com/nginx/nginx.git
synced 2025-01-07 06:33:00 -06:00
Improved readability of the code that produces bitmask from prefix.
In collaboration with Maxim Dounin.
This commit is contained in:
parent
62b937b333
commit
a5bb616af4
@ -420,7 +420,7 @@ ngx_ptocidr(ngx_str_t *text, ngx_cidr_t *cidr)
|
|||||||
s = (shift > 8) ? 8 : shift;
|
s = (shift > 8) ? 8 : shift;
|
||||||
shift -= s;
|
shift -= s;
|
||||||
|
|
||||||
mask[i] = (u_char) (0 - (1 << (8 - s)));
|
mask[i] = (u_char) (0xffu << (8 - s));
|
||||||
|
|
||||||
if (addr[i] != (addr[i] & mask[i])) {
|
if (addr[i] != (addr[i] & mask[i])) {
|
||||||
rc = NGX_DONE;
|
rc = NGX_DONE;
|
||||||
@ -437,7 +437,7 @@ ngx_ptocidr(ngx_str_t *text, ngx_cidr_t *cidr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shift) {
|
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 {
|
} else {
|
||||||
/* x86 compilers use a shl instruction that shifts by modulo 32 */
|
/* x86 compilers use a shl instruction that shifts by modulo 32 */
|
||||||
|
Loading…
Reference in New Issue
Block a user