[PATCH] cxl: Fix ambiguous else warnings

Thomas Huth thuth at redhat.com
Fri Jul 31 19:28:24 AEST 2015


On 31/07/15 08:35, Daniel Axtens wrote:
> Every time I build cxl I see the following warnings:
> 
> /scratch/dja/linux-capi/drivers/misc/cxl/pci.c: In function ‘sanitise_afu_regs’:
> /scratch/dja/linux-capi/drivers/misc/cxl/pci.c:712:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
>    if (reg & CXL_PSL_DSISR_TRANS)
>       ^
> /scratch/dja/linux-capi/drivers/misc/cxl/irq.c: In function ‘fail_psl_irq’:
> /scratch/dja/linux-capi/drivers/misc/cxl/irq.c:184:5: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
>   if (irq_info->dsisr & CXL_PSL_DSISR_TRANS)
>      ^
> 
> They're annoying. Fix them by inserting the braces.
> 
> Signed-off-by: Daniel Axtens <dja at axtens.net>
> ---
>  drivers/misc/cxl/irq.c | 5 +++--
>  drivers/misc/cxl/pci.c | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
> index 121ec48f3ab4..c11e583a15a9 100644
> --- a/drivers/misc/cxl/irq.c
> +++ b/drivers/misc/cxl/irq.c
> @@ -181,10 +181,11 @@ static irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info)
>  
>  static irqreturn_t fail_psl_irq(struct cxl_afu *afu, struct cxl_irq_info *irq_info)
>  {
> -	if (irq_info->dsisr & CXL_PSL_DSISR_TRANS)
> +	if (irq_info->dsisr & CXL_PSL_DSISR_TRANS) {
>  		cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_AE);
> -	else
> +	} else {
>  		cxl_p2n_write(afu, CXL_PSL_TFC_An, CXL_PSL_TFC_An_A);
> +	}
>  
>  	return IRQ_HANDLED;
>  }

Why does your GCC complain here at all? The code doesn't look ambiguous
to me... Which version of GCC are you using?
I just did a quick test compile here, and these warnings do not occur
for me.

 Thomas



More information about the Linuxppc-dev mailing list