Skip to content

Commit 8f426e2

Browse files
committed
Simplify a bitwise expression in gen_broadcast().
Since hostmask is a 32-bit unsigned int, "~0 & hostmask" stands for "0xFFFFFFFF & hostmask", which always equals hostmask. The tests for "ip broadcast" hold as expected.
1 parent a40bc5c commit 8f426e2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

gencode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8467,8 +8467,7 @@ gen_broadcast(compiler_state_t *cstate, int proto)
84678467
b0 = gen_linktype(cstate, ETHERTYPE_IP);
84688468
hostmask = ~cstate->netmask;
84698469
b1 = gen_mcmp(cstate, OR_LINKPL, 16, BPF_W, 0, hostmask);
8470-
b2 = gen_mcmp(cstate, OR_LINKPL, 16, BPF_W,
8471-
~0 & hostmask, hostmask);
8470+
b2 = gen_mcmp(cstate, OR_LINKPL, 16, BPF_W, hostmask, hostmask);
84728471
gen_or(b1, b2);
84738472
gen_and(b0, b2);
84748473
return b2;

0 commit comments

Comments
 (0)