I’m looking at:

https://git.openwrt.org/?p=project/firewall3.git;a=commitdiff;h=c03e20d7f594058ff223f30cf34de1b5e8210b8d;hp=b59934331c4b9271ceb5e30b793a552618299d39

and wondering, why not just do:

    v4->s_addr = htonl(~(UINT_MAX >> bits));

For instance, with bits == 14, we get:

UINT_MAX >> 14 == 0x0003ffff

~0x0003ffff == 0xfffc0000

Checking the case for bits == 0, we get:

UINT_MAX >> 0 == 0xffffffff

~0xffffffff == 0x00000000

And for bits == 32, we get:

UINT_MAX >> 32 == 0x00000000

~0x00000000 == 0xffffffff


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to