RIOT-OS / RIOT

RIOT - The friendly OS for IoT
https://riot-os.org
GNU Lesser General Public License v2.1
4.97k stars 1.99k forks source link

Is there a risk associated with the bitarithm_lsb function #21049

Closed muaxiaohei closed 1 week ago

muaxiaohei commented 1 week ago

Description

In my testing, v might be 0 which will cause a mcu stall.

    unsigned r = 0;
    printf("v: %d\n", v);
    while ((v & 0x01) == 0) {
        v >>= 1;
        r++;
    }

    return r;

Steps to reproduce the issue

Expected results

Actual results

Versions

muaxiaohei commented 1 week ago

I will add details later.

kaspar030 commented 1 week ago

Yes, as documented.