diff mbox series

[1/4] command: Use a constant pointer for the help

Message ID 20210406043011.1780229-2-sjg@chromium.org
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series sf: Add documentation and an 'sf mmap' command | expand

Commit Message

Simon Glass April 6, 2021, 4:30 a.m. UTC
This text should never change during execution, so it makes sense to
use a const char * so that it can be declared as const in the code.
Update struct cmd_tbl with a const char * pointer for 'help'.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/command.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Anderson April 9, 2021, 3:32 a.m. UTC | #1
On 4/6/21 12:30 AM, Simon Glass wrote:
> This text should never change during execution, so it makes sense to
> use a const char * so that it can be declared as const in the code.
> Update struct cmd_tbl with a const char * pointer for 'help'.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>   include/command.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/command.h b/include/command.h
> index 747f8f80958..675c16a1249 100644
> --- a/include/command.h
> +++ b/include/command.h
> @@ -45,7 +45,7 @@ struct cmd_tbl {
>   			       char *const argv[]);
>   	char		*usage;		/* Usage message	(short)	*/

Should usage also be const?

--Sean

>   #ifdef	CONFIG_SYS_LONGHELP
> -	char		*help;		/* Help  message	(long)	*/
> +	const char	*help;		/* Help  message	(long)	*/
>   #endif
>   #ifdef CONFIG_AUTO_COMPLETE
>   	/* do auto completion on the arguments */
>
Simon Glass April 14, 2021, 7:38 p.m. UTC | #2
Hi Sean,

On Fri, 9 Apr 2021 at 04:32, Sean Anderson <seanga2@gmail.com> wrote:
>
> On 4/6/21 12:30 AM, Simon Glass wrote:
> > This text should never change during execution, so it makes sense to
> > use a const char * so that it can be declared as const in the code.
> > Update struct cmd_tbl with a const char * pointer for 'help'.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >   include/command.h | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/command.h b/include/command.h
> > index 747f8f80958..675c16a1249 100644
> > --- a/include/command.h
> > +++ b/include/command.h
> > @@ -45,7 +45,7 @@ struct cmd_tbl {
> >                              char *const argv[]);
> >       char            *usage;         /* Usage message        (short) */
>
> Should usage also be const?

I think so, but would need to check it builds, etc.

Regards,
Simon
diff mbox series

Patch

diff --git a/include/command.h b/include/command.h
index 747f8f80958..675c16a1249 100644
--- a/include/command.h
+++ b/include/command.h
@@ -45,7 +45,7 @@  struct cmd_tbl {
 			       char *const argv[]);
 	char		*usage;		/* Usage message	(short)	*/
 #ifdef	CONFIG_SYS_LONGHELP
-	char		*help;		/* Help  message	(long)	*/
+	const char	*help;		/* Help  message	(long)	*/
 #endif
 #ifdef CONFIG_AUTO_COMPLETE
 	/* do auto completion on the arguments */