diff mbox series

[3/3,v2] sh: fix READ/WRITE redefinition warnings

Message ID 20210627220544.8757-4-rdunlap@infradead.org (mailing list archive)
State New, archived
Headers show
Series sh: fixes for various build and kconfig warnings | expand

Commit Message

Randy Dunlap June 27, 2021, 10:05 p.m. UTC
kernel.h defines READ and WRITE, so rename the SH math-emu macros
to MREAD and MWRITE.

Fixes these warnings:

../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
   54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
In file included from ../arch/sh/math-emu/math.c:10:
../include/linux/kernel.h:37: note: this is the location of the previous definition
   37 | #define WRITE   1
../arch/sh/math-emu/math.c:55: warning: "READ" redefined
   55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
In file included from ../arch/sh/math-emu/math.c:10:
../include/linux/kernel.h:36: note: this is the location of the previous definition
   36 | #define READ   0

Fixes: 4b565680d163 ("sh: math-emu support")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2: renumber patches, otherwise no change;

 arch/sh/math-emu/math.c |   44 +++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

Comments

Geert Uytterhoeven June 28, 2021, 8:46 a.m. UTC | #1
On Mon, Jun 28, 2021 at 12:05 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> kernel.h defines READ and WRITE, so rename the SH math-emu macros
> to MREAD and MWRITE.
>
> Fixes these warnings:
>
> ../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
>    54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> In file included from ../arch/sh/math-emu/math.c:10:
> ../include/linux/kernel.h:37: note: this is the location of the previous definition
>    37 | #define WRITE   1
> ../arch/sh/math-emu/math.c:55: warning: "READ" redefined
>    55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> In file included from ../arch/sh/math-emu/math.c:10:
> ../include/linux/kernel.h:36: note: this is the location of the previous definition
>    36 | #define READ   0
>
> Fixes: 4b565680d163 ("sh: math-emu support")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
John Paul Adrian Glaubitz June 30, 2021, 9:36 a.m. UTC | #2
On 6/28/21 12:05 AM, Randy Dunlap wrote:
> kernel.h defines READ and WRITE, so rename the SH math-emu macros
> to MREAD and MWRITE.
> 
> Fixes these warnings:
> 
> ../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
>    54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> In file included from ../arch/sh/math-emu/math.c:10:
> ../include/linux/kernel.h:37: note: this is the location of the previous definition
>    37 | #define WRITE   1
> ../arch/sh/math-emu/math.c:55: warning: "READ" redefined
>    55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> In file included from ../arch/sh/math-emu/math.c:10:
> ../include/linux/kernel.h:36: note: this is the location of the previous definition
>    36 | #define READ   0
> 
> Fixes: 4b565680d163 ("sh: math-emu support")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2: renumber patches, otherwise no change;
> 
>  arch/sh/math-emu/math.c |   44 +++++++++++++++++++-------------------
>  1 file changed, 22 insertions(+), 22 deletions(-)
> 
> --- linux-next-20210625.orig/arch/sh/math-emu/math.c
> +++ linux-next-20210625/arch/sh/math-emu/math.c
> @@ -51,8 +51,8 @@
>  #define Rn	(regs->regs[n])
>  #define Rm	(regs->regs[m])
>  
> -#define WRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> -#define READ(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> +#define MWRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> +#define MREAD(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>  
>  #define PACK_S(r,f)	FP_PACK_SP(&r,f)
>  #define UNPACK_S(f,r)	FP_UNPACK_SP(f,&r)
> @@ -157,11 +157,11 @@ fmov_idx_reg(struct sh_fpu_soft_struct *
>  {
>  	if (FPSCR_SZ) {
>  		FMOV_EXT(n);
> -		READ(FRn, Rm + R0 + 4);
> +		MREAD(FRn, Rm + R0 + 4);
>  		n++;
> -		READ(FRn, Rm + R0);
> +		MREAD(FRn, Rm + R0);
>  	} else {
> -		READ(FRn, Rm + R0);
> +		MREAD(FRn, Rm + R0);
>  	}
>  
>  	return 0;
> @@ -173,11 +173,11 @@ fmov_mem_reg(struct sh_fpu_soft_struct *
>  {
>  	if (FPSCR_SZ) {
>  		FMOV_EXT(n);
> -		READ(FRn, Rm + 4);
> +		MREAD(FRn, Rm + 4);
>  		n++;
> -		READ(FRn, Rm);
> +		MREAD(FRn, Rm);
>  	} else {
> -		READ(FRn, Rm);
> +		MREAD(FRn, Rm);
>  	}
>  
>  	return 0;
> @@ -189,12 +189,12 @@ fmov_inc_reg(struct sh_fpu_soft_struct *
>  {
>  	if (FPSCR_SZ) {
>  		FMOV_EXT(n);
> -		READ(FRn, Rm + 4);
> +		MREAD(FRn, Rm + 4);
>  		n++;
> -		READ(FRn, Rm);
> +		MREAD(FRn, Rm);
>  		Rm += 8;
>  	} else {
> -		READ(FRn, Rm);
> +		MREAD(FRn, Rm);
>  		Rm += 4;
>  	}
>  
> @@ -207,11 +207,11 @@ fmov_reg_idx(struct sh_fpu_soft_struct *
>  {
>  	if (FPSCR_SZ) {
>  		FMOV_EXT(m);
> -		WRITE(FRm, Rn + R0 + 4);
> +		MWRITE(FRm, Rn + R0 + 4);
>  		m++;
> -		WRITE(FRm, Rn + R0);
> +		MWRITE(FRm, Rn + R0);
>  	} else {
> -		WRITE(FRm, Rn + R0);
> +		MWRITE(FRm, Rn + R0);
>  	}
>  
>  	return 0;
> @@ -223,11 +223,11 @@ fmov_reg_mem(struct sh_fpu_soft_struct *
>  {
>  	if (FPSCR_SZ) {
>  		FMOV_EXT(m);
> -		WRITE(FRm, Rn + 4);
> +		MWRITE(FRm, Rn + 4);
>  		m++;
> -		WRITE(FRm, Rn);
> +		MWRITE(FRm, Rn);
>  	} else {
> -		WRITE(FRm, Rn);
> +		MWRITE(FRm, Rn);
>  	}
>  
>  	return 0;
> @@ -240,12 +240,12 @@ fmov_reg_dec(struct sh_fpu_soft_struct *
>  	if (FPSCR_SZ) {
>  		FMOV_EXT(m);
>  		Rn -= 8;
> -		WRITE(FRm, Rn + 4);
> +		MWRITE(FRm, Rn + 4);
>  		m++;
> -		WRITE(FRm, Rn);
> +		MWRITE(FRm, Rn);
>  	} else {
>  		Rn -= 4;
> -		WRITE(FRm, Rn);
> +		MWRITE(FRm, Rn);
>  	}
>  
>  	return 0;
> @@ -445,11 +445,11 @@ id_sys(struct sh_fpu_soft_struct *fregs,
>  	case 0x4052:
>  	case 0x4062:
>  		Rn -= 4;
> -		WRITE(*reg, Rn);
> +		MWRITE(*reg, Rn);
>  		break;
>  	case 0x4056:
>  	case 0x4066:
> -		READ(*reg, Rn);
> +		MREAD(*reg, Rn);
>  		Rn += 4;
>  		break;
>  	default:
> 

This one no longer applies to Linus' tree:

glaubitz@node54:/data/home/glaubitz/linux> git am ../sh-patches-2021/\[PATCH\ 3_3\ v2\]\ sh\:\ fix\ READ_WRITE\ redefinition\ warnings.eml
Applying: sh: fix READ/WRITE redefinition warnings
error: patch failed: arch/sh/math-emu/math.c:51
error: arch/sh/math-emu/math.c: patch does not apply
Patch failed at 0001 sh: fix READ/WRITE redefinition warnings
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
glaubitz@node54:/data/home/glaubitz/linux>
Geert Uytterhoeven June 30, 2021, 9:42 a.m. UTC | #3
Hi Adrian,

On Wed, Jun 30, 2021 at 11:36 AM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
> On 6/28/21 12:05 AM, Randy Dunlap wrote:
> > kernel.h defines READ and WRITE, so rename the SH math-emu macros
> > to MREAD and MWRITE.
> >
> > Fixes these warnings:
> >
> > ../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
> >    54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> > In file included from ../arch/sh/math-emu/math.c:10:
> > ../include/linux/kernel.h:37: note: this is the location of the previous definition
> >    37 | #define WRITE   1
> > ../arch/sh/math-emu/math.c:55: warning: "READ" redefined
> >    55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> > In file included from ../arch/sh/math-emu/math.c:10:
> > ../include/linux/kernel.h:36: note: this is the location of the previous definition
> >    36 | #define READ   0
> >
> > Fixes: 4b565680d163 ("sh: math-emu support")
> > Signed-off-by: Randy Dunlap <rdunlap@infradead.org>

> This one no longer applies to Linus' tree:

Worked fine for me.
Ah, Linus tree still doesn't have b1deeeb93933d390[1] ("sh: fix
trivial misannotations"), which has been lingering in sh/for-next
since the beginning or March.

[1] Note to Gmail: No, I don't want to correct this to "b1de b93933d390".

Gr{oetje,eeting}s,

                        Geert
Randy Dunlap June 30, 2021, 7:33 p.m. UTC | #4
On 6/30/21 2:36 AM, John Paul Adrian Glaubitz wrote:
> On 6/28/21 12:05 AM, Randy Dunlap wrote:
>> kernel.h defines READ and WRITE, so rename the SH math-emu macros
>> to MREAD and MWRITE.
>>
>> Fixes these warnings:
>>
>> ../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
>>    54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>> In file included from ../arch/sh/math-emu/math.c:10:
>> ../include/linux/kernel.h:37: note: this is the location of the previous definition
>>    37 | #define WRITE   1
>> ../arch/sh/math-emu/math.c:55: warning: "READ" redefined
>>    55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>> In file included from ../arch/sh/math-emu/math.c:10:
>> ../include/linux/kernel.h:36: note: this is the location of the previous definition
>>    36 | #define READ   0
>>
>> Fixes: 4b565680d163 ("sh: math-emu support")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
>> Cc: Rich Felker <dalias@libc.org>
>> Cc: linux-sh@vger.kernel.org
>> Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
>> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
>> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>> v2: renumber patches, otherwise no change;
>>
>>  arch/sh/math-emu/math.c |   44 +++++++++++++++++++-------------------
>>  1 file changed, 22 insertions(+), 22 deletions(-)
>>
>> --- linux-next-20210625.orig/arch/sh/math-emu/math.c
>> +++ linux-next-20210625/arch/sh/math-emu/math.c
>> @@ -51,8 +51,8 @@
>>  #define Rn	(regs->regs[n])
>>  #define Rm	(regs->regs[m])
>>  
>> -#define WRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>> -#define READ(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>> +#define MWRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>> +#define MREAD(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>  
>>  #define PACK_S(r,f)	FP_PACK_SP(&r,f)
>>  #define UNPACK_S(f,r)	FP_UNPACK_SP(f,&r)
>> @@ -157,11 +157,11 @@ fmov_idx_reg(struct sh_fpu_soft_struct *
>>  {
>>  	if (FPSCR_SZ) {
>>  		FMOV_EXT(n);
>> -		READ(FRn, Rm + R0 + 4);
>> +		MREAD(FRn, Rm + R0 + 4);
>>  		n++;
>> -		READ(FRn, Rm + R0);
>> +		MREAD(FRn, Rm + R0);
>>  	} else {
>> -		READ(FRn, Rm + R0);
>> +		MREAD(FRn, Rm + R0);
>>  	}
>>  
>>  	return 0;
>> @@ -173,11 +173,11 @@ fmov_mem_reg(struct sh_fpu_soft_struct *
>>  {
>>  	if (FPSCR_SZ) {
>>  		FMOV_EXT(n);
>> -		READ(FRn, Rm + 4);
>> +		MREAD(FRn, Rm + 4);
>>  		n++;
>> -		READ(FRn, Rm);
>> +		MREAD(FRn, Rm);
>>  	} else {
>> -		READ(FRn, Rm);
>> +		MREAD(FRn, Rm);
>>  	}
>>  
>>  	return 0;
>> @@ -189,12 +189,12 @@ fmov_inc_reg(struct sh_fpu_soft_struct *
>>  {
>>  	if (FPSCR_SZ) {
>>  		FMOV_EXT(n);
>> -		READ(FRn, Rm + 4);
>> +		MREAD(FRn, Rm + 4);
>>  		n++;
>> -		READ(FRn, Rm);
>> +		MREAD(FRn, Rm);
>>  		Rm += 8;
>>  	} else {
>> -		READ(FRn, Rm);
>> +		MREAD(FRn, Rm);
>>  		Rm += 4;
>>  	}
>>  
>> @@ -207,11 +207,11 @@ fmov_reg_idx(struct sh_fpu_soft_struct *
>>  {
>>  	if (FPSCR_SZ) {
>>  		FMOV_EXT(m);
>> -		WRITE(FRm, Rn + R0 + 4);
>> +		MWRITE(FRm, Rn + R0 + 4);
>>  		m++;
>> -		WRITE(FRm, Rn + R0);
>> +		MWRITE(FRm, Rn + R0);
>>  	} else {
>> -		WRITE(FRm, Rn + R0);
>> +		MWRITE(FRm, Rn + R0);
>>  	}
>>  
>>  	return 0;
>> @@ -223,11 +223,11 @@ fmov_reg_mem(struct sh_fpu_soft_struct *
>>  {
>>  	if (FPSCR_SZ) {
>>  		FMOV_EXT(m);
>> -		WRITE(FRm, Rn + 4);
>> +		MWRITE(FRm, Rn + 4);
>>  		m++;
>> -		WRITE(FRm, Rn);
>> +		MWRITE(FRm, Rn);
>>  	} else {
>> -		WRITE(FRm, Rn);
>> +		MWRITE(FRm, Rn);
>>  	}
>>  
>>  	return 0;
>> @@ -240,12 +240,12 @@ fmov_reg_dec(struct sh_fpu_soft_struct *
>>  	if (FPSCR_SZ) {
>>  		FMOV_EXT(m);
>>  		Rn -= 8;
>> -		WRITE(FRm, Rn + 4);
>> +		MWRITE(FRm, Rn + 4);
>>  		m++;
>> -		WRITE(FRm, Rn);
>> +		MWRITE(FRm, Rn);
>>  	} else {
>>  		Rn -= 4;
>> -		WRITE(FRm, Rn);
>> +		MWRITE(FRm, Rn);
>>  	}
>>  
>>  	return 0;
>> @@ -445,11 +445,11 @@ id_sys(struct sh_fpu_soft_struct *fregs,
>>  	case 0x4052:
>>  	case 0x4062:
>>  		Rn -= 4;
>> -		WRITE(*reg, Rn);
>> +		MWRITE(*reg, Rn);
>>  		break;
>>  	case 0x4056:
>>  	case 0x4066:
>> -		READ(*reg, Rn);
>> +		MREAD(*reg, Rn);
>>  		Rn += 4;
>>  		break;
>>  	default:
>>
> 
> This one no longer applies to Linus' tree:
> 
> glaubitz@node54:/data/home/glaubitz/linux> git am ../sh-patches-2021/\[PATCH\ 3_3\ v2\]\ sh\:\ fix\ READ_WRITE\ redefinition\ warnings.eml
> Applying: sh: fix READ/WRITE redefinition warnings
> error: patch failed: arch/sh/math-emu/math.c:51
> error: arch/sh/math-emu/math.c: patch does not apply
> Patch failed at 0001 sh: fix READ/WRITE redefinition warnings
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
> glaubitz@node54:/data/home/glaubitz/linux>

OK. Thanks for all of the testing.
John Paul Adrian Glaubitz June 30, 2021, 7:36 p.m. UTC | #5
On 6/30/21 9:33 PM, Randy Dunlap wrote:
> On 6/30/21 2:36 AM, John Paul Adrian Glaubitz wrote:
>> On 6/28/21 12:05 AM, Randy Dunlap wrote:
>>> kernel.h defines READ and WRITE, so rename the SH math-emu macros
>>> to MREAD and MWRITE.
>>>
>>> Fixes these warnings:
>>>
>>> ../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
>>>    54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>> In file included from ../arch/sh/math-emu/math.c:10:
>>> ../include/linux/kernel.h:37: note: this is the location of the previous definition
>>>    37 | #define WRITE   1
>>> ../arch/sh/math-emu/math.c:55: warning: "READ" redefined
>>>    55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>> In file included from ../arch/sh/math-emu/math.c:10:
>>> ../include/linux/kernel.h:36: note: this is the location of the previous definition
>>>    36 | #define READ   0
>>>
>>> Fixes: 4b565680d163 ("sh: math-emu support")
>>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>>> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
>>> Cc: Rich Felker <dalias@libc.org>
>>> Cc: linux-sh@vger.kernel.org
>>> Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
>>> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
>>> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
>>> ---
>>> v2: renumber patches, otherwise no change;
>>>
>>>  arch/sh/math-emu/math.c |   44 +++++++++++++++++++-------------------
>>>  1 file changed, 22 insertions(+), 22 deletions(-)
>>>
>>> --- linux-next-20210625.orig/arch/sh/math-emu/math.c
>>> +++ linux-next-20210625/arch/sh/math-emu/math.c
>>> @@ -51,8 +51,8 @@
>>>  #define Rn	(regs->regs[n])
>>>  #define Rm	(regs->regs[m])
>>>  
>>> -#define WRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>> -#define READ(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>> +#define MWRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>> +#define MREAD(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
>>>  
>>>  #define PACK_S(r,f)	FP_PACK_SP(&r,f)
>>>  #define UNPACK_S(f,r)	FP_UNPACK_SP(f,&r)
>>> @@ -157,11 +157,11 @@ fmov_idx_reg(struct sh_fpu_soft_struct *
>>>  {
>>>  	if (FPSCR_SZ) {
>>>  		FMOV_EXT(n);
>>> -		READ(FRn, Rm + R0 + 4);
>>> +		MREAD(FRn, Rm + R0 + 4);
>>>  		n++;
>>> -		READ(FRn, Rm + R0);
>>> +		MREAD(FRn, Rm + R0);
>>>  	} else {
>>> -		READ(FRn, Rm + R0);
>>> +		MREAD(FRn, Rm + R0);
>>>  	}
>>>  
>>>  	return 0;
>>> @@ -173,11 +173,11 @@ fmov_mem_reg(struct sh_fpu_soft_struct *
>>>  {
>>>  	if (FPSCR_SZ) {
>>>  		FMOV_EXT(n);
>>> -		READ(FRn, Rm + 4);
>>> +		MREAD(FRn, Rm + 4);
>>>  		n++;
>>> -		READ(FRn, Rm);
>>> +		MREAD(FRn, Rm);
>>>  	} else {
>>> -		READ(FRn, Rm);
>>> +		MREAD(FRn, Rm);
>>>  	}
>>>  
>>>  	return 0;
>>> @@ -189,12 +189,12 @@ fmov_inc_reg(struct sh_fpu_soft_struct *
>>>  {
>>>  	if (FPSCR_SZ) {
>>>  		FMOV_EXT(n);
>>> -		READ(FRn, Rm + 4);
>>> +		MREAD(FRn, Rm + 4);
>>>  		n++;
>>> -		READ(FRn, Rm);
>>> +		MREAD(FRn, Rm);
>>>  		Rm += 8;
>>>  	} else {
>>> -		READ(FRn, Rm);
>>> +		MREAD(FRn, Rm);
>>>  		Rm += 4;
>>>  	}
>>>  
>>> @@ -207,11 +207,11 @@ fmov_reg_idx(struct sh_fpu_soft_struct *
>>>  {
>>>  	if (FPSCR_SZ) {
>>>  		FMOV_EXT(m);
>>> -		WRITE(FRm, Rn + R0 + 4);
>>> +		MWRITE(FRm, Rn + R0 + 4);
>>>  		m++;
>>> -		WRITE(FRm, Rn + R0);
>>> +		MWRITE(FRm, Rn + R0);
>>>  	} else {
>>> -		WRITE(FRm, Rn + R0);
>>> +		MWRITE(FRm, Rn + R0);
>>>  	}
>>>  
>>>  	return 0;
>>> @@ -223,11 +223,11 @@ fmov_reg_mem(struct sh_fpu_soft_struct *
>>>  {
>>>  	if (FPSCR_SZ) {
>>>  		FMOV_EXT(m);
>>> -		WRITE(FRm, Rn + 4);
>>> +		MWRITE(FRm, Rn + 4);
>>>  		m++;
>>> -		WRITE(FRm, Rn);
>>> +		MWRITE(FRm, Rn);
>>>  	} else {
>>> -		WRITE(FRm, Rn);
>>> +		MWRITE(FRm, Rn);
>>>  	}
>>>  
>>>  	return 0;
>>> @@ -240,12 +240,12 @@ fmov_reg_dec(struct sh_fpu_soft_struct *
>>>  	if (FPSCR_SZ) {
>>>  		FMOV_EXT(m);
>>>  		Rn -= 8;
>>> -		WRITE(FRm, Rn + 4);
>>> +		MWRITE(FRm, Rn + 4);
>>>  		m++;
>>> -		WRITE(FRm, Rn);
>>> +		MWRITE(FRm, Rn);
>>>  	} else {
>>>  		Rn -= 4;
>>> -		WRITE(FRm, Rn);
>>> +		MWRITE(FRm, Rn);
>>>  	}
>>>  
>>>  	return 0;
>>> @@ -445,11 +445,11 @@ id_sys(struct sh_fpu_soft_struct *fregs,
>>>  	case 0x4052:
>>>  	case 0x4062:
>>>  		Rn -= 4;
>>> -		WRITE(*reg, Rn);
>>> +		MWRITE(*reg, Rn);
>>>  		break;
>>>  	case 0x4056:
>>>  	case 0x4066:
>>> -		READ(*reg, Rn);
>>> +		MREAD(*reg, Rn);
>>>  		Rn += 4;
>>>  		break;
>>>  	default:
>>>
>>
>> This one no longer applies to Linus' tree:
>>
>> glaubitz@node54:/data/home/glaubitz/linux> git am ../sh-patches-2021/\[PATCH\ 3_3\ v2\]\ sh\:\ fix\ READ_WRITE\ redefinition\ warnings.eml
>> Applying: sh: fix READ/WRITE redefinition warnings
>> error: patch failed: arch/sh/math-emu/math.c:51
>> error: arch/sh/math-emu/math.c: patch does not apply
>> Patch failed at 0001 sh: fix READ/WRITE redefinition warnings
>> hint: Use 'git am --show-current-patch=diff' to see the failed patch
>> When you have resolved this problem, run "git am --continue".
>> If you prefer to skip this patch, run "git am --skip" instead.
>> To restore the original branch and stop patching, run "git am --abort".
>> glaubitz@node54:/data/home/glaubitz/linux>
> 
> OK. Thanks for all of the testing.

I'll report back with the other patch applied that Geert mentioned from linux-next before this one.

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,
      |        ^~~~~~~~~~~~~~~~~
./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:34: 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,
      |        ^~~~~~~~~~~~~~~~~
./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:105:31: note: in expansion of macro '_INTC_ARRAY'
  105 |         _INTC_ARRAY(vectors), _INTC_ARRAY(groups),      \
      |                               ^~~~~~~~~~~
./include/linux/sh_intc.h:132:15: note: in expansion of macro 'INTC_HW_DESC'
  132 |         .hw = INTC_HW_DESC(vectors, groups, mask_regs,                  \
      |               ^~~~~~~~~~~~
arch/sh/kernel/cpu/sh4a/setup-sh7785.c:503:8: note: in expansion of macro 'DECLARE_INTC_DESC_ACK'
  503 | static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7785-irq0123",
      |        ^~~~~~~~~~~~~~~~~~~~~
./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:105:31: note: in expansion of macro '_INTC_ARRAY'
  105 |         _INTC_ARRAY(vectors), _INTC_ARRAY(groups),      \
      |                               ^~~~~~~~~~~
./include/linux/sh_intc.h:132:15: note: in expansion of macro 'INTC_HW_DESC'
  132 |         .hw = INTC_HW_DESC(vectors, groups, mask_regs,                  \
      |               ^~~~~~~~~~~~
arch/sh/kernel/cpu/sh4a/setup-sh7785.c:507:8: note: in expansion of macro 'DECLARE_INTC_DESC_ACK'
  507 | static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7785-irq4567",
      |        ^~~~~~~~~~~~~~~~~~~~~
./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:105:31: note: in expansion of macro '_INTC_ARRAY'
  105 |         _INTC_ARRAY(vectors), _INTC_ARRAY(groups),      \
      |                               ^~~~~~~~~~~
./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:535:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  535 | static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7785-irl0123", vectors_irl0123,
      |        ^~~~~~~~~~~~~~~~~
./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:106:33: note: in expansion of macro '_INTC_ARRAY'
  106 |         _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_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:535:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  535 | static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7785-irl0123", vectors_irl0123,
      |        ^~~~~~~~~~~~~~~~~
./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:535:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  535 | static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7785-irl0123", vectors_irl0123,
      |        ^~~~~~~~~~~~~~~~~
./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:34: 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:535:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  535 | static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7785-irl0123", vectors_irl0123,
      |        ^~~~~~~~~~~~~~~~~
./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:105:31: note: in expansion of macro '_INTC_ARRAY'
  105 |         _INTC_ARRAY(vectors), _INTC_ARRAY(groups),      \
      |                               ^~~~~~~~~~~
./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:538:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  538 | static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7785-irl4567", vectors_irl4567,
      |        ^~~~~~~~~~~~~~~~~
./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:106:33: note: in expansion of macro '_INTC_ARRAY'
  106 |         _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_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:538:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  538 | static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7785-irl4567", vectors_irl4567,
      |        ^~~~~~~~~~~~~~~~~
./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:538:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  538 | static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7785-irl4567", vectors_irl4567,
      |        ^~~~~~~~~~~~~~~~~
./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:34: 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:538:8: note: in expansion of macro 'DECLARE_INTC_DESC'
  538 | static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7785-irl4567", vectors_irl4567,
      |        ^~~~~~~~~~~~~~~~~
Geert Uytterhoeven July 1, 2021, 8:41 a.m. UTC | #6
) Hi Adrian,

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:
> >> On 6/28/21 12:05 AM, Randy Dunlap wrote:
> >>> kernel.h defines READ and WRITE, so rename the SH math-emu macros
> >>> to MREAD and MWRITE.
> >>>
> >>> Fixes these warnings:
> >>>
> >>> ../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
> >>>    54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> >>> In file included from ../arch/sh/math-emu/math.c:10:
> >>> ../include/linux/kernel.h:37: note: this is the location of the previous definition
> >>>    37 | #define WRITE   1
> >>> ../arch/sh/math-emu/math.c:55: warning: "READ" redefined
> >>>    55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
> >>> In file included from ../arch/sh/math-emu/math.c:10:
> >>> ../include/linux/kernel.h:36: note: this is the location of the previous definition
> >>>    36 | #define READ   0
> >>>
> >>> Fixes: 4b565680d163 ("sh: math-emu support")
> >>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> >>> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> >>> Cc: Rich Felker <dalias@libc.org>
> >>> Cc: linux-sh@vger.kernel.org
> >>> Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
> >>> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> >>> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> >>> ---
> >>> v2: renumber patches, otherwise no change;
> >>>
> >>>  arch/sh/math-emu/math.c |   44 +++++++++++++++++++-------------------
> >>>  1 file changed, 22 insertions(+), 22 deletions(-)

> >> This one no longer applies to Linus' tree:
> >>
> >> glaubitz@node54:/data/home/glaubitz/linux> git am ../sh-patches-2021/\[PATCH\ 3_3\ v2\]\ sh\:\ fix\ READ_WRITE\ redefinition\ warnings.eml
> >> Applying: sh: fix READ/WRITE redefinition warnings
> >> error: patch failed: arch/sh/math-emu/math.c:51
> >> error: arch/sh/math-emu/math.c: patch does not apply
> >> Patch failed at 0001 sh: fix READ/WRITE redefinition warnings
> >> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> >> When you have resolved this problem, run "git am --continue".
> >> If you prefer to skip this patch, run "git am --skip" instead.
> >> To restore the original branch and stop patching, run "git am --abort".
> >> glaubitz@node54:/data/home/glaubitz/linux>
> >
> > OK. Thanks for all of the testing.
>
> I'll report back with the other patch applied that Geert mentioned from linux-next before this one.

FTR, I booted all three successfully on qemu/rts7751r2d and on physical landisk.


> 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)

Gr{oetje,eeting}s,

                        Geert
Arnd Bergmann July 1, 2021, 11:57 a.m. UTC | #7
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
John Paul Adrian Glaubitz July 2, 2021, 9:25 a.m. UTC | #8
Hi Geert!

On 7/1/21 10:41 AM, Geert Uytterhoeven wrote:
>>> OK. Thanks for all of the testing.
>>
>> I'll report back with the other patch applied that Geert mentioned from linux-next before this one.
> 
> FTR, I booted all three successfully on qemu/rts7751r2d and on physical landisk.

Good to know, thanks.

>> 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)

Ah, thanks for the explanation.

Adrian
diff mbox series

Patch

--- linux-next-20210625.orig/arch/sh/math-emu/math.c
+++ linux-next-20210625/arch/sh/math-emu/math.c
@@ -51,8 +51,8 @@ 
 #define Rn	(regs->regs[n])
 #define Rm	(regs->regs[m])
 
-#define WRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
-#define READ(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
+#define MWRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
+#define MREAD(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
 
 #define PACK_S(r,f)	FP_PACK_SP(&r,f)
 #define UNPACK_S(f,r)	FP_UNPACK_SP(f,&r)
@@ -157,11 +157,11 @@  fmov_idx_reg(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(n);
-		READ(FRn, Rm + R0 + 4);
+		MREAD(FRn, Rm + R0 + 4);
 		n++;
-		READ(FRn, Rm + R0);
+		MREAD(FRn, Rm + R0);
 	} else {
-		READ(FRn, Rm + R0);
+		MREAD(FRn, Rm + R0);
 	}
 
 	return 0;
@@ -173,11 +173,11 @@  fmov_mem_reg(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(n);
-		READ(FRn, Rm + 4);
+		MREAD(FRn, Rm + 4);
 		n++;
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 	} else {
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 	}
 
 	return 0;
@@ -189,12 +189,12 @@  fmov_inc_reg(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(n);
-		READ(FRn, Rm + 4);
+		MREAD(FRn, Rm + 4);
 		n++;
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 		Rm += 8;
 	} else {
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 		Rm += 4;
 	}
 
@@ -207,11 +207,11 @@  fmov_reg_idx(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(m);
-		WRITE(FRm, Rn + R0 + 4);
+		MWRITE(FRm, Rn + R0 + 4);
 		m++;
-		WRITE(FRm, Rn + R0);
+		MWRITE(FRm, Rn + R0);
 	} else {
-		WRITE(FRm, Rn + R0);
+		MWRITE(FRm, Rn + R0);
 	}
 
 	return 0;
@@ -223,11 +223,11 @@  fmov_reg_mem(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(m);
-		WRITE(FRm, Rn + 4);
+		MWRITE(FRm, Rn + 4);
 		m++;
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	} else {
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	}
 
 	return 0;
@@ -240,12 +240,12 @@  fmov_reg_dec(struct sh_fpu_soft_struct *
 	if (FPSCR_SZ) {
 		FMOV_EXT(m);
 		Rn -= 8;
-		WRITE(FRm, Rn + 4);
+		MWRITE(FRm, Rn + 4);
 		m++;
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	} else {
 		Rn -= 4;
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	}
 
 	return 0;
@@ -445,11 +445,11 @@  id_sys(struct sh_fpu_soft_struct *fregs,
 	case 0x4052:
 	case 0x4062:
 		Rn -= 4;
-		WRITE(*reg, Rn);
+		MWRITE(*reg, Rn);
 		break;
 	case 0x4056:
 	case 0x4066:
-		READ(*reg, Rn);
+		MREAD(*reg, Rn);
 		Rn += 4;
 		break;
 	default: