Klaus Demo nginx / a5bb616
Improved readability of the code that produces bitmask from prefix. In collaboration with Maxim Dounin. Ruslan Ermilov 10 years ago
1 changed file(s) with 2 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
419419 s = (shift > 8) ? 8 : shift;
420420 shift -= s;
421421
422 mask[i] = (u_char) (0 - (1 << (8 - s)));
422 mask[i] = (u_char) (0xffu << (8 - s));
423423
424424 if (addr[i] != (addr[i] & mask[i])) {
425425 rc = NGX_DONE;
436436 }
437437
438438 if (shift) {
439 cidr->u.in.mask = htonl((ngx_uint_t) (0 - (1 << (32 - shift))));
439 cidr->u.in.mask = htonl((uint32_t) (0xffffffffu << (32 - shift)));
440440
441441 } else {
442442 /* x86 compilers use a shl instruction that shifts by modulo 32 */