diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-08-22 10:16:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-08-26 13:11:10 -0400 |
commit | 95c520690f5fafb2cda2ec17f8c76ab3422b0174 (patch) | |
tree | 0dec0f5683f21100b61b19a141512ebe0bac3aea /drivers/media/pci/ivtv | |
parent | cce8ccca80d8388982133192d0a6d9dc2e8ed712 (diff) |
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>
Diffstat (limited to 'drivers/media/pci/ivtv')
-rw-r--r-- | drivers/media/pci/ivtv/ivtv-driver.c | 2 | ||||
-rw-r--r-- | drivers/media/pci/ivtv/ivtv-ioctl.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c index dd727098daf4..3f3f40ea890b 100644 --- a/drivers/media/pci/ivtv/ivtv-driver.c +++ b/drivers/media/pci/ivtv/ivtv-driver.c | |||
@@ -910,7 +910,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
910 | 910 | ||
911 | /* check which i2c devices are actually found */ | 911 | /* check which i2c devices are actually found */ |
912 | for (i = 0; i < 32; i++) { | 912 | for (i = 0; i < 32; i++) { |
913 | u32 device = 1 << i; | 913 | u32 device = BIT(i); |
914 | 914 | ||
915 | if (!(device & hw)) | 915 | if (!(device & hw)) |
916 | continue; | 916 | continue; |
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 5595f6a274e7..137853944e46 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c | |||
@@ -73,8 +73,8 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal) | |||
73 | return 0; | 73 | return 0; |
74 | } | 74 | } |
75 | for (i = 0; i < 32; i++) { | 75 | for (i = 0; i < 32; i++) { |
76 | if ((1 << i) & set) | 76 | if (BIT(i) & set) |
77 | return 1 << i; | 77 | return BIT(i); |
78 | } | 78 | } |
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |