Commit 95c52069 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

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: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent cce8ccca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -431,7 +431,7 @@ static u32 cx24123_int_log2(u32 a, u32 b)
	u32 div = a / b;
	if (a % b >= b / 2)
		++div;
	if (div < (1 << 31)) {
	if (div < (1UL << 31)) {
		for (exp = 1; div > exp; nearest++)
			exp += exp;
	}
+2 −2
Original line number Diff line number Diff line
@@ -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",
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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;
}
Loading