Avoid UB when bit shifting

The 0 literal is a signed integer; bitshifting its (negative) complement is
undefined behavior.

PiperOrigin-RevId: 480717288
This commit is contained in:
Nick Brown
2022-10-12 14:27:44 -07:00
committed by gVisor bot
parent 140384fa22
commit 49874d2cff
+1 -1
View File
@@ -284,7 +284,7 @@ TEST_P(IPUnboundSocketTest, SmallTOSOptionSize) {
EXPECT_EQ(get_sz, expect_sz);
// Account for partial copies by getsockopt, retrieve the lower
// bits specified by get_sz, while comparing against expect_tos.
EXPECT_EQ(get & ~(~0 << (get_sz * 8)), expect_tos);
EXPECT_EQ(get & ~(~static_cast<uint>(0) << (get_sz * 8)), expect_tos);
}
}