media: don't do a 31 bit shift on a signed int
On 32-bits archs, a signed integer has 31 bits plus on extra bit for signal. Due to that, touching the 32th bit with something like: int bar = 1 << 31; has an undefined behavior in C on 32 bit architectures, as it touches the signal bit. This is warned by cppcheck. Instead, force the numbers to be unsigned, in order to solve this issue. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
@@ -84,7 +84,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
|
||||
data = ir_extract_bits(gpio, ir->mask_keycode);
|
||||
|
||||
/* Check if it is keyup */
|
||||
keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0;
|
||||
keyup = (gpio & ir->mask_keyup) ? 1UL << 31 : 0;
|
||||
|
||||
if ((ir->last_gpio & 0x7f) != data) {
|
||||
dprintk("gpio=0x%x code=%d | %s\n",
|
||||
@@ -95,7 +95,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
|
||||
if (keyup)
|
||||
rc_keyup(ir->dev);
|
||||
} else {
|
||||
if ((ir->last_gpio & 1 << 31) == keyup)
|
||||
if ((ir->last_gpio & 1UL << 31) == keyup)
|
||||
return;
|
||||
|
||||
dprintk("(cnt) gpio=0x%x code=%d | %s\n",
|
||||
|
@@ -78,7 +78,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < 32; i++) {
|
||||
if ((1 << i) & set)
|
||||
if (BIT(i) & set)
|
||||
return 1 << i;
|
||||
}
|
||||
return 0;
|
||||
|
@@ -910,7 +910,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
|
||||
|
||||
/* check which i2c devices are actually found */
|
||||
for (i = 0; i < 32; i++) {
|
||||
u32 device = 1 << i;
|
||||
u32 device = BIT(i);
|
||||
|
||||
if (!(device & hw))
|
||||
continue;
|
||||
|
@@ -73,8 +73,8 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < 32; i++) {
|
||||
if ((1 << i) & set)
|
||||
return 1 << i;
|
||||
if (BIT(i) & set)
|
||||
return BIT(i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -39,13 +39,13 @@ static void solo_gpio_mode(struct solo_dev *solo_dev,
|
||||
ret = solo_reg_read(solo_dev, SOLO_GPIO_CONFIG_1);
|
||||
|
||||
for (port = 0; port < 16; port++) {
|
||||
if (!((1 << (port + 16)) & port_mask))
|
||||
if (!((1UL << (port + 16)) & port_mask))
|
||||
continue;
|
||||
|
||||
if (!mode)
|
||||
ret &= ~(1 << port);
|
||||
ret &= ~(1UL << port);
|
||||
else
|
||||
ret |= 1 << port;
|
||||
ret |= 1UL << port;
|
||||
}
|
||||
|
||||
/* Enable GPIO[31:16] */
|
||||
|
Reference in New Issue
Block a user