udev_device.c: fix integer overflow

Bitwise AND operation can produce value that may be larger than
test_bit() return value. Convert result to bool using `!!` to
avoid integer overflow.

Fixes: #33
This commit is contained in:
illiliti
2021-06-26 01:14:10 +03:00
parent bd7d1803e6
commit bf23c9e5ba

View File

@@ -389,7 +389,7 @@ static void make_bit(unsigned long *arr, int cnt, const char *str)
static int test_bit(unsigned long *arr, unsigned long bit)
{
return arr[BIT_WORD(bit)] & BIT_MASK(bit);
return !!(arr[BIT_WORD(bit)] & BIT_MASK(bit));
}
static void set_properties_from_evdev(struct udev_device *udev_device)