Skip to content

Commit eb671b2

Browse files
authored
[bit-set] cast bitwise NOT in FlipBits to uint8_t (openthread#13164)
Explicitly cast the result of the bitwise NOT operator ~ to uint8_t in BitSetUtils::FlipBits to resolve a build error under AppleClang. In C++, using the bitwise NOT operator on a uint8_t value promotes it to an int. Assigning the promoted int back to uint8_t triggers an implicit conversion warning/error (-Wimplicit-int-conversion) under newer compiler versions, which fails the build when compiled with -Werror.
1 parent 3243bc3 commit eb671b2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/core/common/bit_set.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void BitSetUtils::FlipBits(uint8_t *aTargetMask, uint16_t aSize, uint16_t aNumBi
6767
{
6868
for (uint16_t i = 0; i < aSize; i++)
6969
{
70-
aTargetMask[i] = ~aTargetMask[i];
70+
aTargetMask[i] = static_cast<uint8_t>(~aTargetMask[i]);
7171
}
7272

7373
Tidy(aTargetMask, aSize, aNumBits);
@@ -106,7 +106,7 @@ void BitSetUtils::Subtract(uint8_t *aTargetMask, const uint8_t *aMask, uint16_t
106106
{
107107
for (uint16_t i = 0; i < aSize; i++)
108108
{
109-
aTargetMask[i] &= (~aMask[i]);
109+
aTargetMask[i] &= static_cast<uint8_t>(~aMask[i]);
110110
}
111111
}
112112

0 commit comments

Comments
 (0)