public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n
@ 2019-01-17  9:18 Quentin Schulz
  2019-01-17  9:22 ` Miquel Raynal
  2019-01-19  2:53 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Quentin Schulz @ 2019-01-17  9:18 UTC (permalink / raw)
  To: u-boot

cmd/mtd.c:447:13: warning: ‘mtd_help_text’ defined but not used [-Wunused-variable]
static char mtd_help_text[] =
            ^~~~~~~~~~~~~

When SYS_LONGHELP is not defined. After looking at how other commands
work, we should surround the whole help text (even its declaration) with
an #ifdef CONFIG_SYS_LONGHELP, since it's compiled out when calling
_CMD_HELP[1] on the help text variable argument to U_BOOT_CMD.

[1] https://elixir.bootlin.com/u-boot/latest/source/include/command.h#L181

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
---
 cmd/mtd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/cmd/mtd.c b/cmd/mtd.c
index 6142223984..361813a4a1 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -444,8 +444,8 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return CMD_RET_SUCCESS;
 }
 
-static char mtd_help_text[] =
 #ifdef CONFIG_SYS_LONGHELP
+static char mtd_help_text[] =
 	"- generic operations on memory technology devices\n\n"
 	"mtd list\n"
 	"mtd read[.raw][.oob]                  <name> <addr> [<off> [<size>]]\n"
@@ -466,8 +466,7 @@ static char mtd_help_text[] =
 	"\t\t* must be a multiple of a block for erase\n"
 	"\t\t* must be a multiple of a page otherwise (special case: default is a page with dump)\n"
 	"\n"
-	"The .dontskipff option forces writing empty pages, don't use it if unsure.\n"
+	"The .dontskipff option forces writing empty pages, don't use it if unsure.\n";
 #endif
-	"";
 
 U_BOOT_CMD(mtd, 10, 1, do_mtd, "MTD utils", mtd_help_text);
-- 
2.17.1

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

* [U-Boot] [PATCH] cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n
  2019-01-17  9:18 [U-Boot] [PATCH] cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n Quentin Schulz
@ 2019-01-17  9:22 ` Miquel Raynal
  2019-01-19  2:53 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2019-01-17  9:22 UTC (permalink / raw)
  To: u-boot

Hi Quentin,

Quentin Schulz <quentin.schulz@bootlin.com> wrote on Thu, 17 Jan 2019
10:18:47 +0100:

> cmd/mtd.c:447:13: warning: ‘mtd_help_text’ defined but not used [-Wunused-variable]
> static char mtd_help_text[] =
>             ^~~~~~~~~~~~~
> 
> When SYS_LONGHELP is not defined. After looking at how other commands
> work, we should surround the whole help text (even its declaration) with
> an #ifdef CONFIG_SYS_LONGHELP, since it's compiled out when calling
> _CMD_HELP[1] on the help text variable argument to U_BOOT_CMD.
> 
> [1] https://elixir.bootlin.com/u-boot/latest/source/include/command.h#L181
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
> ---
>  cmd/mtd.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/mtd.c b/cmd/mtd.c
> index 6142223984..361813a4a1 100644
> --- a/cmd/mtd.c
> +++ b/cmd/mtd.c
> @@ -444,8 +444,8 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  	return CMD_RET_SUCCESS;
>  }
>  
> -static char mtd_help_text[] =
>  #ifdef CONFIG_SYS_LONGHELP
> +static char mtd_help_text[] =
>  	"- generic operations on memory technology devices\n\n"
>  	"mtd list\n"
>  	"mtd read[.raw][.oob]                  <name> <addr> [<off> [<size>]]\n"
> @@ -466,8 +466,7 @@ static char mtd_help_text[] =
>  	"\t\t* must be a multiple of a block for erase\n"
>  	"\t\t* must be a multiple of a page otherwise (special case: default is a page with dump)\n"
>  	"\n"
> -	"The .dontskipff option forces writing empty pages, don't use it if unsure.\n"
> +	"The .dontskipff option forces writing empty pages, don't use it if unsure.\n";
>  #endif
> -	"";
>  
>  U_BOOT_CMD(mtd, 10, 1, do_mtd, "MTD utils", mtd_help_text);

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>


Thanks,
Miquèl

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

* [U-Boot] cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n
  2019-01-17  9:18 [U-Boot] [PATCH] cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n Quentin Schulz
  2019-01-17  9:22 ` Miquel Raynal
@ 2019-01-19  2:53 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2019-01-19  2:53 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 17, 2019 at 10:18:47AM +0100, Quentin Schulz wrote:

> cmd/mtd.c:447:13: warning: ‘mtd_help_text’ defined but not used [-Wunused-variable]
> static char mtd_help_text[] =
>             ^~~~~~~~~~~~~
> 
> When SYS_LONGHELP is not defined. After looking at how other commands
> work, we should surround the whole help text (even its declaration) with
> an #ifdef CONFIG_SYS_LONGHELP, since it's compiled out when calling
> _CMD_HELP[1] on the help text variable argument to U_BOOT_CMD.
> 
> [1] https://elixir.bootlin.com/u-boot/latest/source/include/command.h#L181
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190118/4755b2d4/attachment.sig>

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

end of thread, other threads:[~2019-01-19  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-17  9:18 [U-Boot] [PATCH] cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n Quentin Schulz
2019-01-17  9:22 ` Miquel Raynal
2019-01-19  2:53 ` [U-Boot] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox