Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1588541

Re: [PATCH] bcm2048: Fix checkpatch checks

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] bcm2048: Fix checkpatch checks
Date 2017-02-27 09:30 +0100
Message-ID <tfoQW-2Vd-9@gated-at.bofh.it> (permalink)
References <tc4lH-53f-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Feb 18, 2017 at 11:52:37AM +0800, Man Choy wrote:
> 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(-)
> 
> diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
> index 37bd439..d5ee279 100644
> --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
> +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
> @@ -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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] bcm2048: Fix checkpatch checks Man Choy <manchoyy@gmail.com> - 2017-02-18 05:00 +0100
  Re: [PATCH] bcm2048: Fix checkpatch checks Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-27 09:30 +0100
    Re: [PATCH] bcm2048: Fix checkpatch checks Man Choy <manchoyy@gmail.com> - 2017-02-28 02:20 +0100

csiph-web