* [XEN PATCH] xl: constify cmd_table entries
@ 2021-04-27 16:11 Anthony PERARD
2021-04-28 12:54 ` Julien Grall
0 siblings, 1 reply; 3+ messages in thread
From: Anthony PERARD @ 2021-04-27 16:11 UTC (permalink / raw)
To: xen-devel; +Cc: Julien Grall, Anthony PERARD, Ian Jackson, Wei Liu
and cmdtable_len.
The entries in cmd_table don't need to be modified once xl is running.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
tools/xl/xl.c | 4 ++--
tools/xl/xl.h | 6 +++---
tools/xl/xl_cmdtable.c | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/xl/xl.c b/tools/xl/xl.c
index 3a8929580212..4107d10fd469 100644
--- a/tools/xl/xl.c
+++ b/tools/xl/xl.c
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
{
int opt = 0;
char *cmd = 0;
- struct cmd_spec *cspec;
+ const struct cmd_spec *cspec;
int ret;
void *config_data = 0;
int config_len = 0;
@@ -462,7 +462,7 @@ int child_report(xlchildnum child)
void help(const char *command)
{
int i;
- struct cmd_spec *cmd;
+ const struct cmd_spec *cmd;
if (!command || !strcmp(command, "help")) {
printf("Usage xl [-vfNtT] <subcommand> [args]\n\n");
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 137a29077c1e..e5a106dfbc82 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -218,10 +218,10 @@ int main_qemu_monitor_command(int argc, char **argv);
void help(const char *command);
extern const char *common_domname;
-extern struct cmd_spec cmd_table[];
-extern int cmdtable_len;
+extern const struct cmd_spec cmd_table[];
+extern const int cmdtable_len;
/* Look up a command in the table, allowing unambiguous truncation */
-struct cmd_spec *cmdtable_lookup(const char *s);
+const struct cmd_spec *cmdtable_lookup(const char *s);
extern libxl_ctx *ctx;
extern xentoollog_logger_stdiostream *logger;
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 07f54daabec3..84e2067e278b 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -18,7 +18,7 @@
#include "xl.h"
-struct cmd_spec cmd_table[] = {
+const struct cmd_spec cmd_table[] = {
{ "create",
&main_create, 1, 1,
"Create a domain from config file <filename>",
@@ -631,12 +631,12 @@ struct cmd_spec cmd_table[] = {
},
};
-int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
+const int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
/* Look up a command in the table, allowing unambiguous truncation */
-struct cmd_spec *cmdtable_lookup(const char *s)
+const struct cmd_spec *cmdtable_lookup(const char *s)
{
- struct cmd_spec *cmd = NULL;
+ const struct cmd_spec *cmd = NULL;
size_t len;
int i, count = 0;
--
Anthony PERARD
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [XEN PATCH] xl: constify cmd_table entries
2021-04-27 16:11 [XEN PATCH] xl: constify cmd_table entries Anthony PERARD
@ 2021-04-28 12:54 ` Julien Grall
2021-05-04 15:51 ` Anthony PERARD
0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2021-04-28 12:54 UTC (permalink / raw)
To: Anthony PERARD, xen-devel; +Cc: Ian Jackson, Wei Liu
NIT: I would suggest to add "..." so it is clear...
On 27/04/2021 17:11, Anthony PERARD wrote:
> and cmdtable_len.
... this is a continuation of the title.
>
> The entries in cmd_table don't need to be modified once xl is running.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> tools/xl/xl.c | 4 ++--
> tools/xl/xl.h | 6 +++---
> tools/xl/xl_cmdtable.c | 8 ++++----
> 3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/tools/xl/xl.c b/tools/xl/xl.c
> index 3a8929580212..4107d10fd469 100644
> --- a/tools/xl/xl.c
> +++ b/tools/xl/xl.c
> @@ -362,7 +362,7 @@ int main(int argc, char **argv)
> {
> int opt = 0;
> char *cmd = 0;
> - struct cmd_spec *cspec;
> + const struct cmd_spec *cspec;
> int ret;
> void *config_data = 0;
> int config_len = 0;
> @@ -462,7 +462,7 @@ int child_report(xlchildnum child)
> void help(const char *command)
> {
> int i;
> - struct cmd_spec *cmd;
> + const struct cmd_spec *cmd;
>
> if (!command || !strcmp(command, "help")) {
> printf("Usage xl [-vfNtT] <subcommand> [args]\n\n");
> diff --git a/tools/xl/xl.h b/tools/xl/xl.h
> index 137a29077c1e..e5a106dfbc82 100644
> --- a/tools/xl/xl.h
> +++ b/tools/xl/xl.h
> @@ -218,10 +218,10 @@ int main_qemu_monitor_command(int argc, char **argv);
> void help(const char *command);
>
> extern const char *common_domname;
> -extern struct cmd_spec cmd_table[];
> -extern int cmdtable_len;
> +extern const struct cmd_spec cmd_table[];
> +extern const int cmdtable_len;
> /* Look up a command in the table, allowing unambiguous truncation */
> -struct cmd_spec *cmdtable_lookup(const char *s);
> +const struct cmd_spec *cmdtable_lookup(const char *s);
>
> extern libxl_ctx *ctx;
> extern xentoollog_logger_stdiostream *logger;
> diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
> index 07f54daabec3..84e2067e278b 100644
> --- a/tools/xl/xl_cmdtable.c
> +++ b/tools/xl/xl_cmdtable.c
> @@ -18,7 +18,7 @@
>
> #include "xl.h"
>
> -struct cmd_spec cmd_table[] = {
> +const struct cmd_spec cmd_table[] = {
> { "create",
> &main_create, 1, 1,
> "Create a domain from config file <filename>",
> @@ -631,12 +631,12 @@ struct cmd_spec cmd_table[] = {
> },
> };
>
> -int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
> +const int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
NIT: This can be replaced with ARRAY_SIZE().
>
> /* Look up a command in the table, allowing unambiguous truncation */
> -struct cmd_spec *cmdtable_lookup(const char *s)
> +const struct cmd_spec *cmdtable_lookup(const char *s)
> {
> - struct cmd_spec *cmd = NULL;
> + const struct cmd_spec *cmd = NULL;
> size_t len;
> int i, count = 0;
>
>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [XEN PATCH] xl: constify cmd_table entries
2021-04-28 12:54 ` Julien Grall
@ 2021-05-04 15:51 ` Anthony PERARD
0 siblings, 0 replies; 3+ messages in thread
From: Anthony PERARD @ 2021-05-04 15:51 UTC (permalink / raw)
To: Julien Grall; +Cc: xen-devel, Ian Jackson, Wei Liu
On Wed, Apr 28, 2021 at 01:54:39PM +0100, Julien Grall wrote:
> > -int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
> > +const int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
>
> NIT: This can be replaced with ARRAY_SIZE().
I've thought of using it but the macro isn't available to "xl". But it's
probably a good time to add the macro and start using it.
>
> Reviewed-by: Julien Grall <jgrall@amazon.com>
Thanks,
--
Anthony PERARD
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-04 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 16:11 [XEN PATCH] xl: constify cmd_table entries Anthony PERARD
2021-04-28 12:54 ` Julien Grall
2021-05-04 15:51 ` Anthony PERARD
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.