1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/rng: fix cppcheck error shiftTooManyBitsSigned

cpp check is reporting the following error

    error (shiftTooManyBitsSigned):
    Shifting signed 32-bit value by 31 bits is undefined behaviour

Fix by ensuring the `1` is an `uint32_t` before shifting.
This commit is contained in:
Gaëtan Harter 2019-02-12 18:33:24 +01:00 committed by cladmi
parent 643de0a857
commit 44d2b62a70
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -154,7 +154,7 @@ void test_distributions(uint32_t samples)
/* count bits */
for (int i = 0; i < 32; i++) {
if (value & (1 << i)) {
if (value & (UINT32_C(1) << i)) {
distributions[i]++;
}
}