[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 07/14] tools/xl: Use const whenever we point to literal strings
On Mon, Apr 05, 2021 at 04:57:06PM +0100, Julien Grall wrote: > From: Julien Grall <jgrall@xxxxxxxxxx> > > literal strings are not meant to be modified. So we should use const > char * rather than char * when we want to store a pointer to them. > > Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx> > --- > diff --git a/tools/xl/xl.h b/tools/xl/xl.h > index 137a29077c1e..3052e3db0072 100644 > --- a/tools/xl/xl.h > +++ b/tools/xl/xl.h > @@ -21,13 +21,13 @@ > #include <xentoollog.h> > > struct cmd_spec { > - char *cmd_name; > + const char *cmd_name; > int (*cmd_impl)(int argc, char **argv); > int can_dryrun; > int modifies; > - char *cmd_desc; > - char *cmd_usage; > - char *cmd_option; > + const char *cmd_desc; > + const char *cmd_usage; > + const char *cmd_option; > }; Those const in cmd_spec feels almost the wrong things to do, but it is also unlikely that we would want to modify the strings in a cmd_spec so I guess that's fine. I'm thinking that `cmd_table` should be const as well (I mean const struct cmd_spec cmd_table[];) as there is no reason to modify the entries once they are in the table. I'll send a patch. The rest looks good. Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Thanks, -- Anthony PERARD
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |