* [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’
@ 2018-06-22 19:27 Mathieu Malaterre
2018-06-23 16:59 ` christophe leroy
0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Malaterre @ 2018-06-22 19:27 UTC (permalink / raw)
To: Michael Ellerman
Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
Balbir Singh, Nicholas Piggin, Vaibhav Jain, Breno Leitao,
Yisheng Xie, linuxppc-dev, linux-kernel
Move initialization of variables after data definitions. This silence
warnings treated as error with W=1:
arch/powerpc/xmon/xmon.c:3389:14: error: variable ‘name’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
arch/powerpc/xmon/xmon.c:3100:22: error: variable ‘tsk’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
arch/powerpc/xmon/xmon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 47166ad2a669..982848c784ff 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -3097,10 +3097,11 @@ static void show_pte(unsigned long addr)
static void show_tasks(void)
{
unsigned long tskv;
- struct task_struct *tsk = NULL;
+ struct task_struct *tsk;
printf(" task_struct ->thread.ksp PID PPID S P CMD\n");
+ tsk = NULL;
if (scanhex(&tskv))
tsk = (struct task_struct *)tskv;
@@ -3386,10 +3387,11 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
const char *after)
{
char *modname;
- const char *name = NULL;
+ const char *name;
unsigned long offset, size;
printf(REG, address);
+ name = NULL;
if (setjmp(bus_error_jmp) == 0) {
catch_memory_errors = 1;
sync();
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’
2018-06-22 19:27 [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’ Mathieu Malaterre
@ 2018-06-23 16:59 ` christophe leroy
2018-06-23 19:47 ` Segher Boessenkool
0 siblings, 1 reply; 5+ messages in thread
From: christophe leroy @ 2018-06-23 16:59 UTC (permalink / raw)
To: Mathieu Malaterre, Michael Ellerman
Cc: Yisheng Xie, Vaibhav Jain, Nicholas Piggin, linux-kernel,
Paul Mackerras, Breno Leitao, linuxppc-dev
Le 22/06/2018 à 21:27, Mathieu Malaterre a écrit :
> Move initialization of variables after data definitions. This silence
> warnings treated as error with W=1:
>
> arch/powerpc/xmon/xmon.c:3389:14: error: variable ‘name’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> arch/powerpc/xmon/xmon.c:3100:22: error: variable ‘tsk’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
Is that an invalid warning ?
If so, please explain in the commit log.
Otherwise, I'd expect one to fix the warning, not just cheat on GCC.
Christophe
>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> arch/powerpc/xmon/xmon.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index 47166ad2a669..982848c784ff 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -3097,10 +3097,11 @@ static void show_pte(unsigned long addr)
> static void show_tasks(void)
> {
> unsigned long tskv;
> - struct task_struct *tsk = NULL;
> + struct task_struct *tsk;
>
> printf(" task_struct ->thread.ksp PID PPID S P CMD\n");
>
> + tsk = NULL;
> if (scanhex(&tskv))
> tsk = (struct task_struct *)tskv;
>
> @@ -3386,10 +3387,11 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
> const char *after)
> {
> char *modname;
> - const char *name = NULL;
> + const char *name;
> unsigned long offset, size;
>
> printf(REG, address);
> + name = NULL;
> if (setjmp(bus_error_jmp) == 0) {
> catch_memory_errors = 1;
> sync();
>
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’
2018-06-23 16:59 ` christophe leroy
@ 2018-06-23 19:47 ` Segher Boessenkool
2018-06-26 6:27 ` Mathieu Malaterre
0 siblings, 1 reply; 5+ messages in thread
From: Segher Boessenkool @ 2018-06-23 19:47 UTC (permalink / raw)
To: christophe leroy
Cc: Mathieu Malaterre, Michael Ellerman, Yisheng Xie, Vaibhav Jain,
Nicholas Piggin, linux-kernel, Paul Mackerras, Breno Leitao,
linuxppc-dev
On Sat, Jun 23, 2018 at 06:59:27PM +0200, christophe leroy wrote:
>
>
> Le 22/06/2018 à 21:27, Mathieu Malaterre a écrit :
> >Move initialization of variables after data definitions. This silence
> >warnings treated as error with W=1:
> >
> > arch/powerpc/xmon/xmon.c:3389:14: error: variable ‘name’ might be
> > clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> > arch/powerpc/xmon/xmon.c:3100:22: error: variable ‘tsk’ might be
> > clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
>
> Is that an invalid warning ?
No, both are correct warnings. GCC can not see which functions it only
has a declaration of can call longjmp.
> Otherwise, I'd expect one to fix the warning, not just cheat on GCC.
Yes, the patch seems to change the code in such a way that some versions
of GCC will no longer warn. Which does not make to code any more correct.
Either restructure the code, or make the var non-automatic, or make it
volatile.
Segher
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’
2018-06-23 19:47 ` Segher Boessenkool
@ 2018-06-26 6:27 ` Mathieu Malaterre
0 siblings, 0 replies; 5+ messages in thread
From: Mathieu Malaterre @ 2018-06-26 6:27 UTC (permalink / raw)
To: Segher Boessenkool
Cc: Christophe LEROY, Michael Ellerman, Yisheng Xie, Vaibhav Jain,
Nicholas Piggin, LKML, Paul Mackerras, Breno Leitao,
linuxppc-dev
On Sat, Jun 23, 2018 at 9:47 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Sat, Jun 23, 2018 at 06:59:27PM +0200, christophe leroy wrote:
> >
> >
> > Le 22/06/2018 à 21:27, Mathieu Malaterre a écrit :
> > >Move initialization of variables after data definitions. This silence
> > >warnings treated as error with W=1:
> > >
> > > arch/powerpc/xmon/xmon.c:3389:14: error: variable ‘name’ might be
> > > clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> > > arch/powerpc/xmon/xmon.c:3100:22: error: variable ‘tsk’ might be
> > > clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> >
> > Is that an invalid warning ?
>
> No, both are correct warnings. GCC can not see which functions it only
> has a declaration of can call longjmp.
I assumed those were false positive warnings, given how easy it was to
defeat them. Let give it another try.
> > Otherwise, I'd expect one to fix the warning, not just cheat on GCC.
>
> Yes, the patch seems to change the code in such a way that some versions
> of GCC will no longer warn. Which does not make to code any more correct.
>
> Either restructure the code, or make the var non-automatic, or make it
> volatile.
>
>
> Segher
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’
@ 2018-06-26 6:27 ` Mathieu Malaterre
0 siblings, 0 replies; 5+ messages in thread
From: Mathieu Malaterre @ 2018-06-26 6:27 UTC (permalink / raw)
To: Segher Boessenkool
Cc: Christophe LEROY, Michael Ellerman, Yisheng Xie, Vaibhav Jain,
Nicholas Piggin, LKML, Paul Mackerras, Breno Leitao,
linuxppc-dev
On Sat, Jun 23, 2018 at 9:47 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Sat, Jun 23, 2018 at 06:59:27PM +0200, christophe leroy wrote:
> >
> >
> > Le 22/06/2018 =C3=A0 21:27, Mathieu Malaterre a =C3=A9crit :
> > >Move initialization of variables after data definitions. This silence
> > >warnings treated as error with W=3D1:
> > >
> > > arch/powerpc/xmon/xmon.c:3389:14: error: variable =E2=80=98name=E2=
=80=99 might be
> > > clobbered by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [=
-Werror=3Dclobbered]
> > > arch/powerpc/xmon/xmon.c:3100:22: error: variable =E2=80=98tsk=E2=
=80=99 might be
> > > clobbered by =E2=80=98longjmp=E2=80=99 or =E2=80=98vfork=E2=80=99 [=
-Werror=3Dclobbered]
> >
> > Is that an invalid warning ?
>
> No, both are correct warnings. GCC can not see which functions it only
> has a declaration of can call longjmp.
I assumed those were false positive warnings, given how easy it was to
defeat them. Let give it another try.
> > Otherwise, I'd expect one to fix the warning, not just cheat on GCC.
>
> Yes, the patch seems to change the code in such a way that some versions
> of GCC will no longer warn. Which does not make to code any more correct=
.
>
> Either restructure the code, or make the var non-automatic, or make it
> volatile.
>
>
> Segher
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-26 6:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22 19:27 [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’ Mathieu Malaterre
2018-06-23 16:59 ` christophe leroy
2018-06-23 19:47 ` Segher Boessenkool
2018-06-26 6:27 ` Mathieu Malaterre
2018-06-26 6:27 ` 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.