lkml.org 
[lkml]   [2021]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/3 v2] sh: fix READ/WRITE redefinition warnings
On Thu, Jul 1, 2021 at 10:41 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, Jun 30, 2021 at 9:36 PM John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:
> > On 6/30/21 9:33 PM, Randy Dunlap wrote:
> > > On 6/30/21 2:36 AM, John Paul Adrian Glaubitz wrote:
>
> > FWIW, there are some warnings when building the SH-7785LCR configuration:
> >
> > In file included from ./arch/sh/include/asm/hw_irq.h:6,
> > from ./include/linux/irq.h:591,
> > from ./include/asm-generic/hardirq.h:17,
> > from ./arch/sh/include/asm/hardirq.h:9,
> > from ./include/linux/hardirq.h:11,
> > from ./include/linux/interrupt.h:11,
> > from ./include/linux/serial_core.h:13,
> > from ./include/linux/serial_sci.h:6,
> > from arch/sh/kernel/cpu/sh4a/setup-sh7785.c:10:
> > ./include/linux/sh_intc.h:100:63: warning: division 'sizeof (void *) / sizeof (void)' does not compute the number of array elements [-Wsizeof-pointer-div]
> > 100 | #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
> > | ^
> > ./include/linux/sh_intc.h:107:9: note: in expansion of macro '_INTC_ARRAY'
> > 107 | _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \
> > | ^~~~~~~~~~~
> > ./include/linux/sh_intc.h:124:15: note: in expansion of macro 'INTC_HW_DESC'
> > 124 | .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
> > | ^~~~~~~~~~~~
> > arch/sh/kernel/cpu/sh4a/setup-sh7785.c:478:8: note: in expansion of macro 'DECLARE_INTC_DESC'
> > 478 | static DECLARE_INTC_DESC(intc_desc, "sh7785", vectors, groups,
> > | ^~~~~~~~~~~~~~~~~
>
> A while ago, I had a look into fixing them, but it was non-trivial.
> The issue is that the macros are sometimes used with NULL pointer arrays.
> The __same_type() check in
>
> #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
>
> is supposed to catch that, but modern compilers seem to evaluate the
> non-taken branch, too, leading to the warning.
>
> Anyone with a suggestion? (CCing the multi-compiler guru)

I think I looked at this (or maybe a related sh driver) in the past
and also gave up.

The best idea I have would be to manually expand the DECLARE_INTC_DESC()
macros. It would be possible to add further variations of them for each
combination of NULL/non-NULL arguments, but IMHO they don't actually
add any readability over the expanded version in the first place.

Another option would be to change the definition from array/size to
zero-terminated
arrays and get rid of the sizeof hack.

Arnd

\
 
 \ /
  Last update: 2021-07-01 13:58    [W:1.645 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site