All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: LEROY Christophe <christophe.leroy@c-s.fr>,
	Mathieu Malaterre <malat@debian.org>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	"Paul Mackerras" <paulus@samba.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH v2 03/19] powerpc: Mark variables as unused
Date: Thu, 05 Apr 2018 15:57:59 +1000	[thread overview]
Message-ID: <87fu4atct4.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20180329181422.Horde.4gvIQbpSZkuyC4Yzg06PKw2@messagerie.si.c-s.fr>

LEROY Christophe <christophe.leroy@c-s.fr> writes:

> Mathieu Malaterre <malat@debian.org> a écrit :
>
>> Add gcc attribute unused for two variables. Fix warnings treated as errors
>> with W=1:
>>
>>   arch/powerpc/kernel/prom_init.c:1388:8: error: variable ‘path’ 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: move path within ifdef DEBUG_PROM
>>
>>  arch/powerpc/kernel/prom_init.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/prom_init.c  
>> b/arch/powerpc/kernel/prom_init.c
>> index acf4b2e0530c..4163b11abb6c 100644
>> --- a/arch/powerpc/kernel/prom_init.c
>> +++ b/arch/powerpc/kernel/prom_init.c
>> @@ -603,7 +603,7 @@ static void __init early_cmdline_parse(void)
>>  	const char *opt;
>>
>>  	char *p;
>> -	int l = 0;
>> +	int l __maybe_unused = 0;
>>
>>  	prom_cmd_line[0] = 0;
>>  	p = prom_cmd_line;
>> @@ -1385,7 +1385,7 @@ static void __init reserve_mem(u64 base, u64 size)
>>  static void __init prom_init_mem(void)
>>  {
>>  	phandle node;
>> -	char *path, type[64];
>> +	char *path __maybe_unused, type[64];
>
> You should enclose that in an ifdef DEBUG_PROM instead of hiding the warning

I disagree, the result is horrible:

 static void __init prom_init_mem(void)
 {
	phandle node;
-	char *path, type[64];
+#ifdef DEBUG_PROM
+	char *path;
+#endif
+	char type[64];
	unsigned int plen;
	cell_t *p, *endp;
	__be32 val;


The right fix is to move the debug logic into a helper, and put the path
in there, eg. something like (not tested):

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index f9d6befb55a6..b02fa2ccc70b 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1389,6 +1389,18 @@ static void __init reserve_mem(u64 base, u64 size)
 	mem_reserve_cnt = cnt + 1;
 }
 
+#ifdef DEBUG_PROM
+static void prom_debug_path(phandle node)
+{
+	char *path;
+	path = prom_scratch;
+	memset(path, 0, PROM_SCRATCH_SIZE);
+	call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
+	prom_debug("  node %s :\n", path);
+}
+#else
+static void prom_debug_path(phandle node) { }
+#endif /* DEBUG_PROM */
 /*
  * Initialize memory allocation mechanism, parse "memory" nodes and
  * obtain that way the top of memory and RMO to setup out local allocator
@@ -1441,11 +1453,7 @@ static void __init prom_init_mem(void)
 		p = regbuf;
 		endp = p + (plen / sizeof(cell_t));
 
-#ifdef DEBUG_PROM
-		memset(path, 0, PROM_SCRATCH_SIZE);
-		call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
-		prom_debug("  node %s :\n", path);
-#endif /* DEBUG_PROM */
+		prom_debug_path(node);
 
 		while ((endp - p) >= (rac + rsc)) {
 			unsigned long base, size;


Although that also begs the question of why the hell do we need path at
all, and not just use prom_scratch directly?

cheers

WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: LEROY Christophe <christophe.leroy@c-s.fr>,
	Mathieu Malaterre <malat@debian.org>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	"Paul Mackerras" <paulus@samba.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH v2 03/19] powerpc: Mark variables as unused
Date: Thu, 05 Apr 2018 15:57:59 +1000	[thread overview]
Message-ID: <87fu4atct4.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20180329181422.Horde.4gvIQbpSZkuyC4Yzg06PKw2@messagerie.si.c-s.fr>

LEROY Christophe <christophe.leroy@c-s.fr> writes:

> Mathieu Malaterre <malat@debian.org> a =C3=A9crit=C2=A0:
>
>> Add gcc attribute unused for two variables. Fix warnings treated as erro=
rs
>> with W=3D1:
>>
>>   arch/powerpc/kernel/prom_init.c:1388:8: error: variable =E2=80=98path=
=E2=80=99 set=20=20
>> but not used [-Werror=3Dunused-but-set-variable]
>>
>> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>> ---
>> v2: move path within ifdef DEBUG_PROM
>>
>>  arch/powerpc/kernel/prom_init.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/prom_init.c=20=20
>> b/arch/powerpc/kernel/prom_init.c
>> index acf4b2e0530c..4163b11abb6c 100644
>> --- a/arch/powerpc/kernel/prom_init.c
>> +++ b/arch/powerpc/kernel/prom_init.c
>> @@ -603,7 +603,7 @@ static void __init early_cmdline_parse(void)
>>  	const char *opt;
>>
>>  	char *p;
>> -	int l =3D 0;
>> +	int l __maybe_unused =3D 0;
>>
>>  	prom_cmd_line[0] =3D 0;
>>  	p =3D prom_cmd_line;
>> @@ -1385,7 +1385,7 @@ static void __init reserve_mem(u64 base, u64 size)
>>  static void __init prom_init_mem(void)
>>  {
>>  	phandle node;
>> -	char *path, type[64];
>> +	char *path __maybe_unused, type[64];
>
> You should enclose that in an ifdef DEBUG_PROM instead of hiding the warn=
ing

I disagree, the result is horrible:

 static void __init prom_init_mem(void)
 {
	phandle node;
-	char *path, type[64];
+#ifdef DEBUG_PROM
+	char *path;
+#endif
+	char type[64];
	unsigned int plen;
	cell_t *p, *endp;
	__be32 val;


The right fix is to move the debug logic into a helper, and put the path
in there, eg. something like (not tested):

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_ini=
t.c
index f9d6befb55a6..b02fa2ccc70b 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1389,6 +1389,18 @@ static void __init reserve_mem(u64 base, u64 size)
 	mem_reserve_cnt =3D cnt + 1;
 }
=20
+#ifdef DEBUG_PROM
+static void prom_debug_path(phandle node)
+{
+	char *path;
+	path =3D prom_scratch;
+	memset(path, 0, PROM_SCRATCH_SIZE);
+	call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
+	prom_debug("  node %s :\n", path);
+}
+#else
+static void prom_debug_path(phandle node) { }
+#endif /* DEBUG_PROM */
 /*
  * Initialize memory allocation mechanism, parse "memory" nodes and
  * obtain that way the top of memory and RMO to setup out local allocator
@@ -1441,11 +1453,7 @@ static void __init prom_init_mem(void)
 		p =3D regbuf;
 		endp =3D p + (plen / sizeof(cell_t));
=20
-#ifdef DEBUG_PROM
-		memset(path, 0, PROM_SCRATCH_SIZE);
-		call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);
-		prom_debug("  node %s :\n", path);
-#endif /* DEBUG_PROM */
+		prom_debug_path(node);
=20
 		while ((endp - p) >=3D (rac + rsc)) {
 			unsigned long base, size;


Although that also begs the question of why the hell do we need path at
all, and not just use prom_scratch directly?

cheers

  reply	other threads:[~2018-04-05  5:58 UTC|newest]

Thread overview: 173+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 20:19 [PATCH 00/19] powerpc/ppc32: make W=1 compilation errors free Mathieu Malaterre
2018-03-22 20:19 ` Mathieu Malaterre
2018-03-22 20:19 ` [PATCH 01/19] powerpc/powermac: Mark variable x as unused Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23  9:18   ` christophe leroy
2018-03-23  9:18     ` christophe leroy
2018-03-28 19:27   ` [PATCH v2 " Mathieu Malaterre
2018-03-29 16:07     ` LEROY Christophe
2018-03-29 16:07       ` LEROY Christophe
2018-04-04 20:21       ` Mathieu Malaterre
2018-04-04 20:21         ` Mathieu Malaterre
2018-04-04 20:07     ` [PATCH v3 " Mathieu Malaterre
2018-04-24 14:12       ` Christophe LEROY
2018-05-25 11:41       ` [v3,01/19] " Michael Ellerman
2018-03-22 20:19 ` [PATCH 02/19] " Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23  9:38   ` christophe leroy
2018-03-23  9:38     ` christophe leroy
2018-03-28 19:30   ` [PATCH v2 " Mathieu Malaterre
2018-03-29 16:09     ` LEROY Christophe
2018-03-29 16:09       ` LEROY Christophe
2018-06-22  9:46       ` Mathieu Malaterre
2018-06-22  9:46         ` Mathieu Malaterre
2018-08-13 11:22     ` [v2,02/19] " Michael Ellerman
2018-03-22 20:19 ` [PATCH 03/19] powerpc: Mark variables " Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 10:03   ` christophe leroy
2018-03-23 10:03     ` christophe leroy
2018-03-28 19:33   ` [PATCH v2 " Mathieu Malaterre
2018-03-29 16:14     ` LEROY Christophe
2018-03-29 16:14       ` LEROY Christophe
2018-04-05  5:57       ` Michael Ellerman [this message]
2018-04-05  5:57         ` Michael Ellerman
2018-04-05  7:01         ` LEROY Christophe
2018-04-05  7:01           ` LEROY Christophe
2018-04-04 20:08     ` [PATCH v3 03/19] powerpc: Move `path` variable inside DEBUG_PROM Mathieu Malaterre
2018-06-22  9:48       ` Mathieu Malaterre
2018-06-22  9:48         ` Mathieu Malaterre
2018-08-13 11:22       ` [v3,03/19] " Michael Ellerman
2018-04-05 20:26   ` [PATCH v4 03/19] powerpc: Mark variable `l` as unused, remove `path` Mathieu Malaterre
2018-04-06 15:33     ` LEROY Christophe
2018-04-06 15:33       ` LEROY Christophe
2018-04-06 18:32       ` Mathieu Malaterre
2018-04-06 18:32         ` Mathieu Malaterre
2018-04-24 19:20         ` christophe leroy
2018-03-22 20:19 ` [PATCH 04/19] powerpc/kvm: Mark variable tmp unused Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 10:08   ` christophe leroy
2018-03-23 10:08     ` christophe leroy
2018-03-28 19:58   ` [PATCH v2 04/19] powerpc/kvm: Prefer fault_in_pages_readable function Mathieu Malaterre
2018-03-28 19:58     ` Mathieu Malaterre
2018-03-29 16:18     ` LEROY Christophe
2018-03-29 16:18       ` LEROY Christophe
2018-03-29 16:18       ` LEROY Christophe
2018-05-25  1:59     ` [v2,04/19] " Michael Ellerman
2018-05-25  1:59       ` Michael Ellerman
2018-03-22 20:19 ` [PATCH 05/19] powerpc/chrp/setup: Add attribute unused and make some functions static Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 11:01   ` christophe leroy
2018-03-23 11:01     ` christophe leroy
2018-03-28 19:35   ` [PATCH v2 " Mathieu Malaterre
2018-03-29 16:16     ` LEROY Christophe
2018-03-29 16:16       ` LEROY Christophe
2018-04-04 20:09     ` [PATCH v3 05/19] powerpc/chrp/setup: Remove idu_size variable " Mathieu Malaterre
2018-05-25 11:41       ` [v3, " Michael Ellerman
2018-03-22 20:19 ` [PATCH 06/19] powerpc: Make function btext_initialize static Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-05-25 11:41   ` [06/19] " Michael Ellerman
2018-05-25 11:41     ` Michael Ellerman
2018-03-22 20:19 ` [PATCH 07/19] powerpc/powermac: Make some functions static Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 11:05   ` christophe leroy
2018-03-23 11:05     ` christophe leroy
2018-03-28 19:39   ` [PATCH v2 " Mathieu Malaterre
2018-06-22 11:29     ` Mathieu Malaterre
2018-06-22 11:29       ` Mathieu Malaterre
2018-08-13 11:22     ` [v2,07/19] " Michael Ellerman
2018-03-22 20:19 ` [PATCH 08/19] powerpc/tau: Make some function static Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-05-25 11:41   ` [08/19] " Michael Ellerman
2018-05-25 11:41     ` Michael Ellerman
2018-03-22 20:19 ` [PATCH 09/19] powerpc/chrp/pci: Make some functions static Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-04-04 20:15   ` [PATCH v3 " Mathieu Malaterre
2018-05-25 11:41     ` [v3,09/19] " Michael Ellerman
2018-03-22 20:19 ` [PATCH 10/19] powerpc/chrp/time: Make some functions static, add missing header include Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-05-25 11:41   ` [10/19] " Michael Ellerman
2018-05-25 11:41     ` Michael Ellerman
2018-03-22 20:19 ` [PATCH 11/19] powerpc/powermac: Move pmac_pfunc_base_install prototype to header file Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 12:13   ` christophe leroy
2018-03-23 12:13     ` christophe leroy
2018-03-28 19:11     ` Mathieu Malaterre
2018-03-28 19:11       ` Mathieu Malaterre
2018-03-29 15:51       ` LEROY Christophe
2018-03-29 15:51         ` LEROY Christophe
2018-04-04 20:13   ` [PATCH v3 " Mathieu Malaterre
2018-05-25 11:41     ` [v3, " Michael Ellerman
2018-03-22 20:19 ` [PATCH 12/19] powerpc/powermac: Add missing prototype for note_bootable_part() Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 12:14   ` christophe leroy
2018-03-23 12:14     ` christophe leroy
2018-04-04 20:13   ` [PATCH v3 " Mathieu Malaterre
2018-05-25 11:41     ` [v3, " Michael Ellerman
2018-03-22 20:19 ` [PATCH 13/19] powerpc/52xx: Add missing functions prototypes Mathieu Malaterre
2018-03-22 20:19   ` Mathieu Malaterre
2018-03-23 12:18   ` christophe leroy
2018-03-23 12:18     ` christophe leroy
2018-04-04 20:12   ` [PATCH v3 " Mathieu Malaterre
2018-05-25 11:41     ` [v3,13/19] " Michael Ellerman
2018-03-22 20:20 ` [PATCH 14/19] powerpc/altivec: Add missing prototypes for altivec Mathieu Malaterre
2018-03-22 20:20   ` Mathieu Malaterre
2018-03-23 12:19   ` christophe leroy
2018-03-23 12:19     ` christophe leroy
2018-03-23 12:24     ` Mathieu Malaterre
2018-03-23 12:24       ` Mathieu Malaterre
2018-03-23 12:24       ` Mathieu Malaterre
2018-03-24 20:10       ` LEROY Christophe
2018-03-24 20:10         ` LEROY Christophe
2018-03-24 20:10         ` LEROY Christophe
2018-03-27  8:39         ` Mathieu Malaterre
2018-03-27  8:39           ` Mathieu Malaterre
2018-03-27  8:39           ` Mathieu Malaterre
2018-03-27 15:58           ` LEROY Christophe
2018-03-27 15:58             ` LEROY Christophe
2018-03-27 15:58             ` LEROY Christophe
2018-03-27 17:33             ` LEROY Christophe
2018-03-27 17:33               ` LEROY Christophe
2018-03-27 17:33               ` LEROY Christophe
2018-03-28  7:26               ` Mathieu Malaterre
2018-03-28  7:26                 ` Mathieu Malaterre
2018-03-28  7:26                 ` Mathieu Malaterre
2018-03-28 11:53                 ` Mathieu Malaterre
2018-03-28 11:53                   ` Mathieu Malaterre
2018-03-28 18:47   ` [PATCH v2] " Mathieu Malaterre
2018-03-28 18:55   ` [PATCH v3] " Mathieu Malaterre
2018-05-25 11:41     ` [v3] " Michael Ellerman
2018-03-22 20:20 ` [PATCH 15/19] powerpc: Add missing prototype Mathieu Malaterre
2018-03-22 20:20   ` Mathieu Malaterre
2018-03-23 12:20   ` christophe leroy
2018-03-23 12:20     ` christophe leroy
2018-03-28 19:13     ` Mathieu Malaterre
2018-03-28 19:13       ` Mathieu Malaterre
2018-03-29 16:02       ` LEROY Christophe
2018-03-29 16:02         ` LEROY Christophe
2018-04-04 20:18         ` Mathieu Malaterre
2018-04-04 20:18           ` Mathieu Malaterre
2018-04-04 20:11   ` [PATCH v3 " Mathieu Malaterre
2018-05-25 11:41     ` [v3,15/19] " Michael Ellerman
2018-03-22 20:20 ` [PATCH 16/19] powerpc/powermac: Add missing include of header pmac.h Mathieu Malaterre
2018-03-22 20:20   ` Mathieu Malaterre
2018-06-22  9:49   ` Mathieu Malaterre
2018-06-22  9:49     ` Mathieu Malaterre
2018-06-22  9:49     ` Mathieu Malaterre
2018-08-13 11:22   ` [16/19] " Michael Ellerman
2018-08-13 11:22     ` Michael Ellerman
2018-03-22 20:20 ` [PATCH 17/19] powerpc/32: Add a missing include header Mathieu Malaterre
2018-03-22 20:20   ` Mathieu Malaterre
2018-05-25 11:41   ` [17/19] " Michael Ellerman
2018-05-25 11:41     ` Michael Ellerman
2018-03-22 20:20 ` [PATCH 18/19] powerpc: " Mathieu Malaterre
2018-03-22 20:20   ` Mathieu Malaterre
2018-05-25 11:41   ` [18/19] " Michael Ellerman
2018-05-25 11:41     ` Michael Ellerman
2018-03-22 20:20 ` [PATCH 19/19] powerpc/tau: Synchronize function prototypes and body Mathieu Malaterre
2018-03-22 20:20   ` Mathieu Malaterre
2018-03-23 12:22   ` christophe leroy
2018-03-23 12:22     ` christophe leroy
2018-04-04 20:10   ` [PATCH v3 " Mathieu Malaterre
2018-05-25 11:41     ` [v3,19/19] " Michael Ellerman
2018-05-22  6:28 ` [PATCH 00/19] powerpc/ppc32: make W=1 compilation errors free Mathieu Malaterre
2018-05-22  6:28   ` Mathieu Malaterre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fu4atct4.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=malat@debian.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.