[PATCH] cxl: Fix ambiguous else warnings

Daniel Axtens dja at axtens.net
Mon Aug 3 10:36:47 AEST 2015


Hi Andreas,

On Fri, 2015-07-31 at 11:16 +0200, Andreas Schwab wrote:
> Daniel Axtens <dja at axtens.net> writes:
> 
> > 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)
> >      ^
> 
> Why are they ambigous?  Why doesn't cxl_p2n_write(afu, CXL_PSL_TFC_An,
> CXL_PSL_TFC_An_AE) expand to a proper statement?
> 
> #define cxl_p2n_write(afu, reg, val) \
> 	out_be64(_cxl_p2n_addr(afu, reg), val)
> 

I realised that I started seeing this when I was working on my EEH
patches, which change the definition to:

#define cxl_p2n_write(afu, reg, val) \
	if (cxl_adapter_link_ok(afu->adapter)) \
		out_be64(_cxl_p2n_addr(afu, reg), val)


I'll redo the patch to change the write functions to wrap the if
statement so they cease to be ambiguous. I'll also spin a patch to
enable -Werror so I catch this earlier next time.

Thanks for the feedback, it was very helpful in me figuring out the root
cause.

-- 
Regards,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 860 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20150803/eb93cb14/attachment.sig>


More information about the Linuxppc-dev mailing list