All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
@ 2019-03-12 20:20 ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-12 20:20 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, linux-kernel

Add gcc attribute unused for `rc` variable.

Fix warnings treated as errors with W=1:

  arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 arch/powerpc/lib/sstep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 3d33fb509ef4..32d092f62ae0 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
 int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		  unsigned int instr)
 {
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
@ 2019-03-12 20:20 ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-12 20:20 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Paul Mackerras, linuxppc-dev, linux-kernel

Add gcc attribute unused for `rc` variable.

Fix warnings treated as errors with W=1:

  arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 arch/powerpc/lib/sstep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 3d33fb509ef4..32d092f62ae0 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
 int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		  unsigned int instr)
 {
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
  2019-03-12 20:20 ` Mathieu Malaterre
@ 2019-03-12 20:56   ` Christophe Leroy
  -1 siblings, 0 replies; 18+ messages in thread
From: Christophe Leroy @ 2019-03-12 20:56 UTC (permalink / raw)
  To: Mathieu Malaterre, Michael Ellerman
  Cc: Paul Mackerras, linuxppc-dev, linux-kernel



Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
> Add gcc attribute unused for `rc` variable.
> 
> Fix warnings treated as errors with W=1:
> 
>    arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
>   arch/powerpc/lib/sstep.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..32d092f62ae0 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>   int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>   		  unsigned int instr)
>   {
> -	unsigned int opcode, ra, rb, rc, rd, spr, u;
> +	unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;

I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64

Christophe

>   	unsigned long int imm;
>   	unsigned long int val, val2;
>   	unsigned int mb, me, sh;
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
@ 2019-03-12 20:56   ` Christophe Leroy
  0 siblings, 0 replies; 18+ messages in thread
From: Christophe Leroy @ 2019-03-12 20:56 UTC (permalink / raw)
  To: Mathieu Malaterre, Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, linux-kernel



Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
> Add gcc attribute unused for `rc` variable.
> 
> Fix warnings treated as errors with W=1:
> 
>    arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
>   arch/powerpc/lib/sstep.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..32d092f62ae0 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>   int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>   		  unsigned int instr)
>   {
> -	unsigned int opcode, ra, rb, rc, rd, spr, u;
> +	unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;

I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64

Christophe

>   	unsigned long int imm;
>   	unsigned long int val, val2;
>   	unsigned int mb, me, sh;
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
  2019-03-12 20:56   ` Christophe Leroy
@ 2019-03-12 21:12     ` Mathieu Malaterre
  -1 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-12 21:12 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Michael Ellerman, Paul Mackerras, linuxppc-dev, LKML

On Tue, Mar 12, 2019 at 9:56 PM Christophe Leroy
<christophe.leroy@c-s.fr> wrote:
>
>
>
> Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
> > Add gcc attribute unused for `rc` variable.
> >
> > Fix warnings treated as errors with W=1:
> >
> >    arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> >
> > Signed-off-by: Mathieu Malaterre <malat@debian.org>
> > ---
> >   arch/powerpc/lib/sstep.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> > index 3d33fb509ef4..32d092f62ae0 100644
> > --- a/arch/powerpc/lib/sstep.c
> > +++ b/arch/powerpc/lib/sstep.c
> > @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
> >   int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
> >                 unsigned int instr)
> >   {
> > -     unsigned int opcode, ra, rb, rc, rd, spr, u;
> > +     unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
>
> I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64

Hum odd, I would have bet you would have suggested me to use
IS_ENABLED with some crazy scheme (I was not able to mix it with the
switch case nicely).

Anyway I'll try your suggestion and post a v2.

> Christophe
>
> >       unsigned long int imm;
> >       unsigned long int val, val2;
> >       unsigned int mb, me, sh;
> >

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
@ 2019-03-12 21:12     ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-12 21:12 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Paul Mackerras, linuxppc-dev, LKML

On Tue, Mar 12, 2019 at 9:56 PM Christophe Leroy
<christophe.leroy@c-s.fr> wrote:
>
>
>
> Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
> > Add gcc attribute unused for `rc` variable.
> >
> > Fix warnings treated as errors with W=1:
> >
> >    arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> >
> > Signed-off-by: Mathieu Malaterre <malat@debian.org>
> > ---
> >   arch/powerpc/lib/sstep.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> > index 3d33fb509ef4..32d092f62ae0 100644
> > --- a/arch/powerpc/lib/sstep.c
> > +++ b/arch/powerpc/lib/sstep.c
> > @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
> >   int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
> >                 unsigned int instr)
> >   {
> > -     unsigned int opcode, ra, rb, rc, rd, spr, u;
> > +     unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
>
> I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64

Hum odd, I would have bet you would have suggested me to use
IS_ENABLED with some crazy scheme (I was not able to mix it with the
switch case nicely).

Anyway I'll try your suggestion and post a v2.

> Christophe
>
> >       unsigned long int imm;
> >       unsigned long int val, val2;
> >       unsigned int mb, me, sh;
> >

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
  2019-03-12 20:20 ` Mathieu Malaterre
@ 2019-03-12 21:23   ` Mathieu Malaterre
  -1 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-12 21:23 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Christophe Leroy, Benjamin Herrenschmidt,
	Paul Mackerras, linuxppc-dev, linux-kernel

Fix warnings treated as errors with W=1:

  arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword

 arch/powerpc/lib/sstep.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 3d33fb509ef4..9996dc7a0b46 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,10 @@ static nokprobe_inline int trap_compare(long v1, long v2)
 int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		  unsigned int instr)
 {
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb, rd, spr, u;
+#ifdef CONFIG_PPC64
+	unsigned int rc;
+#endif
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
@@ -1292,7 +1295,9 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (instr >> 21) & 0x1f;
 	ra = (instr >> 16) & 0x1f;
 	rb = (instr >> 11) & 0x1f;
+#ifdef CONFIG_PPC64
 	rc = (instr >> 6) & 0x1f;
+#endif
 
 	switch (opcode) {
 #ifdef __powerpc64__
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
@ 2019-03-12 21:23   ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-12 21:23 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, linux-kernel, Paul Mackerras, linuxppc-dev

Fix warnings treated as errors with W=1:

  arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword

 arch/powerpc/lib/sstep.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 3d33fb509ef4..9996dc7a0b46 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,10 @@ static nokprobe_inline int trap_compare(long v1, long v2)
 int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		  unsigned int instr)
 {
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb, rd, spr, u;
+#ifdef CONFIG_PPC64
+	unsigned int rc;
+#endif
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
@@ -1292,7 +1295,9 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (instr >> 21) & 0x1f;
 	ra = (instr >> 16) & 0x1f;
 	rb = (instr >> 11) & 0x1f;
+#ifdef CONFIG_PPC64
 	rc = (instr >> 6) & 0x1f;
+#endif
 
 	switch (opcode) {
 #ifdef __powerpc64__
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
  2019-03-12 21:12     ` Mathieu Malaterre
@ 2019-03-12 21:25       ` Christophe Leroy
  -1 siblings, 0 replies; 18+ messages in thread
From: Christophe Leroy @ 2019-03-12 21:25 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: Michael Ellerman, Paul Mackerras, linuxppc-dev, LKML



Le 12/03/2019 à 22:12, Mathieu Malaterre a écrit :
> On Tue, Mar 12, 2019 at 9:56 PM Christophe Leroy
> <christophe.leroy@c-s.fr> wrote:
>>
>>
>>
>> Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
>>> Add gcc attribute unused for `rc` variable.
>>>
>>> Fix warnings treated as errors with W=1:
>>>
>>>     arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
>>>
>>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>>> ---
>>>    arch/powerpc/lib/sstep.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
>>> index 3d33fb509ef4..32d092f62ae0 100644
>>> --- a/arch/powerpc/lib/sstep.c
>>> +++ b/arch/powerpc/lib/sstep.c
>>> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>>>    int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>>>                  unsigned int instr)
>>>    {
>>> -     unsigned int opcode, ra, rb, rc, rd, spr, u;
>>> +     unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
>>
>> I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64
> 
> Hum odd, I would have bet you would have suggested me to use
> IS_ENABLED with some crazy scheme (I was not able to mix it with the
> switch case nicely).

Well I guess yes, you could also get rid of the #ifdef __powerpc64__ and 
instead add the following just after the 'case 4:'

if (!IS_ENABLED(CONFIG_64))
	break;

That's less uggly than adding two #ifdef/#endif

Christophe

> 
> Anyway I'll try your suggestion and post a v2.
> 
>> Christophe
>>
>>>        unsigned long int imm;
>>>        unsigned long int val, val2;
>>>        unsigned int mb, me, sh;
>>>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
@ 2019-03-12 21:25       ` Christophe Leroy
  0 siblings, 0 replies; 18+ messages in thread
From: Christophe Leroy @ 2019-03-12 21:25 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: Paul Mackerras, linuxppc-dev, LKML



Le 12/03/2019 à 22:12, Mathieu Malaterre a écrit :
> On Tue, Mar 12, 2019 at 9:56 PM Christophe Leroy
> <christophe.leroy@c-s.fr> wrote:
>>
>>
>>
>> Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
>>> Add gcc attribute unused for `rc` variable.
>>>
>>> Fix warnings treated as errors with W=1:
>>>
>>>     arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
>>>
>>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>>> ---
>>>    arch/powerpc/lib/sstep.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
>>> index 3d33fb509ef4..32d092f62ae0 100644
>>> --- a/arch/powerpc/lib/sstep.c
>>> +++ b/arch/powerpc/lib/sstep.c
>>> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>>>    int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>>>                  unsigned int instr)
>>>    {
>>> -     unsigned int opcode, ra, rb, rc, rd, spr, u;
>>> +     unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
>>
>> I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64
> 
> Hum odd, I would have bet you would have suggested me to use
> IS_ENABLED with some crazy scheme (I was not able to mix it with the
> switch case nicely).

Well I guess yes, you could also get rid of the #ifdef __powerpc64__ and 
instead add the following just after the 'case 4:'

if (!IS_ENABLED(CONFIG_64))
	break;

That's less uggly than adding two #ifdef/#endif

Christophe

> 
> Anyway I'll try your suggestion and post a v2.
> 
>> Christophe
>>
>>>        unsigned long int imm;
>>>        unsigned long int val, val2;
>>>        unsigned int mb, me, sh;
>>>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
  2019-03-12 21:25       ` Christophe Leroy
@ 2019-03-13 20:12         ` Mathieu Malaterre
  -1 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-13 20:12 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Michael Ellerman, Paul Mackerras, linuxppc-dev, LKML

On Tue, Mar 12, 2019 at 10:26 PM Christophe Leroy
<christophe.leroy@c-s.fr> wrote:
>
>
>
> Le 12/03/2019 à 22:12, Mathieu Malaterre a écrit :
> > On Tue, Mar 12, 2019 at 9:56 PM Christophe Leroy
> > <christophe.leroy@c-s.fr> wrote:
> >>
> >>
> >>
> >> Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
> >>> Add gcc attribute unused for `rc` variable.
> >>>
> >>> Fix warnings treated as errors with W=1:
> >>>
> >>>     arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> >>>
> >>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> >>> ---
> >>>    arch/powerpc/lib/sstep.c | 2 +-
> >>>    1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> >>> index 3d33fb509ef4..32d092f62ae0 100644
> >>> --- a/arch/powerpc/lib/sstep.c
> >>> +++ b/arch/powerpc/lib/sstep.c
> >>> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
> >>>    int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
> >>>                  unsigned int instr)
> >>>    {
> >>> -     unsigned int opcode, ra, rb, rc, rd, spr, u;
> >>> +     unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
> >>
> >> I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64
> >
> > Hum odd, I would have bet you would have suggested me to use
> > IS_ENABLED with some crazy scheme (I was not able to mix it with the
> > switch case nicely).
>
> Well I guess yes, you could also get rid of the #ifdef __powerpc64__ and
> instead add the following just after the 'case 4:'
>
> if (!IS_ENABLED(CONFIG_64))
>         break;
>
> That's less uggly than adding two #ifdef/#endif

So you mean changing:

#ifdef __powerpc64__
  case 4:
    if (!cpu_has_feature(CPU_FTR_ARCH_300))
      return -1;

into:

  case 4:
    if (!IS_ENABLED(CONFIG_PPC64))
      break;
    if (!cpu_has_feature(CPU_FTR_ARCH_300))
      return -1;

So suddenly case label '4' becomes visible for ppc32, is that really
what you wanted ?

> Christophe
>
> >
> > Anyway I'll try your suggestion and post a v2.
> >
> >> Christophe
> >>
> >>>        unsigned long int imm;
> >>>        unsigned long int val, val2;
> >>>        unsigned int mb, me, sh;
> >>>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr'
@ 2019-03-13 20:12         ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-03-13 20:12 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Paul Mackerras, linuxppc-dev, LKML

On Tue, Mar 12, 2019 at 10:26 PM Christophe Leroy
<christophe.leroy@c-s.fr> wrote:
>
>
>
> Le 12/03/2019 à 22:12, Mathieu Malaterre a écrit :
> > On Tue, Mar 12, 2019 at 9:56 PM Christophe Leroy
> > <christophe.leroy@c-s.fr> wrote:
> >>
> >>
> >>
> >> Le 12/03/2019 à 21:20, Mathieu Malaterre a écrit :
> >>> Add gcc attribute unused for `rc` variable.
> >>>
> >>> Fix warnings treated as errors with W=1:
> >>>
> >>>     arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> >>>
> >>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> >>> ---
> >>>    arch/powerpc/lib/sstep.c | 2 +-
> >>>    1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> >>> index 3d33fb509ef4..32d092f62ae0 100644
> >>> --- a/arch/powerpc/lib/sstep.c
> >>> +++ b/arch/powerpc/lib/sstep.c
> >>> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
> >>>    int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
> >>>                  unsigned int instr)
> >>>    {
> >>> -     unsigned int opcode, ra, rb, rc, rd, spr, u;
> >>> +     unsigned int opcode, ra, rb, rc __maybe_unused, rd, spr, u;
> >>
> >> I think it would be better to enclose 'rc' inside a #ifdef CONFIG_PPC64
> >
> > Hum odd, I would have bet you would have suggested me to use
> > IS_ENABLED with some crazy scheme (I was not able to mix it with the
> > switch case nicely).
>
> Well I guess yes, you could also get rid of the #ifdef __powerpc64__ and
> instead add the following just after the 'case 4:'
>
> if (!IS_ENABLED(CONFIG_64))
>         break;
>
> That's less uggly than adding two #ifdef/#endif

So you mean changing:

#ifdef __powerpc64__
  case 4:
    if (!cpu_has_feature(CPU_FTR_ARCH_300))
      return -1;

into:

  case 4:
    if (!IS_ENABLED(CONFIG_PPC64))
      break;
    if (!cpu_has_feature(CPU_FTR_ARCH_300))
      return -1;

So suddenly case label '4' becomes visible for ppc32, is that really
what you wanted ?

> Christophe
>
> >
> > Anyway I'll try your suggestion and post a v2.
> >
> >> Christophe
> >>
> >>>        unsigned long int imm;
> >>>        unsigned long int val, val2;
> >>>        unsigned int mb, me, sh;
> >>>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
  2019-03-12 21:23   ` Mathieu Malaterre
@ 2019-05-23 11:49     ` Mathieu Malaterre
  -1 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-05-23 11:49 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, LKML

ping ?

On Tue, Mar 12, 2019 at 10:23 PM Mathieu Malaterre <malat@debian.org> wrote:
>
> Fix warnings treated as errors with W=1:
>
>   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword
>
>  arch/powerpc/lib/sstep.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..9996dc7a0b46 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,10 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                   unsigned int instr)
>  {
> -       unsigned int opcode, ra, rb, rc, rd, spr, u;
> +       unsigned int opcode, ra, rb, rd, spr, u;
> +#ifdef CONFIG_PPC64
> +       unsigned int rc;
> +#endif
>         unsigned long int imm;
>         unsigned long int val, val2;
>         unsigned int mb, me, sh;
> @@ -1292,7 +1295,9 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>         rd = (instr >> 21) & 0x1f;
>         ra = (instr >> 16) & 0x1f;
>         rb = (instr >> 11) & 0x1f;
> +#ifdef CONFIG_PPC64
>         rc = (instr >> 6) & 0x1f;
> +#endif
>
>         switch (opcode) {
>  #ifdef __powerpc64__
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
@ 2019-05-23 11:49     ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-05-23 11:49 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Paul Mackerras, linuxppc-dev, LKML

ping ?

On Tue, Mar 12, 2019 at 10:23 PM Mathieu Malaterre <malat@debian.org> wrote:
>
> Fix warnings treated as errors with W=1:
>
>   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword
>
>  arch/powerpc/lib/sstep.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..9996dc7a0b46 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,10 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                   unsigned int instr)
>  {
> -       unsigned int opcode, ra, rb, rc, rd, spr, u;
> +       unsigned int opcode, ra, rb, rd, spr, u;
> +#ifdef CONFIG_PPC64
> +       unsigned int rc;
> +#endif
>         unsigned long int imm;
>         unsigned long int val, val2;
>         unsigned int mb, me, sh;
> @@ -1292,7 +1295,9 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>         rd = (instr >> 21) & 0x1f;
>         ra = (instr >> 16) & 0x1f;
>         rb = (instr >> 11) & 0x1f;
> +#ifdef CONFIG_PPC64
>         rc = (instr >> 6) & 0x1f;
> +#endif
>
>         switch (opcode) {
>  #ifdef __powerpc64__
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
  2019-03-12 21:23   ` Mathieu Malaterre
@ 2019-05-28 11:40     ` Michael Ellerman
  -1 siblings, 0 replies; 18+ messages in thread
From: Michael Ellerman @ 2019-05-28 11:40 UTC (permalink / raw)
  To: Mathieu Malaterre
  Cc: Mathieu Malaterre, Christophe Leroy, Benjamin Herrenschmidt,
	Paul Mackerras, linuxppc-dev, linux-kernel

Mathieu Malaterre <malat@debian.org> writes:

> Fix warnings treated as errors with W=1:
>
>   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword

I'd rather avoid adding more ifdefs if we can.

I think this works?

cheers

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 3d33fb509ef4..600b036ddfda 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
 int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		  unsigned int instr)
 {
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
@@ -1292,7 +1292,6 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (instr >> 21) & 0x1f;
 	ra = (instr >> 16) & 0x1f;
 	rb = (instr >> 11) & 0x1f;
-	rc = (instr >> 6) & 0x1f;
 
 	switch (opcode) {
 #ifdef __powerpc64__
@@ -1307,10 +1306,14 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		return 1;
 
 #ifdef __powerpc64__
-	case 4:
+	case 4: {
+		unsigned int rc;
+
 		if (!cpu_has_feature(CPU_FTR_ARCH_300))
 			return -1;
 
+		rc = (instr >> 6) & 0x1f;
+
 		switch (instr & 0x3f) {
 		case 48:	/* maddhd */
 			asm volatile(PPC_MADDHD(%0, %1, %2, %3) :
@@ -1336,6 +1339,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		 * primary opcode which do not have emulation support yet.
 		 */
 		return -1;
+	}
 #endif
 
 	case 7:		/* mulli */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
@ 2019-05-28 11:40     ` Michael Ellerman
  0 siblings, 0 replies; 18+ messages in thread
From: Michael Ellerman @ 2019-05-28 11:40 UTC (permalink / raw)
  To: Mathieu Malaterre
  Cc: Mathieu Malaterre, linux-kernel, Paul Mackerras, linuxppc-dev

Mathieu Malaterre <malat@debian.org> writes:

> Fix warnings treated as errors with W=1:
>
>   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword

I'd rather avoid adding more ifdefs if we can.

I think this works?

cheers

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 3d33fb509ef4..600b036ddfda 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
 int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		  unsigned int instr)
 {
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
@@ -1292,7 +1292,6 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (instr >> 21) & 0x1f;
 	ra = (instr >> 16) & 0x1f;
 	rb = (instr >> 11) & 0x1f;
-	rc = (instr >> 6) & 0x1f;
 
 	switch (opcode) {
 #ifdef __powerpc64__
@@ -1307,10 +1306,14 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		return 1;
 
 #ifdef __powerpc64__
-	case 4:
+	case 4: {
+		unsigned int rc;
+
 		if (!cpu_has_feature(CPU_FTR_ARCH_300))
 			return -1;
 
+		rc = (instr >> 6) & 0x1f;
+
 		switch (instr & 0x3f) {
 		case 48:	/* maddhd */
 			asm volatile(PPC_MADDHD(%0, %1, %2, %3) :
@@ -1336,6 +1339,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 		 * primary opcode which do not have emulation support yet.
 		 */
 		return -1;
+	}
 #endif
 
 	case 7:		/* mulli */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
  2019-05-28 11:40     ` Michael Ellerman
@ 2019-05-28 15:52       ` Mathieu Malaterre
  -1 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-05-28 15:52 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, LKML

On Tue, May 28, 2019 at 1:40 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Mathieu Malaterre <malat@debian.org> writes:
>
> > Fix warnings treated as errors with W=1:
> >
> >   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> >
> > Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> > Signed-off-by: Mathieu Malaterre <malat@debian.org>
> > ---
> > v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword
>
> I'd rather avoid adding more ifdefs if we can.
>
> I think this works?

It does ! ;)

Reviewed-by: Mathieu Malaterre <malat@debian.org>

> cheers
>
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..600b036ddfda 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                   unsigned int instr)
>  {
> -       unsigned int opcode, ra, rb, rc, rd, spr, u;
> +       unsigned int opcode, ra, rb, rd, spr, u;
>         unsigned long int imm;
>         unsigned long int val, val2;
>         unsigned int mb, me, sh;
> @@ -1292,7 +1292,6 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>         rd = (instr >> 21) & 0x1f;
>         ra = (instr >> 16) & 0x1f;
>         rb = (instr >> 11) & 0x1f;
> -       rc = (instr >> 6) & 0x1f;
>
>         switch (opcode) {
>  #ifdef __powerpc64__
> @@ -1307,10 +1306,14 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                 return 1;
>
>  #ifdef __powerpc64__
> -       case 4:
> +       case 4: {
> +               unsigned int rc;
> +
>                 if (!cpu_has_feature(CPU_FTR_ARCH_300))
>                         return -1;
>
> +               rc = (instr >> 6) & 0x1f;
> +
>                 switch (instr & 0x3f) {
>                 case 48:        /* maddhd */
>                         asm volatile(PPC_MADDHD(%0, %1, %2, %3) :
> @@ -1336,6 +1339,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                  * primary opcode which do not have emulation support yet.
>                  */
>                 return -1;
> +       }
>  #endif
>
>         case 7:         /* mulli */

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels
@ 2019-05-28 15:52       ` Mathieu Malaterre
  0 siblings, 0 replies; 18+ messages in thread
From: Mathieu Malaterre @ 2019-05-28 15:52 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Paul Mackerras, linuxppc-dev, LKML

On Tue, May 28, 2019 at 1:40 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Mathieu Malaterre <malat@debian.org> writes:
>
> > Fix warnings treated as errors with W=1:
> >
> >   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used [-Werror=unused-but-set-variable]
> >
> > Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> > Signed-off-by: Mathieu Malaterre <malat@debian.org>
> > ---
> > v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword
>
> I'd rather avoid adding more ifdefs if we can.
>
> I think this works?

It does ! ;)

Reviewed-by: Mathieu Malaterre <malat@debian.org>

> cheers
>
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..600b036ddfda 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                   unsigned int instr)
>  {
> -       unsigned int opcode, ra, rb, rc, rd, spr, u;
> +       unsigned int opcode, ra, rb, rd, spr, u;
>         unsigned long int imm;
>         unsigned long int val, val2;
>         unsigned int mb, me, sh;
> @@ -1292,7 +1292,6 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>         rd = (instr >> 21) & 0x1f;
>         ra = (instr >> 16) & 0x1f;
>         rb = (instr >> 11) & 0x1f;
> -       rc = (instr >> 6) & 0x1f;
>
>         switch (opcode) {
>  #ifdef __powerpc64__
> @@ -1307,10 +1306,14 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                 return 1;
>
>  #ifdef __powerpc64__
> -       case 4:
> +       case 4: {
> +               unsigned int rc;
> +
>                 if (!cpu_has_feature(CPU_FTR_ARCH_300))
>                         return -1;
>
> +               rc = (instr >> 6) & 0x1f;
> +
>                 switch (instr & 0x3f) {
>                 case 48:        /* maddhd */
>                         asm volatile(PPC_MADDHD(%0, %1, %2, %3) :
> @@ -1336,6 +1339,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>                  * primary opcode which do not have emulation support yet.
>                  */
>                 return -1;
> +       }
>  #endif
>
>         case 7:         /* mulli */

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-05-28 15:54 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12 20:20 [PATCH] powerpc: sstep: Mark variable `rc` as unused in function 'analyse_instr' Mathieu Malaterre
2019-03-12 20:20 ` Mathieu Malaterre
2019-03-12 20:56 ` Christophe Leroy
2019-03-12 20:56   ` Christophe Leroy
2019-03-12 21:12   ` Mathieu Malaterre
2019-03-12 21:12     ` Mathieu Malaterre
2019-03-12 21:25     ` Christophe Leroy
2019-03-12 21:25       ` Christophe Leroy
2019-03-13 20:12       ` Mathieu Malaterre
2019-03-13 20:12         ` Mathieu Malaterre
2019-03-12 21:23 ` [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels Mathieu Malaterre
2019-03-12 21:23   ` Mathieu Malaterre
2019-05-23 11:49   ` Mathieu Malaterre
2019-05-23 11:49     ` Mathieu Malaterre
2019-05-28 11:40   ` Michael Ellerman
2019-05-28 11:40     ` Michael Ellerman
2019-05-28 15:52     ` Mathieu Malaterre
2019-05-28 15:52       ` Mathieu Malaterre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.