From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011037606543.0113914485325; Wed, 2 Aug 2023 14:17:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575263.901063 (Exim 4.92) (envelope-from ) id 1qRJDL-0002KV-HN; Wed, 02 Aug 2023 21:17:03 +0000 Received: by outflank-mailman (output) from mailman id 575263.901063; Wed, 02 Aug 2023 21:17:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJDL-0002KO-El; Wed, 02 Aug 2023 21:17:03 +0000 Received: by outflank-mailman (input) for mailman id 575263; Wed, 02 Aug 2023 21:17:02 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJDK-0001jm-97 for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:17:02 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id eab11be8-3179-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:17:00 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LGkRh008303 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:16:51 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LGkHC008302; Wed, 2 Aug 2023 14:16:46 -0700 (PDT) (envelope-from ehem) 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: eab11be8-3179-11ee-8613-37d641c3527e Message-Id: <81a887863224ef22b8d582129fc3cbda596c7880.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Mon, 10 Jul 2023 15:55:30 -0700 Subject: [PATCH 01/22] tools/utils: cleanup formatting of libxlutil.h X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011039171100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some arguments included a name, but not all did. Now use "cfg" for all uses of XLU_Config * and "list" for uses of XLU_ConfigList *. Also fix some spaces missing from xlu_cfg_get_defbool()'s prototype. Rename the "b" argument of xlu_cfg_get_defbool() to "value_r". Similar to other functions this is where the returned value is stored. Signed-off-by: Elliott Mitchell --- tools/include/libxlutil.h | 22 +++++++++++----------- tools/libs/util/libxlu_cfg.c | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/include/libxlutil.h b/tools/include/libxlutil.h index 4dd3c5e92b..fcbe41b15a 100644 --- a/tools/include/libxlutil.h +++ b/tools/include/libxlutil.h @@ -40,12 +40,12 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *repo= rt_filename); /* report_filename is copied; report is saved and must remain valid * until the Config is destroyed. */ =20 -int xlu_cfg_readfile(XLU_Config*, const char *real_filename); -int xlu_cfg_readdata(XLU_Config*, const char *data, int length); +int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename); +int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length); /* If these fail, then it is undefined behaviour to call xlu_cfg_get_... * functions. You have to just xlu_cfg_destroy. */ =20 -void xlu_cfg_destroy(XLU_Config*); +void xlu_cfg_destroy(XLU_Config *cfg); =20 =20 /* All of the following print warnings to "report" if there is a problem. @@ -56,26 +56,26 @@ void xlu_cfg_destroy(XLU_Config*); * ERANGE value out of range (from strtol) */ =20 -int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **valu= e_r, - int dont_warn); +int xlu_cfg_get_string(const XLU_Config *cfg, const char *n, + const char **value_r, int dont_warn); /* free/strdup version */ int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, char **value_r, int dont_warn); -int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r, +int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, long *value_r, int dont_warn); -int xlu_cfg_get_bounded_long(const XLU_Config*, const char *n, long min, +int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n, long mi= n, long max, long *value_r, int dont_warn); -int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b, - int dont_warn); +int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, + libxl_defbool *value_r, int dont_warn); =20 -int xlu_cfg_get_list(const XLU_Config*, const char *n, +int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, XLU_ConfigList **list_r /* may be 0 */, int *entries_r /* may be 0 */, int dont_warn); /* there is no need to free *list_r; lifetime is that of the XLU_Config = */ int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, libxl_string_list *sl, int dont_warn); -const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int entry); +const char *xlu_cfg_get_listitem(const XLU_ConfigList *list, int entry); /* xlu_cfg_get_listitem cannot fail, except that if entry is * out of range it returns 0 (not setting errno) */ =20 diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 874f5abfb9..87ac8c4b41 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -328,15 +328,15 @@ int xlu_cfg_get_long(const XLU_Config *cfg, const cha= r *n, dont_warn); } =20 -int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, libxl_defboo= l *b, - int dont_warn) +int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, + libxl_defbool *value_r, int dont_warn) { int ret; long l; =20 ret =3D xlu_cfg_get_long(cfg, n, &l, dont_warn); if (ret) return ret; - libxl_defbool_set(b, !!l); + libxl_defbool_set(value_r, !!l); return 0; } =20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011683014595.5668628132036; Wed, 2 Aug 2023 14:28:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575436.901167 (Exim 4.92) (envelope-from ) id 1qRJNd-0008DV-Rm; Wed, 02 Aug 2023 21:27:41 +0000 Received: by outflank-mailman (output) from mailman id 575436.901167; Wed, 02 Aug 2023 21:27:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJNd-0008DE-MB; Wed, 02 Aug 2023 21:27:41 +0000 Received: by outflank-mailman (input) for mailman id 575436; Wed, 02 Aug 2023 21:27:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJE7-0001jm-EO for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:17:51 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 08349857-317a-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:17:49 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LHc3i008327 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:17:43 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LHcDt008326; Wed, 2 Aug 2023 14:17:38 -0700 (PDT) (envelope-from ehem) 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: 08349857-317a-11ee-8613-37d641c3527e Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Wed, 12 Jul 2023 23:29:59 -0700 Subject: [PATCH 02/22] tools/utils: rename "n" arguments to "key" X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011683956100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Hopefully make it clearer to others this is the key associated with the storage value to retrieve. Signed-off-by: Elliott Mitchell --- tools/include/libxlutil.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/include/libxlutil.h b/tools/include/libxlutil.h index fcbe41b15a..0ce66c2096 100644 --- a/tools/include/libxlutil.h +++ b/tools/include/libxlutil.h @@ -56,24 +56,24 @@ void xlu_cfg_destroy(XLU_Config *cfg); * ERANGE value out of range (from strtol) */ =20 -int xlu_cfg_get_string(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_string(const XLU_Config *cfg, const char *key, const char **value_r, int dont_warn); /* free/strdup version */ -int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, +int xlu_cfg_replace_string(const XLU_Config *cfg, const char *key, char **value_r, int dont_warn); -int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, long *value_r, +int xlu_cfg_get_long(const XLU_Config *cfg, const char *key, long *value_r, int dont_warn); -int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n, long mi= n, +int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *key, long = min, long max, long *value_r, int dont_warn); -int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *key, libxl_defbool *value_r, int dont_warn); =20 -int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_list(const XLU_Config *cfg, const char *key, XLU_ConfigList **list_r /* may be 0 */, int *entries_r /* may be 0 */, int dont_warn); /* there is no need to free *list_r; lifetime is that of the XLU_Config = */ -int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *key, libxl_string_list *sl, int dont_warn); const char *xlu_cfg_get_listitem(const XLU_ConfigList *list, int entry); /* xlu_cfg_get_listitem cannot fail, except that if entry is --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011139367916.5612983856142; Wed, 2 Aug 2023 14:18:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575281.901073 (Exim 4.92) (envelope-from ) id 1qRJEv-0002w9-Sc; Wed, 02 Aug 2023 21:18:41 +0000 Received: by outflank-mailman (output) from mailman id 575281.901073; Wed, 02 Aug 2023 21:18:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJEv-0002w2-PK; Wed, 02 Aug 2023 21:18:41 +0000 Received: by outflank-mailman (input) for mailman id 575281; Wed, 02 Aug 2023 21:18:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJEu-0002vw-Gn for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:18:40 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 25e12516-317a-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:18:39 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LIUvV008334 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:18:36 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LIUPs008333; Wed, 2 Aug 2023 14:18:30 -0700 (PDT) (envelope-from ehem) 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: 25e12516-317a-11ee-b263-6b7b168915f2 Message-Id: <2d87776c7cf9637f10cade3de5c9dcd3d1c96931.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Wed, 26 Jul 2023 21:09:21 -0700 Subject: [PATCH 03/22] tools/utils: remove old declaration of xlu__cfg_yyparse() X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011139548100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This was added at b104c3762dc. Appears this was fixed in the intervening decade. Otherwise this could have been an issue from using advanced features of Bison. Now this appears unnecessary. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg_i.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/libs/util/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h index 4217f5b28d..3717b9460c 100644 --- a/tools/libs/util/libxlu_cfg_i.h +++ b/tools/libs/util/libxlu_cfg_i.h @@ -42,12 +42,6 @@ void xlu__cfgl_lexicalerror(CfgParseContext*, char const= *msg); =20 void xlu__cfgl_likely_python(CfgParseContext *ctx); =20 - - -/* Why oh why does bison not declare this in its autogenerated .h ? */ -int xlu__cfg_yyparse(CfgParseContext *ctx); - - #endif /*LIBXLU_CFG_I_H*/ =20 /* --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011197427827.3070800242481; Wed, 2 Aug 2023 14:19:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575297.901082 (Exim 4.92) (envelope-from ) id 1qRJFm-0003UB-4Y; Wed, 02 Aug 2023 21:19:34 +0000 Received: by outflank-mailman (output) from mailman id 575297.901082; Wed, 02 Aug 2023 21:19:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJFm-0003U4-1l; Wed, 02 Aug 2023 21:19:34 +0000 Received: by outflank-mailman (input) for mailman id 575297; Wed, 02 Aug 2023 21:19:32 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJFk-0003Tu-Br for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:19:32 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 44d95d70-317a-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:19:31 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LJMDH008355 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:19:27 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LJMYx008354; Wed, 2 Aug 2023 14:19:22 -0700 (PDT) (envelope-from ehem) 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: 44d95d70-317a-11ee-b263-6b7b168915f2 Message-Id: <3aa2df31a341c97d0cc21b1837233446ff1d48c2.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Thu, 27 Jul 2023 14:43:15 -0700 Subject: [PATCH 04/22] tools/utils: enable all Bison warnings X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011199637100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Warnings from Bison seem less likely to be urgent, but on general principle enable everything. Signed-off-by: Elliott Mitchell --- tools/libs/util/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libs/util/Makefile b/tools/libs/util/Makefile index c3b21875dc..d2c90ced69 100644 --- a/tools/libs/util/Makefile +++ b/tools/libs/util/Makefile @@ -50,7 +50,7 @@ $(OBJS-y) $(PIC_OBJS): libxlu_cfg_l.c libxlu_cfg_y.c libx= lu_disk_l.c =20 %.c %.h:: %.y @rm -f $*.[ch] - $(BISON) --output=3D$*.c $< + $(BISON) -Wall --output=3D$*.c $< =20 %.c %.h:: %.l @rm -f $*.[ch] --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011679885962.7359722193962; Wed, 2 Aug 2023 14:27:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575421.901136 (Exim 4.92) (envelope-from ) id 1qRJNb-0007Sv-0f; Wed, 02 Aug 2023 21:27:39 +0000 Received: by outflank-mailman (output) from mailman id 575421.901136; Wed, 02 Aug 2023 21:27:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJNa-0007Sj-TH; Wed, 02 Aug 2023 21:27:38 +0000 Received: by outflank-mailman (input) for mailman id 575421; Wed, 02 Aug 2023 21:27:37 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJGb-0003L7-Jc for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:20:25 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 64102d71-317a-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:20:23 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LKEVN008367 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:20:19 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LKE6T008366; Wed, 2 Aug 2023 14:20:14 -0700 (PDT) (envelope-from ehem) 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: 64102d71-317a-11ee-8613-37d641c3527e Message-Id: <6a645ebcf70c46df5a3ce0d8539d1108d9927d19.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Sat, 29 Jul 2023 16:04:18 -0700 Subject: [PATCH 05/22] tools/utils: update Bison parser directives X-Spam-Status: No, score=0.4 required=10.0 tests=KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011680800100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Update per Bison's obsolete warnings. Testing indicates these are simple and safe. Signed-off-by: Elliott Mitchell --- Someone check for acceptable Bison versions? I'm testing with Flex 2.6.4 and Bison 3.7.5. --- tools/libs/util/libxlu_cfg_y.y | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index 020fc63eb3..e53d8ed337 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -28,9 +28,9 @@ } =20 %locations -%pure-parser +%define api.pure %defines -%error-verbose +%define parse.error verbose %name-prefix "xlu__cfg_yy" %parse-param { CfgParseContext *ctx } %lex-param { ctx_scanner } @@ -48,7 +48,7 @@ file: stmts | stmts assignment =20 -stmts: /* empty */ +stmts: %empty | stmts stmt =20 stmt: assignment endstmt @@ -67,13 +67,12 @@ value: atom { $$=3D xlu__cfg_s= tring_mk(ctx,$1,&@1); } atom: STRING { $$=3D $1; } | NUMBER { $$=3D $1; } =20 -valuelist: /* empty */ { $$=3D xlu__cfg_list_mk(ctx,NULL,&yylloc= ); } +valuelist: %empty { $$=3D xlu__cfg_list_mk(ctx,NULL,&yylloc)= ; } | values { $$=3D $1; } | values ',' nlok { $$=3D $1; } =20 values: value nlok { $$=3D xlu__cfg_list_mk(ctx,$1,&@1); } | values ',' nlok value nlok { xlu__cfg_list_append(ctx,$1,$4); $$= =3D $1; } =20 -nlok: - /* nothing */ +nlok: %empty | nlok NEWLINE --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011294690185.79873632319357; Wed, 2 Aug 2023 14:21:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575318.901093 (Exim 4.92) (envelope-from ) id 1qRJHS-0004vc-FR; Wed, 02 Aug 2023 21:21:18 +0000 Received: by outflank-mailman (output) from mailman id 575318.901093; Wed, 02 Aug 2023 21:21:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJHS-0004vV-C7; Wed, 02 Aug 2023 21:21:18 +0000 Received: by outflank-mailman (input) for mailman id 575318; Wed, 02 Aug 2023 21:21:17 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJHR-0004vP-NF for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:21:17 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 83949012-317a-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:21:16 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LL7DC008373 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:21:12 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LL6lp008372; Wed, 2 Aug 2023 14:21:06 -0700 (PDT) (envelope-from ehem) 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: 83949012-317a-11ee-b263-6b7b168915f2 Message-Id: <07d4758b3ce8b3680c7b0107329033925832a15d.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 22:02:48 -0700 Subject: [PATCH 06/22] tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011294950100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The upper layer disk string parser doesn't need the internals of the lower layer file parser. Split the layers apart. This looks to have been a copy&paste issue. Fixes: 5c206536ad ("libxl: disks: new xlu_disk_parse function") Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_disk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/libs/util/libxlu_disk.c b/tools/libs/util/libxlu_disk.c index 1de16a6a06..e94f4d06cd 100644 --- a/tools/libs/util/libxlu_disk.c +++ b/tools/libs/util/libxlu_disk.c @@ -1,7 +1,6 @@ #include "libxlu_internal.h" #include "libxlu_disk_l.h" #include "libxlu_disk_i.h" -#include "libxlu_cfg_i.h" =20 void xlu__disk_err(DiskParseContext *dpc, const char *erroneous, const char *message) { --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011349915207.01727097239927; Wed, 2 Aug 2023 14:22:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575335.901103 (Exim 4.92) (envelope-from ) id 1qRJIJ-0005Ul-Ow; Wed, 02 Aug 2023 21:22:11 +0000 Received: by outflank-mailman (output) from mailman id 575335.901103; Wed, 02 Aug 2023 21:22:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJIJ-0005Ue-M5; Wed, 02 Aug 2023 21:22:11 +0000 Received: by outflank-mailman (input) for mailman id 575335; Wed, 02 Aug 2023 21:22:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJII-0005Ie-Kh for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:22:10 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a2aa3667-317a-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:22:08 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LLxep008383 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:22:05 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LLx0F008382; Wed, 2 Aug 2023 14:21:59 -0700 (PDT) (envelope-from ehem) 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: a2aa3667-317a-11ee-8613-37d641c3527e Message-Id: <39785555d883fa43b03423e68964bd21f92e791a.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Fri, 28 Jul 2023 12:10:14 -0700 Subject: [PATCH 07/22] tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011350298100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Bison has added the ability to emit declarations in its header. As such everything can instead be dumped in Bison's header instead of having a private one. This resolves the mixed up situation with the libxlu headers. Problem is libxlu_cfg_i.h was trying to function as a wrapper for libxlu_cfg_y.h. Issue is libxlu_cfg.c's #include order didn't match and thus everything was fragile. Fixes: b104c3762d ('Replace config file parser for "xl"') Signed-off-by: Elliott Mitchell --- The bug @b104c3762d was the incorrect ordering of #includes in libxlu_cfg.c. It should instead have been: #include "libxlu_cfg_i.h" #include "libxlu_cfg_l.h" Had this bug not been present, later commits might have looked deeper and chosen correct solutions. Instead this resulted in all the ripples which this series fixes. I'm unsure whether Bison had implemented the %code feature by this point in time. The one and a half remaining issues are whether to convert the %{ %} section to %code and move it after the %union. The %union construct ends up in libxlu_cfg_y.h, whereas the %{ %}/%code construct ends up in libxlu_cfg_y.c. --- tools/libs/util/libxlu_cfg.c | 1 - tools/libs/util/libxlu_cfg_i.h | 53 ---------------------------------- tools/libs/util/libxlu_cfg_l.l | 2 +- tools/libs/util/libxlu_cfg_y.y | 29 ++++++++++++++++++- 4 files changed, 29 insertions(+), 56 deletions(-) delete mode 100644 tools/libs/util/libxlu_cfg_i.h diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 87ac8c4b41..7e9eec550d 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -22,7 +22,6 @@ #include "libxlu_internal.h" #include "libxlu_cfg_y.h" #include "libxlu_cfg_l.h" -#include "libxlu_cfg_i.h" =20 XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { XLU_Config *cfg; diff --git a/tools/libs/util/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h deleted file mode 100644 index 3717b9460c..0000000000 --- a/tools/libs/util/libxlu_cfg_i.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * libxlu_cfg_i.h - xl configuration file parsing: parser-internal declara= tions - * - * Copyright (C) 2010 Citrix Ltd. - * Author Ian Jackson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; version 2.1 only. with the special - * exception on linking described in file LICENSE. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - */ - -#ifndef LIBXLU_CFG_I_H -#define LIBXLU_CFG_I_H - -#include "libxlu_internal.h" -#include "libxlu_cfg_y.h" - -void xlu__cfg_set_free(XLU_ConfigSetting *set); -void xlu__cfg_set_store(CfgParseContext*, char *name, - enum XLU_Operation op, - XLU_ConfigValue *val, int lineno); -XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, - char *atom, YYLTYPE *loc); -XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, - XLU_ConfigValue *val, - YYLTYPE *loc); -void xlu__cfg_list_append(CfgParseContext *ctx, - XLU_ConfigValue *list, - XLU_ConfigValue *val); -void xlu__cfg_value_free(XLU_ConfigValue *value); -char *xlu__cfgl_strdup(CfgParseContext*, const char *src); -char *xlu__cfgl_dequote(CfgParseContext*, const char *src); - -void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg); -void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg); - -void xlu__cfgl_likely_python(CfgParseContext *ctx); - -#endif /*LIBXLU_CFG_I_H*/ - -/* - * Local variables: - * mode: C - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/tools/libs/util/libxlu_cfg_l.l b/tools/libs/util/libxlu_cfg_l.l index 390d6e2c2b..ba023fd679 100644 --- a/tools/libs/util/libxlu_cfg_l.l +++ b/tools/libs/util/libxlu_cfg_l.l @@ -17,7 +17,7 @@ */ =20 %{ -#include "libxlu_cfg_i.h" +#include "libxlu_cfg_y.h" =20 #define ctx ((CfgParseContext*)yyextra) #define YY_NO_INPUT diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index e53d8ed337..e796066941 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -16,9 +16,36 @@ * GNU Lesser General Public License for more details. */ =20 +%code requires { +#include "libxlu_internal.h" +} + +%code provides { +void xlu__cfg_set_free(XLU_ConfigSetting *set); +void xlu__cfg_set_store(CfgParseContext*, char *name, + enum XLU_Operation op, + XLU_ConfigValue *val, int lineno); +XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, + char *atom, YYLTYPE *loc); +XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, + XLU_ConfigValue *val, + YYLTYPE *loc); +void xlu__cfg_list_append(CfgParseContext *ctx, + XLU_ConfigValue *list, + XLU_ConfigValue *val); +void xlu__cfg_value_free(XLU_ConfigValue *value); +char *xlu__cfgl_strdup(CfgParseContext*, const char *src); +char *xlu__cfgl_dequote(CfgParseContext*, const char *src); + +void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg); +void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg); + +void xlu__cfgl_likely_python(CfgParseContext *ctx); +} + %{ #define ctx_scanner ctx->scanner -#include "libxlu_cfg_i.h" +#include "libxlu_cfg_y.h" #include "libxlu_cfg_l.h" %} =20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169101168549835.80069363740745; Wed, 2 Aug 2023 14:28:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575423.901141 (Exim 4.92) (envelope-from ) id 1qRJNb-0007V6-A5; Wed, 02 Aug 2023 21:27:39 +0000 Received: by outflank-mailman (output) from mailman id 575423.901141; Wed, 02 Aug 2023 21:27:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJNb-0007Tn-3h; Wed, 02 Aug 2023 21:27:39 +0000 Received: by outflank-mailman (input) for mailman id 575423; Wed, 02 Aug 2023 21:27:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJJ7-0004vP-OS for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:23:01 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c1bf85c8-317a-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:23:01 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LMpRt008400 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:22:57 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LMphh008399; Wed, 2 Aug 2023 14:22:51 -0700 (PDT) (envelope-from ehem) 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: c1bf85c8-317a-11ee-b263-6b7b168915f2 Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Sat, 29 Jul 2023 17:03:47 -0700 Subject: [PATCH 08/22] tools/utils: Bison: switch from name-prefix to api.prefix X-Spam-Status: No, score=0.4 required=10.0 tests=KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011686798100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bison -Wall declares %name-prefix deprecated. The suggested replacement is "api.prefix". "api.prefix" though effects rather a lot more places than %name-prefix does. As a result, rename YYLTYPE/YYSTYPE to match. As a quick workaround #define YYLTYPE/YYSTYPE to convince flex to interface correctly. Signed-off-by: Elliott Mitchell --- According to the documentation api.prefix was introduced in Bison 2.6, while braces became recommended with Bison 3.0. This seems sufficiently in the past to be worth adopting now. A better workaround for flex is needed. --- tools/libs/util/libxlu_cfg.c | 9 +++++---- tools/libs/util/libxlu_cfg_y.y | 13 +++++++++---- tools/libs/util/libxlu_internal.h | 8 ++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 7e9eec550d..20534343f4 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -388,7 +388,7 @@ const char *xlu_cfg_get_listitem(const XLU_ConfigList *= list, int entry) { =20 =20 XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom, - YYLTYPE *loc) + XLU__CFG_YYLTYPE *loc) { XLU_ConfigValue *value =3D NULL; =20 @@ -412,7 +412,7 @@ XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ct= x, char *atom, =20 XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, XLU_ConfigValue *val, - YYLTYPE *loc) + XLU__CFG_YYLTYPE *loc) { XLU_ConfigValue *value =3D NULL; XLU_ConfigValue **values =3D NULL; @@ -667,13 +667,14 @@ char *xlu__cfgl_dequote(CfgParseContext *ctx, const c= har *src) { } =20 void xlu__cfgl_lexicalerror(CfgParseContext *ctx, char const *msg) { - YYLTYPE loc; + XLU__CFG_YYLTYPE loc; loc.first_line=3D xlu__cfg_yyget_lineno(ctx->scanner); xlu__cfg_yyerror(&loc, ctx, msg); ctx->lexerrlineno=3D loc.first_line; } =20 -void xlu__cfg_yyerror(YYLTYPE *loc, CfgParseContext *ctx, char const *msg)= { +void xlu__cfg_yyerror(XLU__CFG_YYLTYPE *loc, CfgParseContext *ctx, + char const *msg) { const char *text, *newline; int len, lineno; =20 diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index e796066941..adbb74ff11 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -26,10 +26,10 @@ void xlu__cfg_set_store(CfgParseContext*, char *name, enum XLU_Operation op, XLU_ConfigValue *val, int lineno); XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, - char *atom, YYLTYPE *loc); + char *atom, XLU__CFG_YYLTYPE *loc); XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, XLU_ConfigValue *val, - YYLTYPE *loc); + XLU__CFG_YYLTYPE *loc); void xlu__cfg_list_append(CfgParseContext *ctx, XLU_ConfigValue *list, XLU_ConfigValue *val); @@ -37,10 +37,15 @@ void xlu__cfg_value_free(XLU_ConfigValue *value); char *xlu__cfgl_strdup(CfgParseContext*, const char *src); char *xlu__cfgl_dequote(CfgParseContext*, const char *src); =20 -void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg); +void xlu__cfg_yyerror(XLU__CFG_YYLTYPE *locp, CfgParseContext*, + char const *msg); void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg); =20 void xlu__cfgl_likely_python(CfgParseContext *ctx); + +/* issue of name-prefix versus api.prefix and Flex Bison-bridge */ +#define YYLTYPE XLU__CFG_YYLTYPE +#define YYSTYPE XLU__CFG_YYSTYPE } =20 %{ @@ -58,7 +63,7 @@ void xlu__cfgl_likely_python(CfgParseContext *ctx); %define api.pure %defines %define parse.error verbose -%name-prefix "xlu__cfg_yy" +%define api.prefix {xlu__cfg_yy} %parse-param { CfgParseContext *ctx } %lex-param { ctx_scanner } =20 diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 1f7559ecd9..01fe073069 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -31,14 +31,14 @@ struct XLU_ConfigList { XLU_ConfigValue **values; }; =20 -typedef struct YYLTYPE +typedef struct XLU__CFG_YYLTYPE { int first_line; int first_column; int last_line; int last_column; -} YYLTYPE; -#define YYLTYPE_IS_DECLARED +} XLU__CFG_YYLTYPE; +#define XLU__CFG_YYLTYPE_IS_DECLARED =20 struct XLU_ConfigValue { enum XLU_ConfigValueType type; @@ -46,7 +46,7 @@ struct XLU_ConfigValue { char *string; XLU_ConfigList list; } u; - YYLTYPE loc; + XLU__CFG_YYLTYPE loc; }; =20 typedef struct XLU_ConfigSetting { /* transparent */ --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011454184756.3305550578033; Wed, 2 Aug 2023 14:24:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575359.901116 (Exim 4.92) (envelope-from ) id 1qRJK0-000680-5P; Wed, 02 Aug 2023 21:23:56 +0000 Received: by outflank-mailman (output) from mailman id 575359.901116; Wed, 02 Aug 2023 21:23:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJK0-00067t-2j; Wed, 02 Aug 2023 21:23:56 +0000 Received: by outflank-mailman (input) for mailman id 575359; Wed, 02 Aug 2023 21:23:55 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJJz-00067Z-5k for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:23:55 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e0e72bc8-317a-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:23:53 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LNhnU008407 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:23:49 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LNhDC008406; Wed, 2 Aug 2023 14:23:43 -0700 (PDT) (envelope-from ehem) 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: e0e72bc8-317a-11ee-8613-37d641c3527e Message-Id: <58041bfb2a8ce9a54a337a2293c5094c119f7390.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Wed, 26 Jul 2023 21:56:32 -0700 Subject: [PATCH 09/22] tools/utils: move CfgParseContext to top of libxlu_cfg_y.y X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011456278100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The CfgParseContext structure/typedef is used inside the parser. Whereas most #include's of libxlu_internal.h need the common declarations, not the parser internals. Due to this, the structure should be near the top of libxlu_cfg_y.h (libxlu_cfg_i.h @b104c3762d), and not towards the middle of libxlu_internal.h. Fixes: b104c3762d ('Replace config file parser for "xl"') Signed-off-by: Elliott Mitchell --- Ideally at @b104c3762d Bison might already have implemented its %code feature. Less ideal, but workable CfgParseContext should have been placed in libxlu_cfg_i.h, between the two #includes: #include "libxlu_internal.h" typedef struct { } CfgParseContext; #include "libxlu_cfg_y.h" Using Bison's %code feature is rather superior though. This patch is where indentation in Bison.y files becomes crucial. I'm unsure of the call to make, so I've left this as cut&paste which means this will almost certainly change. --- tools/libs/util/libxlu_cfg_y.y | 6 ++++++ tools/libs/util/libxlu_internal.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index adbb74ff11..75e7140478 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -18,6 +18,12 @@ =20 %code requires { #include "libxlu_internal.h" + +typedef struct { + XLU_Config *cfg; + int err, lexerrlineno, likely_python; + void *scanner; +} CfgParseContext; } =20 %code provides { diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 01fe073069..246ad0bde7 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -63,12 +63,6 @@ struct XLU_Config { char *config_source; }; =20 -typedef struct { - XLU_Config *cfg; - int err, lexerrlineno, likely_python; - void *scanner; -} CfgParseContext; - =20 #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011502934122.63753036695971; Wed, 2 Aug 2023 14:25:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575374.901126 (Exim 4.92) (envelope-from ) id 1qRJKq-0006l8-IS; Wed, 02 Aug 2023 21:24:48 +0000 Received: by outflank-mailman (output) from mailman id 575374.901126; Wed, 02 Aug 2023 21:24:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJKq-0006l1-Fn; Wed, 02 Aug 2023 21:24:48 +0000 Received: by outflank-mailman (input) for mailman id 575374; Wed, 02 Aug 2023 21:24:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJKo-00067Z-UA for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:24:46 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ffe0de99-317a-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:24:45 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LOZ04008420 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:24:41 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LOZN1008419; Wed, 2 Aug 2023 14:24:35 -0700 (PDT) (envelope-from ehem) 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: ffe0de99-317a-11ee-8613-37d641c3527e Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 16:31:34 -0700 Subject: [PATCH 10/22] tools/utils: move XLU_ConfigSetting to libxl_cfg.c X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011504422100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" XLU_ConfigSetting is only used inside libxl_cfg.c, so no need for it in the internal header. Keep the type definition in libxlu_internal.h as the incomplete definition is needed for xlu__cfg_set_free(). There is no longer any need for XLU_ConfigSetting to be transparent. Fixes: b104c3762d, 1a09c5113a ("libxlu: rework internal representation of s= etting") Signed-off-by: Elliott Mitchell --- @1a09c5113a deeper probing should have been done and figured out everything needed to move to libxlu_cfg_i.h. Making use of %code would have been better, but moving would have been sufficient. Note: If the decision is made to keep libxlu_cfg.c intact, then the type definition should be in libxlu_cfg_y.y/libxlu_cfg_y.h. --- tools/libs/util/libxlu_cfg.c | 8 ++++++++ tools/libs/util/libxlu_internal.h | 8 +------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 20534343f4..2ad58d4240 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -23,6 +23,14 @@ #include "libxlu_cfg_y.h" #include "libxlu_cfg_l.h" =20 +struct XLU_ConfigSetting { + struct XLU_ConfigSetting *next; + char *name; + XLU_ConfigValue *value; + enum XLU_Operation op; + int lineno; +}; + XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { XLU_Config *cfg; =20 diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 246ad0bde7..bf1827ea73 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -49,13 +49,7 @@ struct XLU_ConfigValue { XLU__CFG_YYLTYPE loc; }; =20 -typedef struct XLU_ConfigSetting { /* transparent */ - struct XLU_ConfigSetting *next; - char *name; - XLU_ConfigValue *value; - enum XLU_Operation op; - int lineno; -} XLU_ConfigSetting; +typedef struct XLU_ConfigSetting XLU_ConfigSetting; =20 struct XLU_Config { XLU_ConfigSetting *settings; --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011680719673.2881957204266; Wed, 2 Aug 2023 14:28:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575426.901147 (Exim 4.92) (envelope-from ) id 1qRJNb-0007YR-KB; Wed, 02 Aug 2023 21:27:39 +0000 Received: by outflank-mailman (output) from mailman id 575426.901147; Wed, 02 Aug 2023 21:27:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJNb-0007WQ-Bz; Wed, 02 Aug 2023 21:27:39 +0000 Received: by outflank-mailman (input) for mailman id 575426; Wed, 02 Aug 2023 21:27:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJLe-0004vP-1G for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:25:38 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1ef7b072-317b-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:25:37 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LPSkE008432 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:25:33 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LPS4R008431; Wed, 2 Aug 2023 14:25:28 -0700 (PDT) (envelope-from ehem) 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: 1ef7b072-317b-11ee-b263-6b7b168915f2 Message-Id: <22cd5f8f7d7d7c54a1a02a36bcd32c88632c6dbb.1690990427.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 23:07:20 -0700 Subject: [PATCH 11/22] tools/utils: move XLU_ConfigValue to libxl_cfg.c X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011681943100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At no point was the complete type for XLU_ConfigValue used anywhere besides libxlu_cfg.c, overdue for a move. Fixes: 1a09c5113a ("libxlu: rework internal representation of setting") Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg.c | 9 +++++++++ tools/libs/util/libxlu_internal.h | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 2ad58d4240..d3b5c86ed6 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -31,6 +31,15 @@ struct XLU_ConfigSetting { int lineno; }; =20 +struct XLU_ConfigValue { + enum XLU_ConfigValueType type; + union { + char *string; + XLU_ConfigList list; + } u; + XLU__CFG_YYLTYPE loc; +}; + XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { XLU_Config *cfg; =20 diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index bf1827ea73..1a9d25e14e 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -40,15 +40,6 @@ typedef struct XLU__CFG_YYLTYPE } XLU__CFG_YYLTYPE; #define XLU__CFG_YYLTYPE_IS_DECLARED =20 -struct XLU_ConfigValue { - enum XLU_ConfigValueType type; - union { - char *string; - XLU_ConfigList list; - } u; - XLU__CFG_YYLTYPE loc; -}; - typedef struct XLU_ConfigSetting XLU_ConfigSetting; =20 struct XLU_Config { --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011679586519.7083934279431; Wed, 2 Aug 2023 14:27:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575437.901171 (Exim 4.92) (envelope-from ) id 1qRJNe-0008G6-7X; Wed, 02 Aug 2023 21:27:42 +0000 Received: by outflank-mailman (output) from mailman id 575437.901171; Wed, 02 Aug 2023 21:27:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJNe-0008Ew-0h; Wed, 02 Aug 2023 21:27:42 +0000 Received: by outflank-mailman (input) for mailman id 575437; Wed, 02 Aug 2023 21:27:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJMU-0004vP-FI for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:26:30 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3e3e1e12-317b-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:26:29 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LQKx1008439 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:26:26 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LQKN6008438; Wed, 2 Aug 2023 14:26:20 -0700 (PDT) (envelope-from ehem) 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: 3e3e1e12-317b-11ee-b263-6b7b168915f2 Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 23:07:20 -0700 Subject: [PATCH 12/22] tools/utils: remove YYLTYPE definition from libxlu_internal.h X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011680037100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The definition was needed due to XLU_ConfigValue being before Bison's declaration of YYLTYPE. Since XLU_ConfigValue has moved to libxlu_cfg.c, the duplication is now unnecessary. Fixes: 1a09c5113a, 6ec86e91c8 ("libxlu: record location when parsing values= ") Signed-off-by: Elliott Mitchell --- Had @1a09c5113a placed the structure definition in libxlu_cfg_i.h, there never would have been a need to override YYLTYPE. --- tools/libs/util/libxlu_internal.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 1a9d25e14e..c68669c3a1 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -31,15 +31,6 @@ struct XLU_ConfigList { XLU_ConfigValue **values; }; =20 -typedef struct XLU__CFG_YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} XLU__CFG_YYLTYPE; -#define XLU__CFG_YYLTYPE_IS_DECLARED - typedef struct XLU_ConfigSetting XLU_ConfigSetting; =20 struct XLU_Config { --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012274610581.6302687554079; Wed, 2 Aug 2023 14:37:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575654.901266 (Exim 4.92) (envelope-from ) id 1qRJXK-00070e-64; Wed, 02 Aug 2023 21:37:42 +0000 Received: by outflank-mailman (output) from mailman id 575654.901266; Wed, 02 Aug 2023 21:37:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJXK-00070T-2D; Wed, 02 Aug 2023 21:37:42 +0000 Received: by outflank-mailman (input) for mailman id 575654; Wed, 02 Aug 2023 21:37:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJNK-0004vP-G1 for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:27:22 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5d25a01e-317b-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:27:21 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LRCsJ008463 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:27:18 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LRCav008462; Wed, 2 Aug 2023 14:27:12 -0700 (PDT) (envelope-from ehem) 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: 5d25a01e-317b-11ee-b263-6b7b168915f2 Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 23:07:20 -0700 Subject: [PATCH 13/22] tools/utils: move XLU_ConfigList to libxl_cfg.c X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012274768100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With XLU_ConfigValue now in libxlu_cfg.c, XLU_ConfigList can follow. Fixes: 1a09c5113a ("libxlu: rework internal representation of setting") Signed-off-by: Elliott Mitchell --- Placing XLU_ConfigValue/XLU_ConfigList in libxlu_internal.h was certainly *wrong*. --- tools/libs/util/libxlu_cfg.c | 6 ++++++ tools/libs/util/libxlu_internal.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index d3b5c86ed6..67d1a8123f 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -31,6 +31,12 @@ struct XLU_ConfigSetting { int lineno; }; =20 +struct XLU_ConfigList { + int avalues; /* available slots */ + int nvalues; /* actual occupied slots */ + XLU_ConfigValue **values; +}; + struct XLU_ConfigValue { enum XLU_ConfigValueType type; union { diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index c68669c3a1..310e2145a7 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -25,12 +25,6 @@ =20 #include "libxlutil.h" =20 -struct XLU_ConfigList { - int avalues; /* available slots */ - int nvalues; /* actual occupied slots */ - XLU_ConfigValue **values; -}; - typedef struct XLU_ConfigSetting XLU_ConfigSetting; =20 struct XLU_Config { --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012259656163.8948681569491; Wed, 2 Aug 2023 14:37:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575608.901245 (Exim 4.92) (envelope-from ) id 1qRJX2-00063n-Mm; Wed, 02 Aug 2023 21:37:24 +0000 Received: by outflank-mailman (output) from mailman id 575608.901245; Wed, 02 Aug 2023 21:37:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJX2-00063e-Jf; Wed, 02 Aug 2023 21:37:24 +0000 Received: by outflank-mailman (input) for mailman id 575608; Wed, 02 Aug 2023 21:37:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJOE-0004vP-Mr for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:28:18 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7c87010a-317b-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:28:14 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LS4dU008489 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:28:10 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LS4M9008488; Wed, 2 Aug 2023 14:28:04 -0700 (PDT) (envelope-from ehem) 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: 7c87010a-317b-11ee-b263-6b7b168915f2 Message-Id: <7c33609a299bcec685b9a77becd73abefbb9d237.1690990428.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Thu, 13 Jul 2023 19:01:19 -0700 Subject: [PATCH 14/22] tools/utils: introduce xlu_cfg_printf() function X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012261777100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Isolate the lower layer configuration handling from the upper layer. Now only the lowest layer of configuration handling looks inside XLU_Config. Also make error messages a bit more consistent. Now PCI device parsing will report filename. Replace the XLU__PCI_ERR() with xlu_cfg_printf(). The new function encompasses the full functionality of the macro. Signed-off-by: Elliott Mitchell --- Someone else can decide where xlu__disk_err() should have its linebreaks and indentation. That string isn't very good. I'm wondering about the return codes. *printf() can return errors, but so many places are ignoring them. If the output is a console the errors are fairly unlikely, but full storage does happen. --- tools/libs/util/libxlu_cfg.c | 23 +++++++++++++++++++++++ tools/libs/util/libxlu_disk.c | 14 +++++--------- tools/libs/util/libxlu_internal.h | 4 ++++ tools/libs/util/libxlu_pci.c | 11 ++++------- tools/libs/util/libxlu_vif.c | 4 +--- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 67d1a8123f..e37f84829f 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -18,6 +18,7 @@ #define _GNU_SOURCE =20 #include +#include =20 #include "libxlu_internal.h" #include "libxlu_cfg_y.h" @@ -191,6 +192,28 @@ void xlu_cfg_destroy(XLU_Config *cfg) { free(cfg); } =20 +int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...) +{ + va_list args; + int ret; + + if (!cfg || !cfg->report) + return EFAULT; + + ret =3D fputs(cfg->config_source, cfg->report); + if (ret < 0) + return -errno; + ret =3D fputc(':', cfg->report); + if (ret < 0) + return -errno; + + va_start(args, format); + ret =3D vfprintf(cfg->report, format, args); + va_end(args); + + return -errno; +} + static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) { XLU_ConfigSetting *set; =20 diff --git a/tools/libs/util/libxlu_disk.c b/tools/libs/util/libxlu_disk.c index e94f4d06cd..8728c9e133 100644 --- a/tools/libs/util/libxlu_disk.c +++ b/tools/libs/util/libxlu_disk.c @@ -4,13 +4,10 @@ =20 void xlu__disk_err(DiskParseContext *dpc, const char *erroneous, const char *message) { - fprintf(dpc->cfg->report, - "%s: config parsing error in disk specification: %s" - "%s%s%s" - " in `%s'\n", - dpc->cfg->config_source, message, - erroneous?": near `":"", erroneous?erroneous:"", erroneous?"'"= :"", - dpc->spec); + xlu_cfg_printf(dpc->cfg, + " config parsing error in disk specification: %s%s%s%s in `%s'= \n", + message, erroneous?": near `":"", erroneous?erroneous:"", + erroneous?"'":"", dpc->spec); if (!dpc->err) dpc->err=3D EINVAL; } =20 @@ -28,8 +25,7 @@ static int dpc_prep(DiskParseContext *dpc, const char *sp= ec) { return 0; =20 fail: - fprintf(dpc->cfg->report, "cannot init disk scanner: %s\n", - strerror(errno)); + xlu_cfg_printf(dpc->cfg, " cannot init disk scanner: %s\n", strerror(e= rrno)); return e; } =20 diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 310e2145a7..214ebe5f48 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -37,6 +37,10 @@ struct XLU_Config { #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) =20 + +extern int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...) + __attribute__((__format__(__printf__, 2, 3))); + #endif /*LIBXLU_INTERNAL_H*/ =20 /* diff --git a/tools/libs/util/libxlu_pci.c b/tools/libs/util/libxlu_pci.c index 294482c6d7..1f75317428 100644 --- a/tools/libs/util/libxlu_pci.c +++ b/tools/libs/util/libxlu_pci.c @@ -5,9 +5,6 @@ #include "libxlu_internal.h" =20 =20 -#define XLU__PCI_ERR(_c, _x, _a...) \ - if((_c) && (_c)->report) fprintf((_c)->report, _x, ##_a) - static int parse_bdf(libxl_device_pci *pci, const char *str, const char **= endp) { const char *ptr =3D str; @@ -129,7 +126,7 @@ static int parse_rdm_policy(XLU_Config *cfg, libxl_rdm_= reserve_policy *policy, int ret =3D libxl_rdm_reserve_policy_from_string(str, policy); =20 if (ret) - XLU__PCI_ERR(cfg, "Unknown RDM policy: %s", str); + xlu_cfg_printf(cfg, " Unknown RDM policy: %s", str); =20 return ret; } @@ -193,7 +190,7 @@ int xlu_pci_parse_spec_string(XLU_Config *cfg, libxl_de= vice_pci *pci, pci->name =3D strdup(val); if (!pci->name) ret =3D ERROR_NOMEM; } else { - XLU__PCI_ERR(cfg, "Unknown PCI_SPEC_STRING option: %s", key); + xlu_cfg_printf(cfg, " Unknown PCI_SPEC_STRING option: %s", key= ); ret =3D ERROR_INVAL; } =20 @@ -233,7 +230,7 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *r= dm, const char *str) } else if (!strcmp(tok, "policy")) { state =3D STATE_RESERVE_POLICY; } else { - XLU__PCI_ERR(cfg, "Unknown RDM state option: %s", tok); + xlu_cfg_printf(cfg, " Unknown RDM state option: %s", t= ok); goto parse_error; } tok =3D ptr + 1; @@ -246,7 +243,7 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *r= dm, const char *str) if (!strcmp(tok, "host")) { rdm->strategy =3D LIBXL_RDM_RESERVE_STRATEGY_HOST; } else { - XLU__PCI_ERR(cfg, "Unknown RDM strategy option: %s", t= ok); + xlu_cfg_printf(cfg, " Unknown RDM strategy option: %s"= , tok); goto parse_error; } tok =3D ptr + 1; diff --git a/tools/libs/util/libxlu_vif.c b/tools/libs/util/libxlu_vif.c index ccf0cbdf57..8331010550 100644 --- a/tools/libs/util/libxlu_vif.c +++ b/tools/libs/util/libxlu_vif.c @@ -6,9 +6,7 @@ static const char *vif_bytes_per_sec_re =3D "^[0-9]+[GMK]?[= Bb]/s$"; static const char *vif_internal_usec_re =3D "^[0-9]+[mu]?s?$"; =20 static void xlu__vif_err(XLU_Config *cfg, const char *msg, const char *rat= e) { - fprintf(cfg->report, - "%s: config parsing error in vif: %s in `%s'\n", - cfg->config_source, msg, rate); + xlu_cfg_printf(cfg, " config parsing error in vif: %s in `%s'\n", msg,= rate); } =20 static int vif_parse_rate_bytes_per_sec(XLU_Config *cfg, const char *bytes, --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011763442179.5024508621865; Wed, 2 Aug 2023 14:29:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575503.901186 (Exim 4.92) (envelope-from ) id 1qRJP2-0001pQ-Iz; Wed, 02 Aug 2023 21:29:08 +0000 Received: by outflank-mailman (output) from mailman id 575503.901186; Wed, 02 Aug 2023 21:29:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJP2-0001pH-F2; Wed, 02 Aug 2023 21:29:08 +0000 Received: by outflank-mailman (input) for mailman id 575503; Wed, 02 Aug 2023 21:29:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJP2-0001nP-0O for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:29:08 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9b7a40ad-317b-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:29:06 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LSusM008502 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:29:02 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LSusJ008501; Wed, 2 Aug 2023 14:28:56 -0700 (PDT) (envelope-from ehem) 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: 9b7a40ad-317b-11ee-8613-37d641c3527e Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Thu, 13 Jul 2023 19:01:19 -0700 Subject: [PATCH 15/22] tools/utils: move XLU_Config to libxlu_cfg.c X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011764090100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Only the lowest layer of configuration handling looks inside XLU_Config. As such the structure can move to this header instead of the shared header. Mark ->config_source as constant. Most places it truly is constant, only the free() violates the constant. Signed-off-by: Elliott Mitchell --- This could also move to libxlu_cfg_y.h and make preserving messages easier while allowing libxlu_cfg.c to split. --- tools/libs/util/libxlu_cfg.c | 8 +++++++- tools/libs/util/libxlu_internal.h | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index e37f84829f..69b95a4ed0 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -47,6 +47,12 @@ struct XLU_ConfigValue { XLU__CFG_YYLTYPE loc; }; =20 +struct XLU_Config { + XLU_ConfigSetting *settings; + FILE *report; + const char *config_source; +}; + XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { XLU_Config *cfg; =20 @@ -188,7 +194,7 @@ void xlu_cfg_destroy(XLU_Config *cfg) { set_next=3D set->next; xlu__cfg_set_free(set); } - free(cfg->config_source); + free((void *)cfg->config_source); free(cfg); } =20 diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 214ebe5f48..93caf24a6e 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -27,12 +27,6 @@ =20 typedef struct XLU_ConfigSetting XLU_ConfigSetting; =20 -struct XLU_Config { - XLU_ConfigSetting *settings; - FILE *report; - char *config_source; -}; - =20 #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012285476279.53014598081995; Wed, 2 Aug 2023 14:38:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575686.901276 (Exim 4.92) (envelope-from ) id 1qRJXQ-0007Uu-Em; Wed, 02 Aug 2023 21:37:48 +0000 Received: by outflank-mailman (output) from mailman id 575686.901276; Wed, 02 Aug 2023 21:37:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJXQ-0007Un-B4; Wed, 02 Aug 2023 21:37:48 +0000 Received: by outflank-mailman (input) for mailman id 575686; Wed, 02 Aug 2023 21:37:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJPq-0002A0-N2 for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:29:58 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ba56475f-317b-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:29:58 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LTmp6008512 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:29:54 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LTm1g008511; Wed, 2 Aug 2023 14:29:48 -0700 (PDT) (envelope-from ehem) 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: ba56475f-317b-11ee-b263-6b7b168915f2 Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Sun, 9 Jul 2023 16:06:30 -0700 Subject: [PATCH 16/22] tools/utils: move XLU_Operation to libxlu_cfg_y.h X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012286845100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This enumerated value is never used outside of the lowest layer of the configuration parser. As such, move to the internal header. Fixes: a30910bfd7 ("libxlu: Handle +=3D in config files") Signed-off-by: Elliott Mitchell --- I'm unsure whether this is fixing a30910bfd7. Placing XLU_Operation in libxlutil.h was certainly erroneous, but it is quite unlikely to directly result in actual bugs. --- tools/include/libxlutil.h | 5 ----- tools/libs/util/libxlu_cfg_y.y | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/include/libxlutil.h b/tools/include/libxlutil.h index 0ce66c2096..de57ca4200 100644 --- a/tools/include/libxlutil.h +++ b/tools/include/libxlutil.h @@ -25,11 +25,6 @@ enum XLU_ConfigValueType { XLU_LIST, }; =20 -enum XLU_Operation { - XLU_OP_ASSIGNMENT =3D 0, - XLU_OP_ADDITION, -}; - /* Unless otherwise stated, all functions return an errno value. */ typedef struct XLU_Config XLU_Config; typedef struct XLU_ConfigList XLU_ConfigList; diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index 75e7140478..5dfb06941a 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -27,6 +27,11 @@ typedef struct { } =20 %code provides { +enum XLU_Operation { + XLU_OP_ASSIGNMENT =3D 0, + XLU_OP_ADDITION, +}; + void xlu__cfg_set_free(XLU_ConfigSetting *set); void xlu__cfg_set_store(CfgParseContext*, char *name, enum XLU_Operation op, --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011869864165.36321564693105; Wed, 2 Aug 2023 14:31:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575537.901195 (Exim 4.92) (envelope-from ) id 1qRJQk-0003Oy-1G; Wed, 02 Aug 2023 21:30:54 +0000 Received: by outflank-mailman (output) from mailman id 575537.901195; Wed, 02 Aug 2023 21:30:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJQj-0003Or-Uk; Wed, 02 Aug 2023 21:30:53 +0000 Received: by outflank-mailman (input) for mailman id 575537; Wed, 02 Aug 2023 21:30:52 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJQi-0003Og-9l for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:30:52 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d971e1d6-317b-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:30:50 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LUerU008520 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:30:46 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LUeMk008519; Wed, 2 Aug 2023 14:30:40 -0700 (PDT) (envelope-from ehem) 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: d971e1d6-317b-11ee-8613-37d641c3527e Message-Id: <829def3bc27e138286677b95d549684b82f864f4.1690990428.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 25 Jul 2023 11:06:06 -0700 Subject: [PATCH 17/22] tools/utils: move setting free loop to xlu__cfg_set_free() X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011871912100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This better breaks layers apart. xlu_cfg_destroy() now only knows about the XLU_Config structure, while xlu__cfg_set_free() knows about XLU_ConfigSetting. Move declaration of xlu__cfg_set_free() to shared header to indicate it will bridge layers. Signed-off-by: Elliott Mitchell --- This is the end of the higher-value series. Moving the loop is appropriate whether or not libxlu_cfg.c is split. Moving the declaration and patches after this though are mostly valuable for splitting libxlu_cfg.c into reusable and non-reusable portions. --- tools/libs/util/libxlu_cfg.c | 20 ++++++++------------ tools/libs/util/libxlu_cfg_y.y | 1 - tools/libs/util/libxlu_internal.h | 5 +++++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 69b95a4ed0..7fec7fe7be 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -178,22 +178,18 @@ void xlu__cfg_value_free(XLU_ConfigValue *value) } =20 void xlu__cfg_set_free(XLU_ConfigSetting *set) { - if (!set) return; - free(set->name); - xlu__cfg_value_free(set->value); - free(set); + while(set) { + XLU_ConfigSetting *next =3D set->next; + free(set->name); + xlu__cfg_value_free(set->value); + free(set); + set =3D next; + } } =20 void xlu_cfg_destroy(XLU_Config *cfg) { - XLU_ConfigSetting *set, *set_next; - if (!cfg) return; - for (set=3D cfg->settings; - set; - set=3D set_next) { - set_next=3D set->next; - xlu__cfg_set_free(set); - } + xlu__cfg_set_free(cfg->settings); free((void *)cfg->config_source); free(cfg); } diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index 5dfb06941a..5c7e31222d 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -32,7 +32,6 @@ enum XLU_Operation { XLU_OP_ADDITION, }; =20 -void xlu__cfg_set_free(XLU_ConfigSetting *set); void xlu__cfg_set_store(CfgParseContext*, char *name, enum XLU_Operation op, XLU_ConfigValue *val, int lineno); diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 93caf24a6e..cc98efba27 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -35,6 +35,11 @@ typedef struct XLU_ConfigSetting XLU_ConfigSetting; extern int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...) __attribute__((__format__(__printf__, 2, 3))); =20 +/* + * Internals for file parser *only*, NOT to be used by other parsing/lexing + */ +extern void xlu__cfg_set_free(XLU_ConfigSetting *set); + #endif /*LIBXLU_INTERNAL_H*/ =20 /* --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691011921080824.4736285184437; Wed, 2 Aug 2023 14:32:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575560.901206 (Exim 4.92) (envelope-from ) id 1qRJRa-0003xr-A5; Wed, 02 Aug 2023 21:31:46 +0000 Received: by outflank-mailman (output) from mailman id 575560.901206; Wed, 02 Aug 2023 21:31:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJRa-0003xi-7K; Wed, 02 Aug 2023 21:31:46 +0000 Received: by outflank-mailman (input) for mailman id 575560; Wed, 02 Aug 2023 21:31:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJRZ-0003Og-5O for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:31:45 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f90ad61c-317b-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:31:43 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LVX8K008530 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:31:38 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LVXH9008529; Wed, 2 Aug 2023 14:31:33 -0700 (PDT) (envelope-from ehem) 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: f90ad61c-317b-11ee-8613-37d641c3527e Message-Id: <88fee0319d859ab9643a735bc3a3038e245afe6d.1690990428.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Wed, 19 Jul 2023 10:31:21 -0700 Subject: [PATCH 18/22] tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691011923266100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are far more printf()s inside libxlu_cfg.c, so these had been left alone briefly. Now attack all of these. Signed-off-by: Elliott Mitchell --- Note, several messages change mildly. The message in parse() didn't previously include the filename. --- tools/libs/util/libxlu_cfg.c | 78 ++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 7fec7fe7be..91e056bb33 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -78,8 +78,7 @@ static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg= ) { =20 e=3D xlu__cfg_yylex_init_extra(ctx, &ctx->scanner); if (e) { - fprintf(cfg->report,"%s: unable to create scanner: %s\n", - cfg->config_source, strerror(e)); + xlu_cfg_printf(cfg, " unable to create scanner: %s\n", strerror(e)= ); return e; } return 0; @@ -99,11 +98,12 @@ static void parse(CfgParseContext *ctx) { if (r) assert(ctx->err); =20 if (ctx->err && ctx->likely_python) { - fputs( - "warning: Config file looks like it contains Python code.\n" - "warning: Arbitrary Python is no longer supported.\n" - "warning: See https://wiki.xen.org/wiki/PythonInXlConfig\n", - ctx->cfg->report); + xlu_cfg_printf(ctx->cfg, + " warning: Config file looks like it contains Python code.\n"); + xlu_cfg_printf(ctx->cfg, + " warning: Arbitrary Python is no longer supported.\n"); + xlu_cfg_printf(ctx->cfg, + " warning: See https://wiki.xen.org/wiki/PythonInXlConfig\n"); } } =20 @@ -144,8 +144,7 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data,= int length) { =20 buf =3D xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); if (!buf) { - fprintf(cfg->report,"%s: unable to allocate scanner buffer\n", - cfg->config_source); + xlu_cfg_printf(cfg, " unable to allocate scanner buffer\n"); ctx.err=3D ENOMEM; goto xe; } @@ -236,10 +235,10 @@ static int find_atom(const XLU_Config *cfg, const cha= r *n, =20 if (set->value->type!=3DXLU_STRING) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d: warning: parameter `%s' is" + xlu_cfg_printf(cfg, + "%d: warning: parameter `%s' is" " a list but should be a single value\n", - cfg->config_source, set->lineno, n); + set->lineno, n); return EINVAL; } *set_r=3D set; @@ -257,10 +256,8 @@ int xlu_cfg_value_get_string(const XLU_Config *cfg, XL= U_ConfigValue *value, { if (value->type !=3D XLU_STRING) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d:%d: warning: value is not a string\n", - cfg->config_source, value->loc.first_line, - value->loc.first_column); + xlu_cfg_printf(cfg, "%d:%d: warning: value is not a string\n", + value->loc.first_line, value->loc.first_column); *value_r =3D NULL; return EINVAL; } @@ -274,10 +271,8 @@ int xlu_cfg_value_get_list(const XLU_Config *cfg, XLU_= ConfigValue *value, { if (value->type !=3D XLU_LIST) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d:%d: warning: value is not a list\n", - cfg->config_source, value->loc.first_line, - value->loc.first_column); + xlu_cfg_printf(cfg, "%d:%d: warning: value is not a list\n", + value->loc.first_line, value->loc.first_column); *value_r =3D NULL; return EINVAL; } @@ -325,10 +320,10 @@ int xlu_cfg_get_bounded_long(const XLU_Config *cfg, c= onst char *n, e=3D find_atom(cfg,n,&set,dont_warn); if (e) return e; if (set->op =3D=3D XLU_OP_ADDITION) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d: warning: can't use +=3D with numbers" + xlu_cfg_printf(cfg, + "%d: warning: can't use +=3D with numbers" " for parameter `%s'\n", - cfg->config_source, set->lineno, n); + set->lineno, n); return EINVAL; } errno=3D 0; l=3D strtol(set->value->u.string, &ep, 0); @@ -337,31 +332,31 @@ int xlu_cfg_get_bounded_long(const XLU_Config *cfg, c= onst char *n, e=3D errno; assert(e=3D=3DEINVAL || e=3D=3DERANGE); if (!dont_warn) - fprintf(cfg->report, - "%s:%d: warning: parameter `%s' could not be parsed" + xlu_cfg_printf(cfg, + "%d: warning: parameter `%s' could not be parsed" " as a number: %s\n", - cfg->config_source, set->lineno, n, strerror(e)); + set->lineno, n, strerror(e)); return e; } if (*ep || ep=3D=3Dset->value->u.string) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d: warning: parameter `%s' is not a valid number\= n", - cfg->config_source, set->lineno, n); + xlu_cfg_printf(cfg, + "%d: warning: parameter `%s' is not a valid number\n", + set->lineno, n); return EINVAL; } if (l < min) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d: warning: value `%ld' is smaller than minimum b= ound '%ld'\n", - cfg->config_source, set->lineno, l, min); + xlu_cfg_printf(cfg, + "%d: warning: value `%ld' is smaller than minimum boun= d '%ld'\n", + set->lineno, l, min); return EINVAL; } if (l > max) { if (!dont_warn) - fprintf(cfg->report, - "%s:%d: warning: value `%ld' is greater than maximum b= ound '%ld'\n", - cfg->config_source, set->lineno, l, max); + xlu_cfg_printf(cfg, + "%d: warning: value `%ld' is greater than maximum boun= d '%ld'\n", + set->lineno, l, max); return EINVAL; } =20 @@ -393,10 +388,10 @@ int xlu_cfg_get_list(const XLU_Config *cfg, const cha= r *n, set=3D find(cfg,n); if (!set) return ESRCH; if (set->value->type!=3DXLU_LIST) { if (!dont_warn) { - fprintf(cfg->report, - "%s:%d: warning: parameter `%s' is a single value" + xlu_cfg_printf(cfg, + "%d: warning: parameter `%s' is a single value" " but should be a list\n", - cfg->config_source, set->lineno, n); + set->lineno, n); } return EINVAL; } @@ -743,11 +738,8 @@ void xlu__cfg_yyerror(XLU__CFG_YYLTYPE *loc, CfgParseC= ontext *ctx, len--; } =20 - fprintf(ctx->cfg->report, - "%s:%d: config parsing error near %s%.*s%s%s: %s\n", - ctx->cfg->config_source, lineno, - len?"`":"", len, text, len?"'":"", newline, - msg); + xlu_cfg_printf(ctx->cfg, "%d: config parsing error near %s%.*s%s%s: %s= \n", + lineno, len?"`":"", len, text, len?"'":"", newline, msg); if (!ctx->err) ctx->err=3D EINVAL; } =20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012276552804.6702217486339; Wed, 2 Aug 2023 14:37:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575646.901257 (Exim 4.92) (envelope-from ) id 1qRJXJ-0006kv-0i; Wed, 02 Aug 2023 21:37:41 +0000 Received: by outflank-mailman (output) from mailman id 575646.901257; Wed, 02 Aug 2023 21:37:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJXI-0006ko-RQ; Wed, 02 Aug 2023 21:37:40 +0000 Received: by outflank-mailman (input) for mailman id 575646; Wed, 02 Aug 2023 21:37:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJSQ-0003Og-JX for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:32:38 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 18eeff17-317c-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:32:36 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LWPL5008540 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:32:31 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LWPo4008539; Wed, 2 Aug 2023 14:32:25 -0700 (PDT) (envelope-from ehem) 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: 18eeff17-317c-11ee-8613-37d641c3527e Message-Id: <6452c9eae533fbed7e156f71f53045fe7438174b.1690990428.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Wed, 26 Jul 2023 14:22:14 -0700 Subject: [PATCH 19/22] tools/utils: add pointer to in-progress settings to CfgParseContext X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012277061100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Rather than needing the full structure, for many operations the settings pointer is enough. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg.c | 13 ++++++++----- tools/libs/util/libxlu_cfg_y.y | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 91e056bb33..3c0703f9df 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -67,10 +67,13 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *repo= rt_source) { return cfg; } =20 -static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg) { +static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg, + XLU_ConfigSetting **psettings) +{ int e; =20 ctx->cfg=3D cfg; + ctx->psettings =3D psettings; ctx->err=3D 0; ctx->lexerrlineno=3D -1; ctx->likely_python=3D 0; @@ -112,7 +115,7 @@ int xlu_cfg_readfile(XLU_Config *cfg, const char *real_= filename) { int e; =20 CfgParseContext ctx; - e =3D ctx_prep(&ctx, cfg); + e =3D ctx_prep(&ctx, cfg, &cfg->settings); if (e) { ctx.err=3D e; goto xe; } =20 f=3D fopen(real_filename, "r"); @@ -139,7 +142,7 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data,= int length) { YY_BUFFER_STATE buf=3D 0; =20 CfgParseContext ctx; - e=3D ctx_prep(&ctx, cfg); + e =3D ctx_prep(&ctx, cfg, &cfg->settings); if (e) { ctx.err=3D e; goto xe; } =20 buf =3D xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); @@ -619,8 +622,8 @@ void xlu__cfg_set_store(CfgParseContext *ctx, char *nam= e, set->value =3D val; set->op =3D op; set->lineno=3D lineno; - set->next=3D ctx->cfg->settings; - ctx->cfg->settings=3D set; + set->next =3D *ctx->psettings; + *ctx->psettings =3D set; return; out: assert(ctx->err); diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index 5c7e31222d..5bd4cbb0ab 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -21,6 +21,7 @@ =20 typedef struct { XLU_Config *cfg; + XLU_ConfigSetting **psettings; int err, lexerrlineno, likely_python; void *scanner; } CfgParseContext; --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012285122587.019861867017; Wed, 2 Aug 2023 14:38:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575692.901286 (Exim 4.92) (envelope-from ) id 1qRJXR-0007l5-Pa; Wed, 02 Aug 2023 21:37:49 +0000 Received: by outflank-mailman (output) from mailman id 575692.901286; Wed, 02 Aug 2023 21:37:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJXR-0007kW-Iz; Wed, 02 Aug 2023 21:37:49 +0000 Received: by outflank-mailman (input) for mailman id 575692; Wed, 02 Aug 2023 21:37:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJTE-0003Og-So for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:33:28 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 36f5476d-317c-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:33:27 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LXHYp008558 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:33:23 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LXHcA008557; Wed, 2 Aug 2023 14:33:17 -0700 (PDT) (envelope-from ehem) 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: 36f5476d-317c-11ee-8613-37d641c3527e Message-Id: <52d5a8411767aa17ce0db845471ad38dd49f6594.1690990428.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 25 Jul 2023 20:26:48 -0700 Subject: [PATCH 20/22] tools/utils: add wrapper for readfile()/readdata() functions X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012285905100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These functions needs to cross the boundary between core and lower-layer. As such split them in two. Pass most of the values from XLU_Config as they can be used by the lower-layer. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg.c | 47 ++++++++++++++++++++++--------- tools/libs/util/libxlu_internal.h | 6 ++++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 3c0703f9df..cb99b0aab0 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -110,39 +110,58 @@ static void parse(CfgParseContext *ctx) { } } =20 -int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) { - FILE *f =3D 0; +int xlu_cfg_readfile(XLU_Config *cfg, const char *name) +{ + FILE *file; + int ret; + + file =3D fopen(name, "r"); + if (file) { + ret =3D xlu__cfg_readfile(cfg, cfg->report, cfg->config_source, + &cfg->settings, file, name); + fclose(file); + } else { + ret =3D errno; + fprintf(cfg->report,"%s: unable to open configuration file: %s\n", + name, strerror(ret)); + } + + return ret; +} + +int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile, const char *msgprefi= x, + XLU_ConfigSetting **psettings, FILE *f, const char *name) +{ int e; =20 CfgParseContext ctx; - e =3D ctx_prep(&ctx, cfg, &cfg->settings); + e =3D ctx_prep(&ctx, cfg, psettings); if (e) { ctx.err=3D e; goto xe; } =20 - f=3D fopen(real_filename, "r"); - if (!f) { - ctx.err =3D errno; - fprintf(cfg->report,"%s: unable to open configuration file: %s\n", - real_filename, strerror(e)); - goto xe; - } - xlu__cfg_yyrestart(f, ctx.scanner); =20 parse(&ctx); =20 xe: ctx_dispose(&ctx); - if (f) fclose(f); =20 return ctx.err; } =20 -int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { +int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) +{ + return xlu__cfg_readdata(cfg, cfg->report, cfg->config_source, + &cfg->settings, data, length); +} + +int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile, const char *msgprefi= x, + XLU_ConfigSetting **psettings, const char *data, int length) +{ int e; YY_BUFFER_STATE buf=3D 0; =20 CfgParseContext ctx; - e =3D ctx_prep(&ctx, cfg, &cfg->settings); + e =3D ctx_prep(&ctx, cfg, psettings); if (e) { ctx.err=3D e; goto xe; } =20 buf =3D xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index cc98efba27..34c6c7a443 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -39,6 +39,12 @@ extern int xlu_cfg_printf(const XLU_Config *cfg, const c= har *format, ...) * Internals for file parser *only*, NOT to be used by other parsing/lexing */ extern void xlu__cfg_set_free(XLU_ConfigSetting *set); +extern int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile, + const char *msgprefix, XLU_ConfigSetting **psettings, FILE *file, + const char *name); +extern int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile, + const char *msgprefix, XLU_ConfigSetting **psettings, const char *data, + int length); =20 #endif /*LIBXLU_INTERNAL_H*/ =20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012259782325.6909770343965; Wed, 2 Aug 2023 14:37:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575603.901237 (Exim 4.92) (envelope-from ) id 1qRJX0-0005nx-GS; Wed, 02 Aug 2023 21:37:22 +0000 Received: by outflank-mailman (output) from mailman id 575603.901237; Wed, 02 Aug 2023 21:37:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJX0-0005nq-C3; Wed, 02 Aug 2023 21:37:22 +0000 Received: by outflank-mailman (input) for mailman id 575603; Wed, 02 Aug 2023 21:37:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJU4-0003Og-Oi for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:34:20 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 55ed6a32-317c-11ee-8613-37d641c3527e; Wed, 02 Aug 2023 23:34:19 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LY9lp008578 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:34:15 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LY9Dr008577; Wed, 2 Aug 2023 14:34:09 -0700 (PDT) (envelope-from ehem) 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: 55ed6a32-317c-11ee-8613-37d641c3527e Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 25 Jul 2023 20:11:06 -0700 Subject: [PATCH 21/22] tools/utils: add settings get function X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012260855100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The better to isolate the shared portion of the interface from the low-level implementation. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg.c | 7 ++++++- tools/libs/util/libxlu_internal.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index cb99b0aab0..7bbedde8f6 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -240,7 +240,7 @@ int xlu_cfg_printf(const XLU_Config *cfg, const char *f= ormat, ...) static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) { XLU_ConfigSetting *set; =20 - for (set=3D cfg->settings; + for (set =3D xlu__cfg_get_settings(cfg); set; set=3D set->next) if (!strcmp(set->name, n)) @@ -267,6 +267,11 @@ static int find_atom(const XLU_Config *cfg, const char= *n, return 0; } =20 +XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg) +{ + return cfg->settings; +} + =20 enum XLU_ConfigValueType xlu_cfg_value_type(const XLU_ConfigValue *value) { diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 34c6c7a443..993ff88171 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -45,6 +45,8 @@ extern int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfi= le, extern int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile, const char *msgprefix, XLU_ConfigSetting **psettings, const char *data, int length); +extern XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg) + __attribute__((access(read_only, 1))); =20 #endif /*LIBXLU_INTERNAL_H*/ =20 --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445 From nobody Thu May 9 12:34:21 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691012140017151.046640171861; Wed, 2 Aug 2023 14:35:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.575578.901226 (Exim 4.92) (envelope-from ) id 1qRJUx-00059N-WD; Wed, 02 Aug 2023 21:35:16 +0000 Received: by outflank-mailman (output) from mailman id 575578.901226; Wed, 02 Aug 2023 21:35:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJUx-00059G-TI; Wed, 02 Aug 2023 21:35:15 +0000 Received: by outflank-mailman (input) for mailman id 575578; Wed, 02 Aug 2023 21:35:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qRJUw-00059A-Mu for xen-devel@lists.xenproject.org; Wed, 02 Aug 2023 21:35:14 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 75fc2764-317c-11ee-b263-6b7b168915f2; Wed, 02 Aug 2023 23:35:12 +0200 (CEST) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 372LZ28o008587 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 2 Aug 2023 17:35:07 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 372LZ2Ae008586; Wed, 2 Aug 2023 14:35:02 -0700 (PDT) (envelope-from ehem) 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: 75fc2764-317c-11ee-b263-6b7b168915f2 Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 25 Jul 2023 15:50:14 -0700 Subject: [PATCH 22/22] tools/utils: break flex/bison parser away from main config file X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1691012140383100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Potentially allowing a different parser to be substituted. Omit libxlu_internal.h from libxlu_cfg_i.c, since it is kept in libxlu_cfg_y.h. Signed-off-by: Elliott Mitchell --- tools/libs/util/Makefile | 1 + tools/libs/util/libxlu_cfg.c | 662 ------------------ .../util/{libxlu_cfg.c =3D> libxlu_cfg_i.c} | 87 --- 3 files changed, 1 insertion(+), 749 deletions(-) copy tools/libs/util/{libxlu_cfg.c =3D> libxlu_cfg_i.c} (90%) diff --git a/tools/libs/util/Makefile b/tools/libs/util/Makefile index d2c90ced69..bfca15b9b5 100644 --- a/tools/libs/util/Makefile +++ b/tools/libs/util/Makefile @@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk =20 OBJS-y +=3D libxlu_cfg_y.o OBJS-y +=3D libxlu_cfg_l.o +OBJS-y +=3D libxlu_cfg_i.o OBJS-y +=3D libxlu_cfg.o OBJS-y +=3D libxlu_disk_l.o OBJS-y +=3D libxlu_disk.o diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 7bbedde8f6..040d3ea914 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -21,31 +21,6 @@ #include =20 #include "libxlu_internal.h" -#include "libxlu_cfg_y.h" -#include "libxlu_cfg_l.h" - -struct XLU_ConfigSetting { - struct XLU_ConfigSetting *next; - char *name; - XLU_ConfigValue *value; - enum XLU_Operation op; - int lineno; -}; - -struct XLU_ConfigList { - int avalues; /* available slots */ - int nvalues; /* actual occupied slots */ - XLU_ConfigValue **values; -}; - -struct XLU_ConfigValue { - enum XLU_ConfigValueType type; - union { - char *string; - XLU_ConfigList list; - } u; - XLU__CFG_YYLTYPE loc; -}; =20 struct XLU_Config { XLU_ConfigSetting *settings; @@ -67,49 +42,6 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *repor= t_source) { return cfg; } =20 -static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg, - XLU_ConfigSetting **psettings) -{ - int e; - - ctx->cfg=3D cfg; - ctx->psettings =3D psettings; - ctx->err=3D 0; - ctx->lexerrlineno=3D -1; - ctx->likely_python=3D 0; - ctx->scanner=3D 0; - - e=3D xlu__cfg_yylex_init_extra(ctx, &ctx->scanner); - if (e) { - xlu_cfg_printf(cfg, " unable to create scanner: %s\n", strerror(e)= ); - return e; - } - return 0; -} - -static void ctx_dispose(CfgParseContext *ctx) { - if (ctx->scanner) xlu__cfg_yylex_destroy(ctx->scanner); -} - -static void parse(CfgParseContext *ctx) { - /* On return, ctx.err will be updated with the error status. */ - int r; - - xlu__cfg_yyset_lineno(1, ctx->scanner); - - r=3D xlu__cfg_yyparse(ctx); - if (r) assert(ctx->err); - - if (ctx->err && ctx->likely_python) { - xlu_cfg_printf(ctx->cfg, - " warning: Config file looks like it contains Python code.\n"); - xlu_cfg_printf(ctx->cfg, - " warning: Arbitrary Python is no longer supported.\n"); - xlu_cfg_printf(ctx->cfg, - " warning: See https://wiki.xen.org/wiki/PythonInXlConfig\n"); - } -} - int xlu_cfg_readfile(XLU_Config *cfg, const char *name) { FILE *file; @@ -129,85 +61,12 @@ int xlu_cfg_readfile(XLU_Config *cfg, const char *name) return ret; } =20 -int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile, const char *msgprefi= x, - XLU_ConfigSetting **psettings, FILE *f, const char *name) -{ - int e; - - CfgParseContext ctx; - e =3D ctx_prep(&ctx, cfg, psettings); - if (e) { ctx.err=3D e; goto xe; } - - xlu__cfg_yyrestart(f, ctx.scanner); - - parse(&ctx); - - xe: - ctx_dispose(&ctx); - - return ctx.err; -} - int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { return xlu__cfg_readdata(cfg, cfg->report, cfg->config_source, &cfg->settings, data, length); } =20 -int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile, const char *msgprefi= x, - XLU_ConfigSetting **psettings, const char *data, int length) -{ - int e; - YY_BUFFER_STATE buf=3D 0; - - CfgParseContext ctx; - e =3D ctx_prep(&ctx, cfg, psettings); - if (e) { ctx.err=3D e; goto xe; } - - buf =3D xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); - if (!buf) { - xlu_cfg_printf(cfg, " unable to allocate scanner buffer\n"); - ctx.err=3D ENOMEM; - goto xe; - } - - parse(&ctx); - - xe: - if (buf) xlu__cfg_yy_delete_buffer(buf, ctx.scanner); - ctx_dispose(&ctx); - - return ctx.err; -} - -void xlu__cfg_value_free(XLU_ConfigValue *value) -{ - int i; - - if (!value) return; - - switch (value->type) { - case XLU_STRING: - free(value->u.string); - break; - case XLU_LIST: - for (i =3D 0; i < value->u.list.nvalues; i++) - xlu__cfg_value_free(value->u.list.values[i]); - free(value->u.list.values); - } - free(value); -} - -void xlu__cfg_set_free(XLU_ConfigSetting *set) { - while(set) { - XLU_ConfigSetting *next =3D set->next; - free(set->name); - xlu__cfg_value_free(set->value); - free(set); - set =3D next; - } -} - void xlu_cfg_destroy(XLU_Config *cfg) { if (!cfg) return; xlu__cfg_set_free(cfg->settings); @@ -237,539 +96,18 @@ int xlu_cfg_printf(const XLU_Config *cfg, const char = *format, ...) return -errno; } =20 -static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) { - XLU_ConfigSetting *set; - - for (set =3D xlu__cfg_get_settings(cfg); - set; - set=3D set->next) - if (!strcmp(set->name, n)) - return set; - return 0; -} - -static int find_atom(const XLU_Config *cfg, const char *n, - XLU_ConfigSetting **set_r, int dont_warn) { - XLU_ConfigSetting *set; - - set=3D find(cfg,n); - if (!set) return ESRCH; - - if (set->value->type!=3DXLU_STRING) { - if (!dont_warn) - xlu_cfg_printf(cfg, - "%d: warning: parameter `%s' is" - " a list but should be a single value\n", - set->lineno, n); - return EINVAL; - } - *set_r=3D set; - return 0; -} - XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg) { return cfg->settings; } =20 =20 -enum XLU_ConfigValueType xlu_cfg_value_type(const XLU_ConfigValue *value) -{ - return value->type; -} - -int xlu_cfg_value_get_string(const XLU_Config *cfg, XLU_ConfigValue *value, - char **value_r, int dont_warn) -{ - if (value->type !=3D XLU_STRING) { - if (!dont_warn) - xlu_cfg_printf(cfg, "%d:%d: warning: value is not a string\n", - value->loc.first_line, value->loc.first_column); - *value_r =3D NULL; - return EINVAL; - } - - *value_r =3D value->u.string; - return 0; -} - -int xlu_cfg_value_get_list(const XLU_Config *cfg, XLU_ConfigValue *value, - XLU_ConfigList **value_r, int dont_warn) -{ - if (value->type !=3D XLU_LIST) { - if (!dont_warn) - xlu_cfg_printf(cfg, "%d:%d: warning: value is not a list\n", - value->loc.first_line, value->loc.first_column); - *value_r =3D NULL; - return EINVAL; - } - - *value_r =3D &value->u.list; - return 0; -} - -XLU_ConfigValue *xlu_cfg_get_listitem2(const XLU_ConfigList *list, - int entry) -{ - if (entry < 0 || entry >=3D list->nvalues) return NULL; - return list->values[entry]; -} - -int xlu_cfg_get_string(const XLU_Config *cfg, const char *n, - const char **value_r, int dont_warn) { - XLU_ConfigSetting *set; - int e; - - e=3D find_atom(cfg,n,&set,dont_warn); if (e) return e; - *value_r=3D set->value->u.string; - return 0; -} - -int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, - char **value_r, int dont_warn) { - XLU_ConfigSetting *set; - int e; - - e=3D find_atom(cfg,n,&set,dont_warn); if (e) return e; - free(*value_r); - *value_r=3D strdup(set->value->u.string); - return 0; -} - -int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n, - long min, long max, long *value_r, - int dont_warn) { - long l; - XLU_ConfigSetting *set; - int e; - char *ep; - - e=3D find_atom(cfg,n,&set,dont_warn); if (e) return e; - if (set->op =3D=3D XLU_OP_ADDITION) { - if (!dont_warn) - xlu_cfg_printf(cfg, - "%d: warning: can't use +=3D with numbers" - " for parameter `%s'\n", - set->lineno, n); - return EINVAL; - } - errno=3D 0; l=3D strtol(set->value->u.string, &ep, 0); - e=3D errno; - if (errno) { - e=3D errno; - assert(e=3D=3DEINVAL || e=3D=3DERANGE); - if (!dont_warn) - xlu_cfg_printf(cfg, - "%d: warning: parameter `%s' could not be parsed" - " as a number: %s\n", - set->lineno, n, strerror(e)); - return e; - } - if (*ep || ep=3D=3Dset->value->u.string) { - if (!dont_warn) - xlu_cfg_printf(cfg, - "%d: warning: parameter `%s' is not a valid number\n", - set->lineno, n); - return EINVAL; - } - if (l < min) { - if (!dont_warn) - xlu_cfg_printf(cfg, - "%d: warning: value `%ld' is smaller than minimum boun= d '%ld'\n", - set->lineno, l, min); - return EINVAL; - } - if (l > max) { - if (!dont_warn) - xlu_cfg_printf(cfg, - "%d: warning: value `%ld' is greater than maximum boun= d '%ld'\n", - set->lineno, l, max); - return EINVAL; - } - - *value_r=3D l; - return 0; -} - int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, long *value_r, int dont_warn) { return xlu_cfg_get_bounded_long(cfg, n, LONG_MIN, LONG_MAX, value_r, dont_warn); } =20 -int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, - libxl_defbool *value_r, int dont_warn) -{ - int ret; - long l; - - ret =3D xlu_cfg_get_long(cfg, n, &l, dont_warn); - if (ret) return ret; - libxl_defbool_set(value_r, !!l); - return 0; -} - -int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, - XLU_ConfigList **list_r, int *entries_r, int dont_war= n) { - XLU_ConfigSetting *set; - set=3D find(cfg,n); if (!set) return ESRCH; - if (set->value->type!=3DXLU_LIST) { - if (!dont_warn) { - xlu_cfg_printf(cfg, - "%d: warning: parameter `%s' is a single value" - " but should be a list\n", - set->lineno, n); - } - return EINVAL; - } - if (list_r) *list_r=3D &set->value->u.list; - if (entries_r) *entries_r=3D set->value->u.list.nvalues; - return 0; -} - -int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, - libxl_string_list *psl, int dont_warn) { - int i, rc, nr; - XLU_ConfigList *list; - libxl_string_list sl; - - rc =3D xlu_cfg_get_list(cfg, n, &list, &nr, dont_warn); - if (rc) return rc; - - sl =3D malloc(sizeof(char*)*(nr + 1)); - if (sl =3D=3D NULL) return ENOMEM; - - for (i=3D0; i=3D list->nvalues) return 0; - if (list->values[entry]->type !=3D XLU_STRING) return 0; - return list->values[entry]->u.string; -} - - -XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom, - XLU__CFG_YYLTYPE *loc) -{ - XLU_ConfigValue *value =3D NULL; - - if (ctx->err) goto x; - - value =3D malloc(sizeof(*value)); - if (!value) goto xe; - value->type =3D XLU_STRING; - value->u.string =3D atom; - memcpy(&value->loc, loc, sizeof(*loc)); - - return value; - - xe: - ctx->err=3D errno; - x: - free(value); - free(atom); - return NULL; -} - -XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx, - XLU_ConfigValue *val, - XLU__CFG_YYLTYPE *loc) -{ - XLU_ConfigValue *value =3D NULL; - XLU_ConfigValue **values =3D NULL; - - if (ctx->err) goto x; - - values =3D malloc(sizeof(*values)); - if (!values) goto xe; - values[0] =3D val; - - value =3D malloc(sizeof(*value)); - if (!value) goto xe; - value->type =3D XLU_LIST; - value->u.list.nvalues =3D !!val; - value->u.list.avalues =3D 1; - value->u.list.values =3D values; - memcpy(&value->loc, loc, sizeof(*loc)); - - return value; - - xe: - ctx->err=3D errno; - x: - free(value); - free(values); - xlu__cfg_value_free(val); - return NULL; -} - -void xlu__cfg_list_append(CfgParseContext *ctx, - XLU_ConfigValue *list, - XLU_ConfigValue *val) -{ - if (ctx->err) return; - - assert(val); - assert(list->type =3D=3D XLU_LIST); - - if (list->u.list.nvalues >=3D list->u.list.avalues) { - int new_avalues; - XLU_ConfigValue **new_values =3D NULL; - - if (list->u.list.avalues > INT_MAX / 100) { - ctx->err =3D ERANGE; - xlu__cfg_value_free(val); - return; - } - - new_avalues =3D list->u.list.avalues * 4; - new_values =3D realloc(list->u.list.values, - sizeof(*new_values) * new_avalues); - if (!new_values) { - ctx->err =3D errno; - xlu__cfg_value_free(val); - return; - } - - list->u.list.avalues =3D new_avalues; - list->u.list.values =3D new_values; - } - - list->u.list.values[list->u.list.nvalues] =3D val; - list->u.list.nvalues++; -} - -static int xlu__cfg_concat_vals(CfgParseContext *ctx, - XLU_ConfigValue *prev, - XLU_ConfigValue *to_add) -{ - int r; - - if (prev->type !=3D to_add->type) { - xlu__cfgl_lexicalerror(ctx, - "can't add [list] to \"string\" or vice versa"); - return EINVAL; - } - - switch (to_add->type) { - case XLU_STRING: { - char *new_string =3D NULL; - - r =3D asprintf(&new_string, "%s%s", prev->u.string, - to_add->u.string); - if (r < 0) { - return errno; - } - free(to_add->u.string); - to_add->u.string =3D new_string; - return 0; - } - case XLU_LIST: { - XLU_ConfigList *const prev_list =3D &prev->u.list; - XLU_ConfigList *const cur_list =3D &to_add->u.list; - int nvalues; - - if (prev->u.list.nvalues > INT_MAX - to_add->u.list.nvalues) { - return ERANGE; - } - nvalues =3D prev->u.list.nvalues + to_add->u.list.nvalues; - - if (nvalues >=3D cur_list->avalues) { - XLU_ConfigValue **new_vals; - new_vals =3D realloc(cur_list->values, - nvalues * sizeof(*new_vals)); - if (!new_vals) { - return ENOMEM; - } - cur_list->avalues =3D nvalues; - cur_list->values =3D new_vals; - } - - /* make space for `prev' into `to_add' */ - memmove(cur_list->values + prev_list->nvalues, - cur_list->values, - cur_list->nvalues * sizeof(XLU_ConfigValue *)); - /* move values from `prev' to `to_add' as the list in `prev' will - * not be reachable by find(). */ - memcpy(cur_list->values, - prev_list->values, - prev_list->nvalues * sizeof(XLU_ConfigValue *)); - cur_list->nvalues =3D nvalues; - prev_list->nvalues =3D 0; - memset(prev_list->values, 0, - prev_list->nvalues * sizeof(XLU_ConfigValue *)); - return 0; - } - default: - abort(); - } - return -1; -} - -void xlu__cfg_set_store(CfgParseContext *ctx, char *name, - enum XLU_Operation op, - XLU_ConfigValue *val, int lineno) { - XLU_ConfigSetting *set; - int r; - - if (ctx->err) goto out; - - assert(name); - - if (op =3D=3D XLU_OP_ADDITION) { - /* If we have +=3D concatenate with previous value with same name = */ - XLU_ConfigSetting *prev_set =3D find(ctx->cfg, name); - if (prev_set) { - r =3D xlu__cfg_concat_vals(ctx, prev_set->value, val); - if (r) { - ctx->err =3D r; - goto out; - } - } - } - - set =3D malloc(sizeof(*set)); - if (!set) { - ctx->err =3D errno; - goto out; - } - set->name=3D name; - set->value =3D val; - set->op =3D op; - set->lineno=3D lineno; - set->next =3D *ctx->psettings; - *ctx->psettings =3D set; - return; -out: - assert(ctx->err); - free(name); - xlu__cfg_value_free(val); -} - -char *xlu__cfgl_strdup(CfgParseContext *ctx, const char *src) { - char *result; - - if (ctx->err) return 0; - result=3D strdup(src); - if (!result) ctx->err=3D errno; - return result; -} - -char *xlu__cfgl_dequote(CfgParseContext *ctx, const char *src) { - char *result; - const char *p; - char *q; - int len, c, nc; - - if (ctx->err) return 0; - - len=3D strlen(src); - assert(len>=3D2 && src[0]=3D=3Dsrc[len-1]); - - result=3D malloc(len-1); - if (!result) { ctx->err=3D errno; return 0; } - - q=3D result; - - for (p=3D src+1; - p < src+len-1; - ) { - c=3D *p++; - if (c=3D=3D'\\') { - assert(p < src+len-1); - nc=3D *p++; - if (nc=3D=3D'"' || nc=3D=3D'\'' || nc=3D=3D'\\') { - *q++=3D nc; - } else if (nc=3D=3D'a') { *q++=3D '\007'; - } else if (nc=3D=3D'b') { *q++=3D '\010'; - } else if (nc=3D=3D'f') { *q++=3D '\014'; - } else if (nc=3D=3D'n') { *q++=3D '\n'; - } else if (nc=3D=3D'r') { *q++=3D '\r'; - } else if (nc=3D=3D't') { *q++=3D '\t'; - } else if (nc=3D=3D'v') { *q++=3D '\013'; - } else if (nc=3D=3D'x') { - -#define NUMERIC_CHAR(minlen,maxlen,base,basetext) do{ = \ - char numbuf[(maxlen)+1], *ep; = \ - unsigned long val; = \ - = \ - strncpy(numbuf,p,(maxlen)); = \ - numbuf[(maxlen)]=3D 0; = \ - val=3D strtoul(numbuf, &ep, (base)); = \ - if (ep <=3D numbuf+(minlen)) { = \ - xlu__cfgl_lexicalerror(ctx,"invalid digit after" = \ - " backslash " basetext "numerical character escap= e" \ - " in quoted string"); = \ - ctx->err=3D EINVAL; = \ - goto x; = \ - } = \ - p +=3D (ep - numbuf); = \ - }while(0) - - p++; - NUMERIC_CHAR(2,2,16,"hex"); - } else if (nc>=3D'0' && nc<=3D'7') { - NUMERIC_CHAR(1,3,10,"octal"); - } else { - xlu__cfgl_lexicalerror(ctx, - "invalid character after backlash in quoted str= ing"); - ctx->err=3D EINVAL; - goto x; - } - assert(p <=3D src+len-1); - } else { - *q++=3D c; - } - } - - x: - *q++=3D 0; - return result; -} - -void xlu__cfgl_lexicalerror(CfgParseContext *ctx, char const *msg) { - XLU__CFG_YYLTYPE loc; - loc.first_line=3D xlu__cfg_yyget_lineno(ctx->scanner); - xlu__cfg_yyerror(&loc, ctx, msg); - ctx->lexerrlineno=3D loc.first_line; -} - -void xlu__cfg_yyerror(XLU__CFG_YYLTYPE *loc, CfgParseContext *ctx, - char const *msg) { - const char *text, *newline; - int len, lineno; - - lineno=3D loc->first_line; - if (lineno <=3D ctx->lexerrlineno) return; - - text=3D xlu__cfg_yyget_text(ctx->scanner); - len=3D xlu__cfg_yyget_leng(ctx->scanner); - newline=3D ""; - if (len>0 && text[len-1]=3D=3D'\n') { - len--; - lineno--; - if (!len) { - newline=3D ""; - } - } - while (len>0 && (text[len-1]=3D=3D'\t' || text[len-1]=3D=3D' ')) { - len--; - } - - xlu_cfg_printf(ctx->cfg, "%d: config parsing error near %s%.*s%s%s: %s= \n", - lineno, len?"`":"", len, text, len?"'":"", newline, msg); - if (!ctx->err) ctx->err=3D EINVAL; -} - /* * Local variables: * mode: C diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg_i.c similarity index 90% copy from tools/libs/util/libxlu_cfg.c copy to tools/libs/util/libxlu_cfg_i.c index 7bbedde8f6..bf5890b273 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg_i.c @@ -20,7 +20,6 @@ #include #include =20 -#include "libxlu_internal.h" #include "libxlu_cfg_y.h" #include "libxlu_cfg_l.h" =20 @@ -47,26 +46,6 @@ struct XLU_ConfigValue { XLU__CFG_YYLTYPE loc; }; =20 -struct XLU_Config { - XLU_ConfigSetting *settings; - FILE *report; - const char *config_source; -}; - -XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { - XLU_Config *cfg; - - cfg=3D malloc(sizeof(*cfg)); - if (!cfg) return 0; - - cfg->report=3D report; - cfg->config_source=3D strdup(report_source); - if (!cfg->config_source) { free(cfg); return 0; } - - cfg->settings=3D 0; - return cfg; -} - static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg, XLU_ConfigSetting **psettings) { @@ -110,25 +89,6 @@ static void parse(CfgParseContext *ctx) { } } =20 -int xlu_cfg_readfile(XLU_Config *cfg, const char *name) -{ - FILE *file; - int ret; - - file =3D fopen(name, "r"); - if (file) { - ret =3D xlu__cfg_readfile(cfg, cfg->report, cfg->config_source, - &cfg->settings, file, name); - fclose(file); - } else { - ret =3D errno; - fprintf(cfg->report,"%s: unable to open configuration file: %s\n", - name, strerror(ret)); - } - - return ret; -} - int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile, const char *msgprefi= x, XLU_ConfigSetting **psettings, FILE *f, const char *name) { @@ -148,12 +108,6 @@ int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile, = const char *msgprefix, return ctx.err; } =20 -int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) -{ - return xlu__cfg_readdata(cfg, cfg->report, cfg->config_source, - &cfg->settings, data, length); -} - int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile, const char *msgprefi= x, XLU_ConfigSetting **psettings, const char *data, int length) { @@ -208,35 +162,6 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set) { } } =20 -void xlu_cfg_destroy(XLU_Config *cfg) { - if (!cfg) return; - xlu__cfg_set_free(cfg->settings); - free((void *)cfg->config_source); - free(cfg); -} - -int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...) -{ - va_list args; - int ret; - - if (!cfg || !cfg->report) - return EFAULT; - - ret =3D fputs(cfg->config_source, cfg->report); - if (ret < 0) - return -errno; - ret =3D fputc(':', cfg->report); - if (ret < 0) - return -errno; - - va_start(args, format); - ret =3D vfprintf(cfg->report, format, args); - va_end(args); - - return -errno; -} - static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) { XLU_ConfigSetting *set; =20 @@ -267,11 +192,6 @@ static int find_atom(const XLU_Config *cfg, const char= *n, return 0; } =20 -XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg) -{ - return cfg->settings; -} - =20 enum XLU_ConfigValueType xlu_cfg_value_type(const XLU_ConfigValue *value) { @@ -391,12 +311,6 @@ int xlu_cfg_get_bounded_long(const XLU_Config *cfg, co= nst char *n, return 0; } =20 -int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, - long *value_r, int dont_warn) { - return xlu_cfg_get_bounded_long(cfg, n, LONG_MIN, LONG_MAX, value_r, - dont_warn); -} - int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, libxl_defbool *value_r, int dont_warn) { @@ -456,7 +370,6 @@ const char *xlu_cfg_get_listitem(const XLU_ConfigList *= list, int entry) { return list->values[entry]->u.string; } =20 - XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom, XLU__CFG_YYLTYPE *loc) { --=20 (\___(\___(\______ --=3D> 8-) EHM <=3D-- ______/)___/)___= /) \BS ( | ehem+sigmsg@m5p.com PGP 87145445 | ) / \_CS\ | _____ -O #include O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445