Re: [PATCH linux-next] arch/ia64/kernel/module.c: fix bugon.cocci warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 22 Aug 2021 18:51:10 -0700 CGEL <cgel.zte@xxxxxxxxx> wrote:

> From: Jing Yangyang <jing.yangyang@xxxxxxxxxx>
> 
> Use BUG_ON instead of a if condition followed by BUG.
> 
> Generated by: scripts/coccinelle/misc/bugon.cocci
> 
> ...
>
> --- a/arch/ia64/kernel/module.c
> +++ b/arch/ia64/kernel/module.c
> @@ -560,8 +560,7 @@ struct plt_entry {
>  	while (plt->bundle[0][0]) {
>  		if (plt_target(plt) == target_ip)
>  			goto found;
> -		if (++plt >= plt_end)
> -			BUG();
> +		BUG_ON(++plt >= plt_end);

There are concerns that there might be a config combination in which
BUG_ON() expands to a no-op.  It this situation, `plt' won't get
incremented and we have a bug.

Now, we have taken care to prevent this from happening, via the
implementations of BUG_ON().  But still, mistakes happen and out of an
abundance of caution people avoid statements of the form

	assert(expression-with-side-effects)





[Index of Archives]     [Linux Kernel]     [Sparc Linux]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux x86_64]     [Linux for Ham Radio]

  Powered by Linux