From nobody Fri Apr 19 04:37:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620144929; cv=none; d=zohomail.com; s=zohoarc; b=KwkYGEkpibuoK12iRVYNi2la4JkrUplb8lfJc9sJWsSnVbeRq8XzPMRD3x5qSufQihtjuPrxDm9xcsBl1HSsC/7Ai2F5RES7QDRGZUJdJEt2IY7k55oCMG4E3c7mdM0jU+FnHCwY1sVTFOrqp0S9X4WS8Gg4z4gOaNKvLp9IONg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620144929; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Eha5+8TnSaXHjPp5wNrnshuTAJi26DOxP8AxeGTYtbc=; b=DEir8CNkHMuctQmwAk2MROQcxOSTrbOZCJJSYndcZVqWQgczFhfBD6k+xRCFnyUn4NCS+WyEgo3r6Jz7D8pLgaYqVNa4ZWE8ueDJ95ADR1DXpQKBSWPhpm1Lr33PlAITeZw/nSIuKXSe2qGTqnkGwzLZM9u429C81BvI9Y1LFYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620144929507316.18237111507426; Tue, 4 May 2021 09:15:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.122564.231164 (Exim 4.92) (envelope-from ) id 1ldxhS-000495-82; Tue, 04 May 2021 16:15:06 +0000 Received: by outflank-mailman (output) from mailman id 122564.231164; Tue, 04 May 2021 16:15:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ldxhS-00048x-4j; Tue, 04 May 2021 16:15:06 +0000 Received: by outflank-mailman (input) for mailman id 122564; Tue, 04 May 2021 16:15:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ldxhQ-00048f-If for xen-devel@lists.xenproject.org; Tue, 04 May 2021 16:15:04 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0a0874d7-1103-4742-a191-09a704b2fbd8; Tue, 04 May 2021 16:15:03 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0a0874d7-1103-4742-a191-09a704b2fbd8 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620144903; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RbE9Angj5xJVvHKryCVkZNxXmr6wlbJe7cuv7VsWjZQ=; b=OjLu0BIMP6VKLAJiCv3cg2YkW3Qiw5masuTjw74ymIXZ94WKOVVcxWjO 9mcNGvSennboACpdddUi8Ar09HPklevJy9GuFjdu5MBBRChDx6itrsBND 7bUrweZYZR4VWnJsLR6+wX4MtLzLGOgHIs/Xh9HG/9813Lo8d65QKRnM9 A=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: jrZFDAdcWP9PxAV4qiOrl5myQKBMA4t1Mg/dxxGX5aQb+gmTtFmuMon/lzloVuamPKPqnUh/O2 fhU3+y7T4x5cEDrNrN/zrpJPO1QCXm9q+xJS6aDKKwLRKUAktm2xrRZxqQ1KDHU/8OX6LYyeTw 4fmU/K2udp7d3WxGFIqy7hO0qaM62mqPoweMqng1FkNhkCy3yWLC2PL4OgNZ5b2s/3lZJHtBuY Ib15SZ2mNFe9rqRmMYLnycgkCR6ptCRVQSBcfJwQwwLXf2O2zZXxyLpZwHwTUfS6NcyVEGYx+g 7Dw= X-SBRS: 5.1 X-MesageID: 44563269 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:bz+VS6HP6TG5kpwwpLqEDMeALOonbusQ8zAX/mpaICY6TuWzkc eykPMHkSLugDEKV3063fyGMq+MQXTTnKQFhbU5F7GkQQXgpS+UPJhvhLGSpQHINiXi+odmtZ tIXLN5DLTLYWRSqebfzE2GH807wN+BmZrY4Nv263t2VwllZ+VBwm5Ce2WmO3Z7TgVHGpY1fa D0jqEsygaIQngLct+9QkAMQumrnaytqLvdfRUECxQ7gTPusRqU7tfBfCSw71M7WzNLzaxKyx mmrzDE X-IronPort-AV: E=Sophos;i="5.82,272,1613451600"; d="scan'208";a="44563269" From: Anthony PERARD To: CC: Anthony PERARD , Julien Grall , Ian Jackson , Wei Liu Subject: [XEN PATCH v2] xl: constify cmd_table entries Date: Tue, 4 May 2021 17:14:36 +0100 Message-ID: <20210504161436.613782-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" Also constify cmdtable_len and make use of ARRAY_SIZE, which is available in "xen-tools/libs.h". The entries in cmd_table don't need to be modified once xl is running. Signed-off-by: Anthony PERARD Reviewed-by: Julien Grall Acked-by: Wei Liu --- Notes: v2: - use ARRAY_SIZE() - rework commit message tools/xl/xl.c | 4 ++-- tools/xl/xl.h | 6 +++--- tools/xl/xl_cmdtable.c | 9 +++++---- 3 files changed, 10 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 =3D 0; char *cmd =3D 0; - struct cmd_spec *cspec; + const struct cmd_spec *cspec; int ret; void *config_data =3D 0; int config_len =3D 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; =20 if (!command || !strcmp(command, "help")) { printf("Usage xl [-vfNtT] [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); =20 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); =20 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..661323d4884e 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -15,10 +15,11 @@ #include =20 #include +#include =20 #include "xl.h" =20 -struct cmd_spec cmd_table[] =3D { +const struct cmd_spec cmd_table[] =3D { { "create", &main_create, 1, 1, "Create a domain from config file ", @@ -631,12 +632,12 @@ struct cmd_spec cmd_table[] =3D { }, }; =20 -int cmdtable_len =3D sizeof(cmd_table)/sizeof(struct cmd_spec); +const int cmdtable_len =3D ARRAY_SIZE(cmd_table); =20 /* 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 =3D NULL; + const struct cmd_spec *cmd =3D NULL; size_t len; int i, count =3D 0; =20 --=20 Anthony PERARD