Skip to contentSkip to conversation

bcm2048: Fix checkpatch checks

PATCH In review Man Choy 2 participants 3 messages Feb 18, 2017 – Feb 28, 2017

Subsystems (2)
lore
Share & tools
lore

Man Choy

author
#0 lore raw

PATCH 1/1 bcm2048: Fix checkpatch checks

Fix following checks:

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+ BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)

+       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
                     ^

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+ BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)

+       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
                     ^
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/bcm2048/radio-bcm2048.c +2 -2
index 37bd439..d5ee279 100644
@@ -1534,7 +1534,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
 	if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
 		return 0;
 
-	BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
+	WARN_ON((index + 2) >= BCM2048_MAX_RDS_RT);
 
 	if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
 		BCM2048_RDS_BLOCK_C) {
@@ -1557,7 +1557,7 @@ static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i,
 	if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
 		return;
 
-	BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
+	WARN_ON((index + 4) >= BCM2048_MAX_RDS_RT);
 
 	if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
 	    BCM2048_RDS_BLOCK_D)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 24 lines · Man Choy

Fix following checks:

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+ BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)

+       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
                     ^

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+ BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)

(quoted diff) +1 -1
+       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
                     ^
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/bcm2048/radio-bcm2048.c +0 -0
index 37bd439..d5ee279 100644

drivers/staging/media/bcm2048/radio-bcm2048.c static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i, · line 1537

Quoted 5 lines
drivers/staging/media/bcm2048/radio-bcm2048.c +1 -1
@@ -1534,7 +1534,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
 	if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
 		return 0;
 
-	BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
+	WARN_ON((index + 2) >= BCM2048_MAX_RDS_RT);

Ick, no to all of these! What happens if this is true, the code will crash, right? You have to properly recover from this, don't just throw the message out to userspace and then keep on going.

You can't just do a search/replace for this, otherwise it would have been done already :)

thanks,

greg k-h

author
#2 lore raw
Quoted 35 lines · Greg Kroah-Hartman
Quoted 24 lines · Man Choy

Fix following checks:

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+ BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)

+       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
                     ^

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+ BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)

(quoted diff) +1 -1
+       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
                     ^
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/bcm2048/radio-bcm2048.c +0 -0
index 37bd439..d5ee279 100644

drivers/staging/media/bcm2048/radio-bcm2048.c static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i, · line 1537

Quoted 5 lines
drivers/staging/media/bcm2048/radio-bcm2048.c +1 -1
@@ -1534,7 +1534,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
      if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
              return 0;
 
-     BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
+     WARN_ON((index + 2) >= BCM2048_MAX_RDS_RT);

Ick, no to all of these! What happens if this is true, the code will crash, right? You have to properly recover from this, don't just throw the message out to userspace and then keep on going.

Quoted 6 lines

You can't just do a search/replace for this, otherwise it would have been done already :)

thanks,

greg k-h

Okay, noted. Thanks.