mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user