All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 16/22] tools/utils: move XLU_Operation to libxlu_cfg_y.h
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
@ 2023-07-09 23:06 ` Elliott Mitchell
  2023-07-10 22:55 ` [PATCH 01/22] tools/utils: cleanup formatting of libxlutil.h Elliott Mitchell
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-09 23:06 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 += in config files")
Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
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,
 };
 
-enum XLU_Operation {
-    XLU_OP_ASSIGNMENT = 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 {
 }
 
 %code provides {
+enum XLU_Operation {
+    XLU_OP_ASSIGNMENT = 0,
+    XLU_OP_ADDITION,
+};
+
 void xlu__cfg_set_free(XLU_ConfigSetting *set);
 void xlu__cfg_set_store(CfgParseContext*, char *name,
                         enum XLU_Operation op,
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 01/22] tools/utils: cleanup formatting of libxlutil.h
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
  2023-07-09 23:06 ` [PATCH 16/22] tools/utils: move XLU_Operation to libxlu_cfg_y.h Elliott Mitchell
@ 2023-07-10 22:55 ` Elliott Mitchell
  2023-07-13  6:29 ` [PATCH 02/22] tools/utils: rename "n" arguments to "key" Elliott Mitchell
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-10 22:55 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
 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 *report_filename);
   /* report_filename is copied; report is saved and must remain valid
    *  until the Config is destroyed. */
 
-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. */
 
-void xlu_cfg_destroy(XLU_Config*);
+void xlu_cfg_destroy(XLU_Config *cfg);
 
 
 /* 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)
  */
 
-int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **value_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 min,
                              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);
 
-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) */
 
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 char *n,
                                     dont_warn);
 }
 
-int xlu_cfg_get_defbool(const XLU_Config *cfg, 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)
 {
     int ret;
     long l;
 
     ret = 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;
 }
 
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 02/22] tools/utils: rename "n" arguments to "key"
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
  2023-07-09 23:06 ` [PATCH 16/22] tools/utils: move XLU_Operation to libxlu_cfg_y.h Elliott Mitchell
  2023-07-10 22:55 ` [PATCH 01/22] tools/utils: cleanup formatting of libxlutil.h Elliott Mitchell
@ 2023-07-13  6:29 ` Elliott Mitchell
  2023-07-14  2:01 ` [PATCH 15/22] tools/utils: move XLU_Config to libxlu_cfg.c Elliott Mitchell
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-13  6:29 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

Hopefully make it clearer to others this is the key associated with the
storage value to retrieve.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 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)
  */
 
-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 min,
+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);
 
-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
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 15/22] tools/utils: move XLU_Config to libxlu_cfg.c
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (2 preceding siblings ...)
  2023-07-13  6:29 ` [PATCH 02/22] tools/utils: rename "n" arguments to "key" Elliott Mitchell
@ 2023-07-14  2:01 ` Elliott Mitchell
  2023-07-14  2:01 ` [PATCH 14/22] tools/utils: introduce xlu_cfg_printf() function Elliott Mitchell
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-14  2:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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;
 };
 
+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;
 
@@ -188,7 +194,7 @@ void xlu_cfg_destroy(XLU_Config *cfg) {
         set_next= set->next;
         xlu__cfg_set_free(set);
     }
-    free(cfg->config_source);
+    free((void *)cfg->config_source);
     free(cfg);
 }
 
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.h
index 214ebe5f48..93caf24a6e 100644
--- a/tools/libs/util/libxlu_internal.h
+++ b/tools/libs/util/libxlu_internal.h
@@ -27,12 +27,6 @@
 
 typedef struct XLU_ConfigSetting XLU_ConfigSetting;
 
-struct XLU_Config {
-    XLU_ConfigSetting *settings;
-    FILE *report;
-    char *config_source;
-};
-
 
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 14/22] tools/utils: introduce xlu_cfg_printf() function
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (3 preceding siblings ...)
  2023-07-14  2:01 ` [PATCH 15/22] tools/utils: move XLU_Config to libxlu_cfg.c Elliott Mitchell
@ 2023-07-14  2:01 ` Elliott Mitchell
  2023-07-18 23:31 ` [PATCH 10/22] tools/utils: move XLU_ConfigSetting to libxl_cfg.c Elliott Mitchell
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-14  2:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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
 
 #include <limits.h>
+#include <stdarg.h>
 
 #include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
@@ -191,6 +192,28 @@ void xlu_cfg_destroy(XLU_Config *cfg) {
     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 = fputs(cfg->config_source, cfg->report);
+    if (ret < 0)
+        return -errno;
+    ret = fputc(':', cfg->report);
+    if (ret < 0)
+        return -errno;
+
+    va_start(args, format);
+    ret = vfprintf(cfg->report, format, args);
+    va_end(args);
+
+    return -errno;
+}
+
 static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) {
     XLU_ConfigSetting *set;
 
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 @@
 
 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= EINVAL;
 }
 
@@ -28,8 +25,7 @@ static int dpc_prep(DiskParseContext *dpc, const char *spec) {
     return 0;
 
  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(errno));
     return e;
 }
 
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.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)
 
+
+extern int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...)
+    __attribute__((__format__(__printf__, 2, 3)));
+
 #endif /*LIBXLU_INTERNAL_H*/
 
 /*
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"
 
 
-#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 = str;
@@ -129,7 +126,7 @@ static int parse_rdm_policy(XLU_Config *cfg, libxl_rdm_reserve_policy *policy,
     int ret = libxl_rdm_reserve_policy_from_string(str, policy);
 
     if (ret)
-        XLU__PCI_ERR(cfg, "Unknown RDM policy: %s", str);
+        xlu_cfg_printf(cfg, " Unknown RDM policy: %s", str);
 
     return ret;
 }
@@ -193,7 +190,7 @@ int xlu_pci_parse_spec_string(XLU_Config *cfg, libxl_device_pci *pci,
             pci->name = strdup(val);
             if (!pci->name) ret = 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 = ERROR_INVAL;
         }
 
@@ -233,7 +230,7 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *rdm, const char *str)
                 } else if (!strcmp(tok, "policy")) {
                     state = STATE_RESERVE_POLICY;
                 } else {
-                    XLU__PCI_ERR(cfg, "Unknown RDM state option: %s", tok);
+                    xlu_cfg_printf(cfg, " Unknown RDM state option: %s", tok);
                     goto parse_error;
                 }
                 tok = ptr + 1;
@@ -246,7 +243,7 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *rdm, const char *str)
                 if (!strcmp(tok, "host")) {
                     rdm->strategy = LIBXL_RDM_RESERVE_STRATEGY_HOST;
                 } else {
-                    XLU__PCI_ERR(cfg, "Unknown RDM strategy option: %s", tok);
+                    xlu_cfg_printf(cfg, " Unknown RDM strategy option: %s", tok);
                     goto parse_error;
                 }
                 tok = 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 = "^[0-9]+[GMK]?[Bb]/s$";
 static const char *vif_internal_usec_re = "^[0-9]+[mu]?s?$";
 
 static void xlu__vif_err(XLU_Config *cfg, const char *msg, const char *rate) {
-    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);
 }
 
 static int vif_parse_rate_bytes_per_sec(XLU_Config *cfg, const char *bytes,
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 10/22] tools/utils: move XLU_ConfigSetting to libxl_cfg.c
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (4 preceding siblings ...)
  2023-07-14  2:01 ` [PATCH 14/22] tools/utils: introduce xlu_cfg_printf() function Elliott Mitchell
@ 2023-07-18 23:31 ` Elliott Mitchell
  2023-07-19  5:02 ` [PATCH 06/22] tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c Elliott Mitchell
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-18 23:31 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 setting")
Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
@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"
 
+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;
 
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.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;
 };
 
-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;
 
 struct XLU_Config {
     XLU_ConfigSetting *settings;
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 06/22] tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (5 preceding siblings ...)
  2023-07-18 23:31 ` [PATCH 10/22] tools/utils: move XLU_ConfigSetting to libxl_cfg.c Elliott Mitchell
@ 2023-07-19  5:02 ` Elliott Mitchell
  2023-07-19  6:07 ` [PATCH 11/22] tools/utils: move XLU_ConfigValue to libxl_cfg.c Elliott Mitchell
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-19  5:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
 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"
 
 void xlu__disk_err(DiskParseContext *dpc, const char *erroneous,
                    const char *message) {
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 11/22] tools/utils: move XLU_ConfigValue to libxl_cfg.c
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (6 preceding siblings ...)
  2023-07-19  5:02 ` [PATCH 06/22] tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c Elliott Mitchell
@ 2023-07-19  6:07 ` Elliott Mitchell
  2023-07-19  6:07 ` [PATCH 13/22] tools/utils: move XLU_ConfigList " Elliott Mitchell
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-19  6:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
 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;
 };
 
+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;
 
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.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
 
-struct XLU_ConfigValue {
-    enum XLU_ConfigValueType type;
-    union {
-        char *string;
-        XLU_ConfigList list;
-    } u;
-    XLU__CFG_YYLTYPE loc;
-};
-
 typedef struct XLU_ConfigSetting XLU_ConfigSetting;
 
 struct XLU_Config {
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 12/22] tools/utils: remove YYLTYPE definition from libxlu_internal.h
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (8 preceding siblings ...)
  2023-07-19  6:07 ` [PATCH 13/22] tools/utils: move XLU_ConfigList " Elliott Mitchell
@ 2023-07-19  6:07 ` Elliott Mitchell
  2023-07-19 17:31 ` [PATCH 18/22] tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c Elliott Mitchell
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-19  6:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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_internal.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;
 };
 
-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;
 
 struct XLU_Config {
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 13/22] tools/utils: move XLU_ConfigList to libxl_cfg.c
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (7 preceding siblings ...)
  2023-07-19  6:07 ` [PATCH 11/22] tools/utils: move XLU_ConfigValue to libxl_cfg.c Elliott Mitchell
@ 2023-07-19  6:07 ` Elliott Mitchell
  2023-07-19  6:07 ` [PATCH 12/22] tools/utils: remove YYLTYPE definition from libxlu_internal.h Elliott Mitchell
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-19  6:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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;
 };
 
+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_internal.h
index c68669c3a1..310e2145a7 100644
--- a/tools/libs/util/libxlu_internal.h
+++ b/tools/libs/util/libxlu_internal.h
@@ -25,12 +25,6 @@
 
 #include "libxlutil.h"
 
-struct XLU_ConfigList {
-    int avalues; /* available slots */
-    int nvalues; /* actual occupied slots */
-    XLU_ConfigValue **values;
-};
-
 typedef struct XLU_ConfigSetting XLU_ConfigSetting;
 
 struct XLU_Config {
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 18/22] tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (9 preceding siblings ...)
  2023-07-19  6:07 ` [PATCH 12/22] tools/utils: remove YYLTYPE definition from libxlu_internal.h Elliott Mitchell
@ 2023-07-19 17:31 ` Elliott Mitchell
  2023-07-25 18:06 ` [PATCH 17/22] tools/utils: move setting free loop to xlu__cfg_set_free() Elliott Mitchell
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-19 17:31 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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) {
 
     e= 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);
 
     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");
     }
 }
 
@@ -144,8 +144,7 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) {
 
     buf = 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= ENOMEM;
         goto xe;
     }
@@ -236,10 +235,10 @@ static int find_atom(const XLU_Config *cfg, const char *n,
 
     if (set->value->type!=XLU_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= set;
@@ -257,10 +256,8 @@ int xlu_cfg_value_get_string(const XLU_Config *cfg, XLU_ConfigValue *value,
 {
     if (value->type != 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 = NULL;
         return EINVAL;
     }
@@ -274,10 +271,8 @@ int xlu_cfg_value_get_list(const XLU_Config *cfg, XLU_ConfigValue *value,
 {
     if (value->type != 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 = NULL;
         return EINVAL;
     }
@@ -325,10 +320,10 @@ int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n,
     e= find_atom(cfg,n,&set,dont_warn);  if (e) return e;
     if (set->op == XLU_OP_ADDITION) {
         if (!dont_warn)
-            fprintf(cfg->report,
-                    "%s:%d: warning: can't use += with numbers"
+            xlu_cfg_printf(cfg,
+                    "%d: warning: can't use += with numbers"
                     " for parameter `%s'\n",
-                    cfg->config_source, set->lineno, n);
+                    set->lineno, n);
         return EINVAL;
     }
     errno= 0; l= strtol(set->value->u.string, &ep, 0);
@@ -337,31 +332,31 @@ int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n,
         e= errno;
         assert(e==EINVAL || e==ERANGE);
         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==set->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 bound '%ld'\n",
-                    cfg->config_source, set->lineno, l, min);
+            xlu_cfg_printf(cfg,
+                    "%d: warning: value `%ld' is smaller than minimum bound '%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 bound '%ld'\n",
-                    cfg->config_source, set->lineno, l, max);
+            xlu_cfg_printf(cfg,
+                    "%d: warning: value `%ld' is greater than maximum bound '%ld'\n",
+                    set->lineno, l, max);
         return EINVAL;
     }
 
@@ -393,10 +388,10 @@ int xlu_cfg_get_list(const XLU_Config *cfg, const char *n,
     set= find(cfg,n);  if (!set) return ESRCH;
     if (set->value->type!=XLU_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, CfgParseContext *ctx,
         len--;
     }
 
-    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= EINVAL;
 }
 
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 17/22] tools/utils: move setting free loop to xlu__cfg_set_free()
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (10 preceding siblings ...)
  2023-07-19 17:31 ` [PATCH 18/22] tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c Elliott Mitchell
@ 2023-07-25 18:06 ` Elliott Mitchell
  2023-07-25 22:50 ` [PATCH 22/22] tools/utils: break flex/bison parser away from main config file Elliott Mitchell
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-25 18:06 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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)
 }
 
 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 = set->next;
+        free(set->name);
+        xlu__cfg_value_free(set->value);
+        free(set);
+        set = next;
+    }
 }
 
 void xlu_cfg_destroy(XLU_Config *cfg) {
-    XLU_ConfigSetting *set, *set_next;
-
     if (!cfg) return;
-    for (set= cfg->settings;
-         set;
-         set= set_next) {
-        set_next= 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,
 };
 
-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_internal.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)));
 
+/*
+ * 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*/
 
 /*
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 22/22] tools/utils: break flex/bison parser away from main config file
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (11 preceding siblings ...)
  2023-07-25 18:06 ` [PATCH 17/22] tools/utils: move setting free loop to xlu__cfg_set_free() Elliott Mitchell
@ 2023-07-25 22:50 ` Elliott Mitchell
  2023-07-26  3:11 ` [PATCH 21/22] tools/utils: add settings get function Elliott Mitchell
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-25 22:50 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
 tools/libs/util/Makefile                      |   1 +
 tools/libs/util/libxlu_cfg.c                  | 662 ------------------
 .../util/{libxlu_cfg.c => libxlu_cfg_i.c}     |  87 ---
 3 files changed, 1 insertion(+), 749 deletions(-)
 copy tools/libs/util/{libxlu_cfg.c => 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
 
 OBJS-y += libxlu_cfg_y.o
 OBJS-y += libxlu_cfg_l.o
+OBJS-y += libxlu_cfg_i.o
 OBJS-y += libxlu_cfg.o
 OBJS-y += libxlu_disk_l.o
 OBJS-y += 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 <stdarg.h>
 
 #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;
-};
 
 struct XLU_Config {
     XLU_ConfigSetting *settings;
@@ -67,49 +42,6 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) {
     return cfg;
 }
 
-static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg,
-    XLU_ConfigSetting **psettings)
-{
-    int e;
-
-    ctx->cfg= cfg;
-    ctx->psettings = psettings;
-    ctx->err= 0;
-    ctx->lexerrlineno= -1;
-    ctx->likely_python= 0;
-    ctx->scanner= 0;
-
-    e= 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= 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;
 }
 
-int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile, const char *msgprefix,
-    XLU_ConfigSetting **psettings, FILE *f, const char *name)
-{
-    int e;
-
-    CfgParseContext ctx;
-    e = ctx_prep(&ctx, cfg, psettings);
-    if (e) { ctx.err= 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);
 }
 
-int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile, const char *msgprefix,
-    XLU_ConfigSetting **psettings, const char *data, int length)
-{
-    int e;
-    YY_BUFFER_STATE buf= 0;
-
-    CfgParseContext ctx;
-    e = ctx_prep(&ctx, cfg, psettings);
-    if (e) { ctx.err= e; goto xe; }
-
-    buf = xlu__cfg_yy_scan_bytes(data, length, ctx.scanner);
-    if (!buf) {
-        xlu_cfg_printf(cfg, " unable to allocate scanner buffer\n");
-        ctx.err= 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 = 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 = set->next;
-        free(set->name);
-        xlu__cfg_value_free(set->value);
-        free(set);
-        set = 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;
 }
 
-static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) {
-    XLU_ConfigSetting *set;
-
-    for (set = xlu__cfg_get_settings(cfg);
-         set;
-         set= 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= find(cfg,n);
-    if (!set) return ESRCH;
-
-    if (set->value->type!=XLU_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= set;
-    return 0;
-}
-
 XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg)
 {
     return cfg->settings;
 }
 
 
-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 != 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 = NULL;
-        return EINVAL;
-    }
-
-    *value_r = 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 != 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 = NULL;
-        return EINVAL;
-    }
-
-    *value_r = &value->u.list;
-    return 0;
-}
-
-XLU_ConfigValue *xlu_cfg_get_listitem2(const XLU_ConfigList *list,
-                                       int entry)
-{
-    if (entry < 0 || entry >= 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= find_atom(cfg,n,&set,dont_warn);  if (e) return e;
-    *value_r= 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= find_atom(cfg,n,&set,dont_warn);  if (e) return e;
-    free(*value_r);
-    *value_r= 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= find_atom(cfg,n,&set,dont_warn);  if (e) return e;
-    if (set->op == XLU_OP_ADDITION) {
-        if (!dont_warn)
-            xlu_cfg_printf(cfg,
-                    "%d: warning: can't use += with numbers"
-                    " for parameter `%s'\n",
-                    set->lineno, n);
-        return EINVAL;
-    }
-    errno= 0; l= strtol(set->value->u.string, &ep, 0);
-    e= errno;
-    if (errno) {
-        e= errno;
-        assert(e==EINVAL || e==ERANGE);
-        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==set->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 bound '%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 bound '%ld'\n",
-                    set->lineno, l, max);
-        return EINVAL;
-    }
-
-    *value_r= 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);
 }
 
-int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n,
-                        libxl_defbool *value_r, int dont_warn)
-{
-    int ret;
-    long l;
-
-    ret = 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_warn) {
-    XLU_ConfigSetting *set;
-    set= find(cfg,n);  if (!set) return ESRCH;
-    if (set->value->type!=XLU_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= &set->value->u.list;
-    if (entries_r) *entries_r= 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 = xlu_cfg_get_list(cfg, n, &list, &nr, dont_warn);
-    if (rc)  return rc;
-
-    sl = malloc(sizeof(char*)*(nr + 1));
-    if (sl == NULL) return ENOMEM;
-
-    for (i=0; i<nr; i++) {
-        const char *a = xlu_cfg_get_listitem(list, i);
-        sl[i] = a ? strdup(a) : NULL;
-    }
-
-    sl[nr] = NULL;
-
-    *psl = sl;
-    return 0;
-}
-
-const char *xlu_cfg_get_listitem(const XLU_ConfigList *list, int entry) {
-    if (entry < 0 || entry >= list->nvalues) return 0;
-    if (list->values[entry]->type != 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 = NULL;
-
-    if (ctx->err) goto x;
-
-    value = malloc(sizeof(*value));
-    if (!value) goto xe;
-    value->type = XLU_STRING;
-    value->u.string = atom;
-    memcpy(&value->loc, loc, sizeof(*loc));
-
-    return value;
-
- xe:
-    ctx->err= 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 = NULL;
-    XLU_ConfigValue **values = NULL;
-
-    if (ctx->err) goto x;
-
-    values = malloc(sizeof(*values));
-    if (!values) goto xe;
-    values[0] = val;
-
-    value = malloc(sizeof(*value));
-    if (!value) goto xe;
-    value->type = XLU_LIST;
-    value->u.list.nvalues = !!val;
-    value->u.list.avalues = 1;
-    value->u.list.values = values;
-    memcpy(&value->loc, loc, sizeof(*loc));
-
-    return value;
-
- xe:
-    ctx->err= 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 == XLU_LIST);
-
-    if (list->u.list.nvalues >= list->u.list.avalues) {
-        int new_avalues;
-        XLU_ConfigValue **new_values = NULL;
-
-        if (list->u.list.avalues > INT_MAX / 100) {
-            ctx->err = ERANGE;
-            xlu__cfg_value_free(val);
-            return;
-        }
-
-        new_avalues = list->u.list.avalues * 4;
-        new_values  = realloc(list->u.list.values,
-                              sizeof(*new_values) * new_avalues);
-        if (!new_values) {
-            ctx->err = errno;
-            xlu__cfg_value_free(val);
-            return;
-        }
-
-        list->u.list.avalues = new_avalues;
-        list->u.list.values  = new_values;
-    }
-
-    list->u.list.values[list->u.list.nvalues] = 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 != 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 = NULL;
-
-        r = 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 = new_string;
-        return 0;
-    }
-    case XLU_LIST: {
-        XLU_ConfigList *const prev_list = &prev->u.list;
-        XLU_ConfigList *const cur_list = &to_add->u.list;
-        int nvalues;
-
-        if (prev->u.list.nvalues > INT_MAX - to_add->u.list.nvalues) {
-            return ERANGE;
-        }
-        nvalues = prev->u.list.nvalues + to_add->u.list.nvalues;
-
-        if (nvalues >= cur_list->avalues) {
-            XLU_ConfigValue **new_vals;
-            new_vals = realloc(cur_list->values,
-                               nvalues * sizeof(*new_vals));
-            if (!new_vals) {
-                return ENOMEM;
-            }
-            cur_list->avalues = nvalues;
-            cur_list->values = 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 = nvalues;
-        prev_list->nvalues = 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 == XLU_OP_ADDITION) {
-        /* If we have += concatenate with previous value with same name */
-        XLU_ConfigSetting *prev_set = find(ctx->cfg, name);
-        if (prev_set) {
-            r = xlu__cfg_concat_vals(ctx, prev_set->value, val);
-            if (r) {
-                ctx->err = r;
-                goto out;
-            }
-        }
-    }
-
-    set = malloc(sizeof(*set));
-    if (!set) {
-        ctx->err = errno;
-        goto out;
-    }
-    set->name= name;
-    set->value = val;
-    set->op = op;
-    set->lineno= lineno;
-    set->next = *ctx->psettings;
-    *ctx->psettings = 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= strdup(src);
-    if (!result) ctx->err= 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= strlen(src);
-    assert(len>=2 && src[0]==src[len-1]);
-
-    result= malloc(len-1);
-    if (!result) { ctx->err= errno; return 0; }
-
-    q= result;
-
-    for (p= src+1;
-         p < src+len-1;
-         ) {
-        c= *p++;
-        if (c=='\\') {
-            assert(p < src+len-1);
-            nc= *p++;
-            if (nc=='"' || nc=='\'' || nc=='\\') {
-                *q++= nc;
-            } else if (nc=='a') { *q++= '\007';
-            } else if (nc=='b') { *q++= '\010';
-            } else if (nc=='f') { *q++= '\014';
-            } else if (nc=='n') { *q++= '\n';
-            } else if (nc=='r') { *q++= '\r';
-            } else if (nc=='t') { *q++= '\t';
-            } else if (nc=='v') { *q++= '\013';
-            } else if (nc=='x') {
-
-#define NUMERIC_CHAR(minlen,maxlen,base,basetext) do{                        \
-                char numbuf[(maxlen)+1], *ep;                                \
-                unsigned long val;                                           \
-                                                                             \
-                strncpy(numbuf,p,(maxlen));                                  \
-                numbuf[(maxlen)]= 0;                                         \
-                val= strtoul(numbuf, &ep, (base));                           \
-                if (ep <= numbuf+(minlen)) {                                 \
-                    xlu__cfgl_lexicalerror(ctx,"invalid digit after"         \
-                         " backslash " basetext "numerical character escape" \
-                         " in quoted string");                               \
-                    ctx->err= EINVAL;                                        \
-                    goto x;                                                  \
-                }                                                            \
-                p += (ep - numbuf);                                          \
- }while(0)
-
-                p++;
-                NUMERIC_CHAR(2,2,16,"hex");
-            } else if (nc>='0' && nc<='7') {
-                NUMERIC_CHAR(1,3,10,"octal");
-            } else {
-                xlu__cfgl_lexicalerror(ctx,
-                           "invalid character after backlash in quoted string");
-                ctx->err= EINVAL;
-                goto x;
-            }
-            assert(p <= src+len-1);
-        } else {
-            *q++= c;
-        }
-    }
-
- x:
-    *q++= 0;
-    return result;
-}
-
-void xlu__cfgl_lexicalerror(CfgParseContext *ctx, char const *msg) {
-    XLU__CFG_YYLTYPE loc;
-    loc.first_line= xlu__cfg_yyget_lineno(ctx->scanner);
-    xlu__cfg_yyerror(&loc, ctx, msg);
-    ctx->lexerrlineno= loc.first_line;
-}
-
-void xlu__cfg_yyerror(XLU__CFG_YYLTYPE *loc, CfgParseContext *ctx,
-        char const *msg) {
-    const char *text, *newline;
-    int len, lineno;
-
-    lineno= loc->first_line;
-    if (lineno <= ctx->lexerrlineno) return;
-
-    text= xlu__cfg_yyget_text(ctx->scanner);
-    len= xlu__cfg_yyget_leng(ctx->scanner);
-    newline= "";
-    if (len>0 && text[len-1]=='\n') {
-        len--;
-        lineno--;
-        if (!len) {
-            newline= "<newline>";
-        }
-    }
-    while (len>0 && (text[len-1]=='\t' || text[len-1]==' ')) {
-        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= 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 <limits.h>
 #include <stdarg.h>
 
-#include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
 #include "libxlu_cfg_l.h"
 
@@ -47,26 +46,6 @@ struct XLU_ConfigValue {
     XLU__CFG_YYLTYPE loc;
 };
 
-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= malloc(sizeof(*cfg));
-    if (!cfg) return 0;
-
-    cfg->report= report;
-    cfg->config_source= strdup(report_source);
-    if (!cfg->config_source) { free(cfg); return 0; }
-
-    cfg->settings= 0;
-    return cfg;
-}
-
 static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg,
     XLU_ConfigSetting **psettings)
 {
@@ -110,25 +89,6 @@ static void parse(CfgParseContext *ctx) {
     }
 }
 
-int xlu_cfg_readfile(XLU_Config *cfg, const char *name)
-{
-    FILE *file;
-    int ret;
-
-    file = fopen(name, "r");
-    if (file) {
-        ret = xlu__cfg_readfile(cfg, cfg->report, cfg->config_source,
-            &cfg->settings, file, name);
-        fclose(file);
-    } else {
-        ret = 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 *msgprefix,
     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;
 }
 
-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 *msgprefix,
     XLU_ConfigSetting **psettings, const char *data, int length)
 {
@@ -208,35 +162,6 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set) {
     }
 }
 
-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 = fputs(cfg->config_source, cfg->report);
-    if (ret < 0)
-        return -errno;
-    ret = fputc(':', cfg->report);
-    if (ret < 0)
-        return -errno;
-
-    va_start(args, format);
-    ret = vfprintf(cfg->report, format, args);
-    va_end(args);
-
-    return -errno;
-}
-
 static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) {
     XLU_ConfigSetting *set;
 
@@ -267,11 +192,6 @@ static int find_atom(const XLU_Config *cfg, const char *n,
     return 0;
 }
 
-XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg)
-{
-    return cfg->settings;
-}
-
 
 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, const char *n,
     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);
-}
-
 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;
 }
 
-
 XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom,
                                     XLU__CFG_YYLTYPE *loc)
 {
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 21/22] tools/utils: add settings get function
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (12 preceding siblings ...)
  2023-07-25 22:50 ` [PATCH 22/22] tools/utils: break flex/bison parser away from main config file Elliott Mitchell
@ 2023-07-26  3:11 ` Elliott Mitchell
  2023-07-26  3:26 ` [PATCH 20/22] tools/utils: add wrapper for readfile()/readdata() functions Elliott Mitchell
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-26  3:11 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

The better to isolate the shared portion of the interface from the
low-level implementation.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 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 *format, ...)
 static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) {
     XLU_ConfigSetting *set;
 
-    for (set= cfg->settings;
+    for (set = xlu__cfg_get_settings(cfg);
          set;
          set= set->next)
         if (!strcmp(set->name, n))
@@ -267,6 +267,11 @@ static int find_atom(const XLU_Config *cfg, const char *n,
     return 0;
 }
 
+XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg)
+{
+    return cfg->settings;
+}
+
 
 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_internal.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 *msgfile,
 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)));
 
 #endif /*LIBXLU_INTERNAL_H*/
 
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 20/22] tools/utils: add wrapper for readfile()/readdata() functions
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (13 preceding siblings ...)
  2023-07-26  3:11 ` [PATCH 21/22] tools/utils: add settings get function Elliott Mitchell
@ 2023-07-26  3:26 ` Elliott Mitchell
  2023-07-26 21:22 ` [PATCH 19/22] tools/utils: add pointer to in-progress settings to CfgParseContext Elliott Mitchell
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-26  3:26 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
 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) {
     }
 }
 
-int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) {
-    FILE *f = 0;
+int xlu_cfg_readfile(XLU_Config *cfg, const char *name)
+{
+    FILE *file;
+    int ret;
+
+    file = fopen(name, "r");
+    if (file) {
+        ret = xlu__cfg_readfile(cfg, cfg->report, cfg->config_source,
+            &cfg->settings, file, name);
+        fclose(file);
+    } else {
+        ret = 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 *msgprefix,
+    XLU_ConfigSetting **psettings, FILE *f, const char *name)
+{
     int e;
 
     CfgParseContext ctx;
-    e = ctx_prep(&ctx, cfg, &cfg->settings);
+    e = ctx_prep(&ctx, cfg, psettings);
     if (e) { ctx.err= e; goto xe; }
 
-    f= fopen(real_filename, "r");
-    if (!f) {
-        ctx.err = errno;
-        fprintf(cfg->report,"%s: unable to open configuration file: %s\n",
-                real_filename, strerror(e));
-        goto xe;
-    }
-
     xlu__cfg_yyrestart(f, ctx.scanner);
 
     parse(&ctx);
 
  xe:
     ctx_dispose(&ctx);
-    if (f) fclose(f);
 
     return ctx.err;
 }
 
-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 *msgprefix,
+    XLU_ConfigSetting **psettings, const char *data, int length)
+{
     int e;
     YY_BUFFER_STATE buf= 0;
 
     CfgParseContext ctx;
-    e = ctx_prep(&ctx, cfg, &cfg->settings);
+    e = ctx_prep(&ctx, cfg, psettings);
     if (e) { ctx.err= e; goto xe; }
 
     buf = xlu__cfg_yy_scan_bytes(data, length, ctx.scanner);
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.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 char *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);
 
 #endif /*LIBXLU_INTERNAL_H*/
 
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 19/22] tools/utils: add pointer to in-progress settings to CfgParseContext
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (14 preceding siblings ...)
  2023-07-26  3:26 ` [PATCH 20/22] tools/utils: add wrapper for readfile()/readdata() functions Elliott Mitchell
@ 2023-07-26 21:22 ` Elliott Mitchell
  2023-07-27  4:09 ` [PATCH 03/22] tools/utils: remove old declaration of xlu__cfg_yyparse() Elliott Mitchell
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-26 21:22 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

Rather than needing the full structure, for many operations the settings
pointer is enough.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 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 *report_source) {
     return cfg;
 }
 
-static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg) {
+static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg,
+    XLU_ConfigSetting **psettings)
+{
     int e;
 
     ctx->cfg= cfg;
+    ctx->psettings = psettings;
     ctx->err= 0;
     ctx->lexerrlineno= -1;
     ctx->likely_python= 0;
@@ -112,7 +115,7 @@ int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) {
     int e;
 
     CfgParseContext ctx;
-    e = ctx_prep(&ctx, cfg);
+    e = ctx_prep(&ctx, cfg, &cfg->settings);
     if (e) { ctx.err= e; goto xe; }
 
     f= fopen(real_filename, "r");
@@ -139,7 +142,7 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) {
     YY_BUFFER_STATE buf= 0;
 
     CfgParseContext ctx;
-    e= ctx_prep(&ctx, cfg);
+    e = ctx_prep(&ctx, cfg, &cfg->settings);
     if (e) { ctx.err= e; goto xe; }
 
     buf = xlu__cfg_yy_scan_bytes(data, length, ctx.scanner);
@@ -619,8 +622,8 @@ void xlu__cfg_set_store(CfgParseContext *ctx, char *name,
     set->value = val;
     set->op = op;
     set->lineno= lineno;
-    set->next= ctx->cfg->settings;
-    ctx->cfg->settings= set;
+    set->next = *ctx->psettings;
+    *ctx->psettings = 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 @@
 
 typedef struct {
     XLU_Config *cfg;
+    XLU_ConfigSetting **psettings;
     int err, lexerrlineno, likely_python;
     void *scanner;
 } CfgParseContext;
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 03/22] tools/utils: remove old declaration of xlu__cfg_yyparse()
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (15 preceding siblings ...)
  2023-07-26 21:22 ` [PATCH 19/22] tools/utils: add pointer to in-progress settings to CfgParseContext Elliott Mitchell
@ 2023-07-27  4:09 ` Elliott Mitchell
  2023-07-27  4:56 ` [PATCH 09/22] tools/utils: move CfgParseContext to top of libxlu_cfg_y.y Elliott Mitchell
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-27  4:09 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
 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);
 
 void xlu__cfgl_likely_python(CfgParseContext *ctx);
 
-
-
-/* Why oh why does bison not declare this in its autogenerated .h ? */
-int xlu__cfg_yyparse(CfgParseContext *ctx);
-
-
 #endif /*LIBXLU_CFG_I_H*/
 
 /*
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 09/22] tools/utils: move CfgParseContext to top of libxlu_cfg_y.y
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (16 preceding siblings ...)
  2023-07-27  4:09 ` [PATCH 03/22] tools/utils: remove old declaration of xlu__cfg_yyparse() Elliott Mitchell
@ 2023-07-27  4:56 ` Elliott Mitchell
  2023-07-27 21:43 ` [PATCH 04/22] tools/utils: enable all Bison warnings Elliott Mitchell
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-27  4:56 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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 @@
 
 %code requires {
 #include "libxlu_internal.h"
+
+typedef struct {
+    XLU_Config *cfg;
+    int err, lexerrlineno, likely_python;
+    void *scanner;
+} CfgParseContext;
 }
 
 %code provides {
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.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;
 };
 
-typedef struct {
-    XLU_Config *cfg;
-    int err, lexerrlineno, likely_python;
-    void *scanner;
-} CfgParseContext;
-
 
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 04/22] tools/utils: enable all Bison warnings
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (17 preceding siblings ...)
  2023-07-27  4:56 ` [PATCH 09/22] tools/utils: move CfgParseContext to top of libxlu_cfg_y.y Elliott Mitchell
@ 2023-07-27 21:43 ` Elliott Mitchell
  2023-07-28 19:10 ` [PATCH 07/22] tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y Elliott Mitchell
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-27 21:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

Warnings from Bison seem less likely to be urgent, but on general
principle enable everything.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 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 libxlu_disk_l.c
 
 %.c %.h:: %.y
 	@rm -f $*.[ch]
-	$(BISON) --output=$*.c $<
+	$(BISON) -Wall --output=$*.c $<
 
 %.c %.h:: %.l
 	@rm -f $*.[ch]
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 07/22] tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (18 preceding siblings ...)
  2023-07-27 21:43 ` [PATCH 04/22] tools/utils: enable all Bison warnings Elliott Mitchell
@ 2023-07-28 19:10 ` Elliott Mitchell
  2023-07-29 23:04 ` [PATCH 05/22] tools/utils: update Bison parser directives Elliott Mitchell
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-28 19:10 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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"
 
 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 declarations
- *
- * Copyright (C) 2010      Citrix Ltd.
- * Author Ian Jackson <ian.jackson@eu.citrix.com>
- *
- * 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 @@
  */
 
 %{
-#include "libxlu_cfg_i.h"
+#include "libxlu_cfg_y.h"
 
 #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.
  */
 
+%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"
 %}
 
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 05/22] tools/utils: update Bison parser directives
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (19 preceding siblings ...)
  2023-07-28 19:10 ` [PATCH 07/22] tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y Elliott Mitchell
@ 2023-07-29 23:04 ` Elliott Mitchell
  2023-07-30  0:03 ` [PATCH 08/22] tools/utils: Bison: switch from name-prefix to api.prefix Elliott Mitchell
  2023-08-03  8:35 ` [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Jan Beulich
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-29 23:04 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

Update per Bison's obsolete warnings.  Testing indicates these are simple
and safe.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
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 @@
 }
 
 %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
 
-stmts:  /* empty */
+stmts:  %empty
  |      stmts stmt
 
 stmt:   assignment endstmt
@@ -67,13 +67,12 @@ value:  atom                         { $$= xlu__cfg_string_mk(ctx,$1,&@1); }
 atom:   STRING                   { $$= $1; }
  |      NUMBER                   { $$= $1; }
 
-valuelist: /* empty */           { $$= xlu__cfg_list_mk(ctx,NULL,&yylloc); }
+valuelist: %empty               { $$= xlu__cfg_list_mk(ctx,NULL,&yylloc); }
  |      values                  { $$= $1; }
  |      values ',' nlok         { $$= $1; }
 
 values: value nlok                  { $$= xlu__cfg_list_mk(ctx,$1,&@1); }
  |      values ',' nlok value nlok  { xlu__cfg_list_append(ctx,$1,$4); $$= $1; }
 
-nlok:
-        /* nothing */
+nlok:   %empty
  |      nlok NEWLINE
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 08/22] tools/utils: Bison: switch from name-prefix to api.prefix
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (20 preceding siblings ...)
  2023-07-29 23:04 ` [PATCH 05/22] tools/utils: update Bison parser directives Elliott Mitchell
@ 2023-07-30  0:03 ` Elliott Mitchell
  2023-08-03  8:35 ` [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Jan Beulich
  22 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-07-30  0:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

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 <ehem+xen@m5p.com>
---
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) {
 
 
 XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom,
-                                    YYLTYPE *loc)
+                                    XLU__CFG_YYLTYPE *loc)
 {
     XLU_ConfigValue *value = NULL;
 
@@ -412,7 +412,7 @@ XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx, char *atom,
 
 XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx,
                                   XLU_ConfigValue *val,
-                                  YYLTYPE *loc)
+                                  XLU__CFG_YYLTYPE *loc)
 {
     XLU_ConfigValue *value = NULL;
     XLU_ConfigValue **values = NULL;
@@ -667,13 +667,14 @@ char *xlu__cfgl_dequote(CfgParseContext *ctx, const char *src) {
 }
 
 void xlu__cfgl_lexicalerror(CfgParseContext *ctx, char const *msg) {
-    YYLTYPE loc;
+    XLU__CFG_YYLTYPE loc;
     loc.first_line= xlu__cfg_yyget_lineno(ctx->scanner);
     xlu__cfg_yyerror(&loc, ctx, msg);
     ctx->lexerrlineno= loc.first_line;
 }
 
-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;
 
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);
 
-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);
 
 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
 }
 
 %{
@@ -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 }
 
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.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;
 };
 
-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
 
 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;
 };
 
 typedef struct XLU_ConfigSetting { /* transparent */
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
@ 2023-08-02 15:33 Elliott Mitchell
  2023-07-09 23:06 ` [PATCH 16/22] tools/utils: move XLU_Operation to libxlu_cfg_y.h Elliott Mitchell
                   ` (22 more replies)
  0 siblings, 23 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-08-02 15:33 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony PERARD, Juergen Gross

Is there a freeze on that I'm unaware of?  Is there so much traffic from
other developers that smaller output ones are being missed?  I'm
wondering about the initial revision of this series not getting any
feedback:
https://lists.xenproject.org/archives/html/xen-devel/2023-07/msg01264.html


Due to the lack of news on the first thread, I've done some looking to
assess the feasibility.  The xl.cfg parser looks a bit jumbled.  Too many
things are visible to too many places.  In general some pieces have
really needed some TLC for a long time.

Note, some portions of this are semi-WIP.  The first 5 patches are simply
overdue maintenance.  Not particularly urgent, but should probably be
done.

Patch #06 is rather more urgent maintenance.  While it might not explode
soon, that is a landmine.

Patch #07 is the first big issue.  The roles of the various headers had
never been sorted out.  The underlying issue was more the contents of
"libxlu_cfg_i.h" needed to be merged into "libxlu_cfg_y.h".  Bison 2.3
may not have had the ability to embedded things into its header in 2010,
but the functionality appears to have been present in Bison 3.3.

There is an issue of what level of indentation should be used in
libxlu_cfg_y.y?  Normally the sections being added wouldn't be indented,
but normally they would be directly in headers.  I'm unsure of which
direction to go here.

Patch #08 seemed best to leave after #07 due to overlap and difficulty
with reordering.  I'm a bit worried about the interfacing with flex.


Then comes the issue of moving things out of libxlu_internal.h which
should never have been there.  The XLU_Config* values should have been
placed in libxlu_cfg_i.h instead.  Since I'm doing a thorough job,
they're instead moving to libxlu_cfg.c.

I'm unsure splitting libxlu_cfg.c is worthwhile.  The resultant reusable
libxlu_cfg.c is rather small.  Yet avoiding the need to reimplement the
small portion is handy.


Is the decision to keep in-tree copies of current Flex/Bison output still
valid?  I would be awful tempted to remove them from main/master, even
if copies are maintained on release branches.


Elliott Mitchell (22):
  tools/utils: cleanup formatting of libxlutil.h
  tools/utils: rename "n" arguments to "key"
  tools/utils: remove old declaration of xlu__cfg_yyparse()
  tools/utils: enable all Bison warnings
  tools/utils: update Bison parser directives
  tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c
  tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y
  tools/utils: Bison: switch from name-prefix to api.prefix
  tools/utils: move CfgParseContext to top of libxlu_cfg_y.y
  tools/utils: move XLU_ConfigSetting to libxl_cfg.c
  tools/utils: move XLU_ConfigValue to libxl_cfg.c
  tools/utils: remove YYLTYPE definition from libxlu_internal.h
  tools/utils: move XLU_ConfigList to libxl_cfg.c
  tools/utils: introduce xlu_cfg_printf() function
  tools/utils: move XLU_Config to libxlu_cfg.c
  tools/utils: move XLU_Operation to libxlu_cfg_y.h
  tools/utils: move setting free loop to xlu__cfg_set_free()
  tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c
  tools/utils: add pointer to in-progress settings to CfgParseContext
  tools/utils: add wrapper for readfile()/readdata() functions
  tools/utils: add settings get function
  tools/utils: break flex/bison parser away from main config file

 tools/include/libxlutil.h                     |  31 +-
 tools/libs/util/Makefile                      |   3 +-
 tools/libs/util/libxlu_cfg.c                  | 679 ++----------------
 .../util/{libxlu_cfg.c => libxlu_cfg_i.c}     | 196 +++--
 tools/libs/util/libxlu_cfg_i.h                |  59 --
 tools/libs/util/libxlu_cfg_l.l                |   2 +-
 tools/libs/util/libxlu_cfg_y.y                |  58 +-
 tools/libs/util/libxlu_disk.c                 |  15 +-
 tools/libs/util/libxlu_internal.h             |  59 +-
 tools/libs/util/libxlu_pci.c                  |  11 +-
 tools/libs/util/libxlu_vif.c                  |   4 +-
 11 files changed, 223 insertions(+), 894 deletions(-)
 copy tools/libs/util/{libxlu_cfg.c => libxlu_cfg_i.c} (78%)
 delete mode 100644 tools/libs/util/libxlu_cfg_i.h

-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@m5p.com      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445





^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
                   ` (21 preceding siblings ...)
  2023-07-30  0:03 ` [PATCH 08/22] tools/utils: Bison: switch from name-prefix to api.prefix Elliott Mitchell
@ 2023-08-03  8:35 ` Jan Beulich
  2023-08-03 16:13   ` Elliott Mitchell
  22 siblings, 1 reply; 30+ messages in thread
From: Jan Beulich @ 2023-08-03  8:35 UTC (permalink / raw)
  To: Elliott Mitchell; +Cc: Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

On 02.08.2023 17:33, Elliott Mitchell wrote:
> Is there a freeze on that I'm unaware of?  Is there so much traffic from
> other developers that smaller output ones are being missed?  I'm
> wondering about the initial revision of this series not getting any
> feedback:
> https://lists.xenproject.org/archives/html/xen-devel/2023-07/msg01264.html
> 
> 
> Due to the lack of news on the first thread, I've done some looking to
> assess the feasibility.  The xl.cfg parser looks a bit jumbled.  Too many
> things are visible to too many places.  In general some pieces have
> really needed some TLC for a long time.
> 
> Note, some portions of this are semi-WIP.  The first 5 patches are simply
> overdue maintenance.  Not particularly urgent, but should probably be
> done.
> 
> Patch #06 is rather more urgent maintenance.  While it might not explode
> soon, that is a landmine.
> 
> Patch #07 is the first big issue.  The roles of the various headers had
> never been sorted out.  The underlying issue was more the contents of
> "libxlu_cfg_i.h" needed to be merged into "libxlu_cfg_y.h".  Bison 2.3
> may not have had the ability to embedded things into its header in 2010,
> but the functionality appears to have been present in Bison 3.3.
> 
> There is an issue of what level of indentation should be used in
> libxlu_cfg_y.y?  Normally the sections being added wouldn't be indented,
> but normally they would be directly in headers.  I'm unsure of which
> direction to go here.
> 
> Patch #08 seemed best to leave after #07 due to overlap and difficulty
> with reordering.  I'm a bit worried about the interfacing with flex.
> 
> 
> Then comes the issue of moving things out of libxlu_internal.h which
> should never have been there.  The XLU_Config* values should have been
> placed in libxlu_cfg_i.h instead.  Since I'm doing a thorough job,
> they're instead moving to libxlu_cfg.c.
> 
> I'm unsure splitting libxlu_cfg.c is worthwhile.  The resultant reusable
> libxlu_cfg.c is rather small.  Yet avoiding the need to reimplement the
> small portion is handy.
> 
> 
> Is the decision to keep in-tree copies of current Flex/Bison output still
> valid?  I would be awful tempted to remove them from main/master, even
> if copies are maintained on release branches.
> 
> 
> Elliott Mitchell (22):
>   tools/utils: cleanup formatting of libxlutil.h
>   tools/utils: rename "n" arguments to "key"
>   tools/utils: remove old declaration of xlu__cfg_yyparse()
>   tools/utils: enable all Bison warnings
>   tools/utils: update Bison parser directives
>   tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c
>   tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y
>   tools/utils: Bison: switch from name-prefix to api.prefix
>   tools/utils: move CfgParseContext to top of libxlu_cfg_y.y
>   tools/utils: move XLU_ConfigSetting to libxl_cfg.c
>   tools/utils: move XLU_ConfigValue to libxl_cfg.c
>   tools/utils: remove YYLTYPE definition from libxlu_internal.h
>   tools/utils: move XLU_ConfigList to libxl_cfg.c
>   tools/utils: introduce xlu_cfg_printf() function
>   tools/utils: move XLU_Config to libxlu_cfg.c
>   tools/utils: move XLU_Operation to libxlu_cfg_y.h
>   tools/utils: move setting free loop to xlu__cfg_set_free()
>   tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c
>   tools/utils: add pointer to in-progress settings to CfgParseContext
>   tools/utils: add wrapper for readfile()/readdata() functions
>   tools/utils: add settings get function
>   tools/utils: break flex/bison parser away from main config file

Some of the patches looks to have been posted previously as a 7-patch
series. It would have been nice if therefore this one was marked as
v2, indicating in a revision log what the differences are. It appears
as if at least one out of those 7 earlier patches was dropped (or
maybe assimilated into another one).

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-03  8:35 ` [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Jan Beulich
@ 2023-08-03 16:13   ` Elliott Mitchell
  2023-08-03 16:34     ` Julien Grall
  2023-08-04  5:53     ` Jan Beulich
  0 siblings, 2 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-08-03 16:13 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

On Thu, Aug 03, 2023 at 10:35:53AM +0200, Jan Beulich wrote:
> 
> Some of the patches looks to have been posted previously as a 7-patch
> series. It would have been nice if therefore this one was marked as
> v2, indicating in a revision log what the differences are. It appears
> as if at least one out of those 7 earlier patches was dropped (or
> maybe assimilated into another one).

Indeed.  Problem is several tags could potentially have been used.
Should I have used all of them simultaneously?  Should I have used only
some of them?  Which subset?

Several were mildly adjusted, so it could have been marked "v2".

No one responded at all to the previous round, so this could have been
marked "RESEND".

Yet the refinements and general changes are large enough for the series
to be pretty distinct.

I didn't know which way to go, so with no idea which option to choose the
last one ended up winning out.  Perhaps that was wrong yet I've still no
feedback on the actual patches.


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg@m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-03 16:13   ` Elliott Mitchell
@ 2023-08-03 16:34     ` Julien Grall
  2023-08-03 17:45       ` Elliott Mitchell
  2023-08-04  5:53     ` Jan Beulich
  1 sibling, 1 reply; 30+ messages in thread
From: Julien Grall @ 2023-08-03 16:34 UTC (permalink / raw)
  To: Elliott Mitchell, Jan Beulich
  Cc: Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

Hi Elliott,

On 03/08/2023 17:13, Elliott Mitchell wrote:
> On Thu, Aug 03, 2023 at 10:35:53AM +0200, Jan Beulich wrote:
>>
>> Some of the patches looks to have been posted previously as a 7-patch
>> series. It would have been nice if therefore this one was marked as
>> v2, indicating in a revision log what the differences are. It appears
>> as if at least one out of those 7 earlier patches was dropped (or
>> maybe assimilated into another one).
> 
> Indeed.  Problem is several tags could potentially have been used.
> Should I have used all of them simultaneously?  Should I have used only
> some of them?  Which subset?
> 
> Several were mildly adjusted, so it could have been marked "v2".
> 
> No one responded at all to the previous round, so this could have been
> marked "RESEND".
> 
> Yet the refinements and general changes are large enough for the series
> to be pretty distinct.
> 
> I didn't know which way to go, so with no idea which option to choose the
> last one ended up winning out.  Perhaps that was wrong yet I've still no
> feedback on the actual patches.

Not sure if this is related to the lack of answer. But I didn't receive 
any of your patches via xen-devel (I received your replies). Skimming 
through the bounce for the xenproject mail server, I noticed a lot of 
the following:

     host gmail-smtp-in.l.google.com [142.250.123.26]
     SMTP error from remote mail server after pipelined end of data:
     550-5.7.1 This message is not RFC 5322 compliant. There are 
multiple Cc headers.
     550-5.7.1 To reduce the amount of spam sent to Gmail, this message 
has been
     550-5.7.1 blocked. Please visit
     550 5.7.1 
https://support.google.com/mail/?p=RfcMessageNonCompliant 
t7-20020a81e447000000b005839e8b595dsi12027284ywl.554 - gsmtp

It might be possible that other mail server are not happy with your e-mails.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-03 16:34     ` Julien Grall
@ 2023-08-03 17:45       ` Elliott Mitchell
  2023-08-03 17:48         ` Julien Grall
  0 siblings, 1 reply; 30+ messages in thread
From: Elliott Mitchell @ 2023-08-03 17:45 UTC (permalink / raw)
  To: Julien Grall
  Cc: Jan Beulich, Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

On Thu, Aug 03, 2023 at 05:34:31PM +0100, Julien Grall wrote:
> 
> On 03/08/2023 17:13, Elliott Mitchell wrote:
> > 
> > I didn't know which way to go, so with no idea which option to choose the
> > last one ended up winning out.  Perhaps that was wrong yet I've still no
> > feedback on the actual patches.
> 
> Not sure if this is related to the lack of answer. But I didn't receive 
> any of your patches via xen-devel (I received your replies). Skimming 
> through the bounce for the xenproject mail server, I noticed a lot of 
> the following:
> 
>      host gmail-smtp-in.l.google.com [142.250.123.26]
>      SMTP error from remote mail server after pipelined end of data:
>      550-5.7.1 This message is not RFC 5322 compliant. There are 
> multiple Cc headers.
>      550-5.7.1 To reduce the amount of spam sent to Gmail, this message 
> has been
>      550-5.7.1 blocked. Please visit
>      550 5.7.1 
> https://support.google.com/mail/?p=RfcMessageNonCompliant 
> t7-20020a81e447000000b005839e8b595dsi12027284ywl.554 - gsmtp

That seems to be repotting a bug in `scripts/add_maintainers.pl`.


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg@m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-03 17:45       ` Elliott Mitchell
@ 2023-08-03 17:48         ` Julien Grall
  2023-08-12  5:27           ` Elliott Mitchell
  0 siblings, 1 reply; 30+ messages in thread
From: Julien Grall @ 2023-08-03 17:48 UTC (permalink / raw)
  To: Elliott Mitchell
  Cc: Jan Beulich, Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

Hi,

On 03/08/2023 18:45, Elliott Mitchell wrote:
> On Thu, Aug 03, 2023 at 05:34:31PM +0100, Julien Grall wrote:
>>
>> On 03/08/2023 17:13, Elliott Mitchell wrote:
>>>
>>> I didn't know which way to go, so with no idea which option to choose the
>>> last one ended up winning out.  Perhaps that was wrong yet I've still no
>>> feedback on the actual patches.
>>
>> Not sure if this is related to the lack of answer. But I didn't receive
>> any of your patches via xen-devel (I received your replies). Skimming
>> through the bounce for the xenproject mail server, I noticed a lot of
>> the following:
>>
>>       host gmail-smtp-in.l.google.com [142.250.123.26]
>>       SMTP error from remote mail server after pipelined end of data:
>>       550-5.7.1 This message is not RFC 5322 compliant. There are
>> multiple Cc headers.
>>       550-5.7.1 To reduce the amount of spam sent to Gmail, this message
>> has been
>>       550-5.7.1 blocked. Please visit
>>       550 5.7.1
>> https://support.google.com/mail/?p=RfcMessageNonCompliant
>> t7-20020a81e447000000b005839e8b595dsi12027284ywl.554 - gsmtp
> 
> That seems to be repotting a bug in `scripts/add_maintainers.pl`.

I am curious to know why you think so?

I have been using scripts/add_maintainers.pl for quite a while and so 
far never seen any of my e-mail blocked.

My usual runes are:

42sh> scripts/add_maintainers.pl -d .
42sh> git-send-email *.patch

What's yours?

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-03 16:13   ` Elliott Mitchell
  2023-08-03 16:34     ` Julien Grall
@ 2023-08-04  5:53     ` Jan Beulich
  1 sibling, 0 replies; 30+ messages in thread
From: Jan Beulich @ 2023-08-04  5:53 UTC (permalink / raw)
  To: Elliott Mitchell; +Cc: Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

On 03.08.2023 18:13, Elliott Mitchell wrote:
> On Thu, Aug 03, 2023 at 10:35:53AM +0200, Jan Beulich wrote:
>>
>> Some of the patches looks to have been posted previously as a 7-patch
>> series. It would have been nice if therefore this one was marked as
>> v2, indicating in a revision log what the differences are. It appears
>> as if at least one out of those 7 earlier patches was dropped (or
>> maybe assimilated into another one).
> 
> Indeed.  Problem is several tags could potentially have been used.
> Should I have used all of them simultaneously?  Should I have used only
> some of them?  Which subset?
> 
> Several were mildly adjusted, so it could have been marked "v2".
> 
> No one responded at all to the previous round, so this could have been
> marked "RESEND".
> 
> Yet the refinements and general changes are large enough for the series
> to be pretty distinct.
> 
> I didn't know which way to go, so with no idea which option to choose the
> last one ended up winning out.  Perhaps that was wrong yet I've still no
> feedback on the actual patches.

As, for this series, being just in the role of a committer, without clearly
identifying that some earlier patches can now be dropped from the list of
things which need monitoring, you're making my (in that regard) supposedly
purely mechanical job harder (and presumably every other committer's as
well). As to not getting feedback: Your posting (at least the cover letter)
dates back to July 19. That's not all that long compared to other series.
Plus if you were concerned, you could have pinged the respective
maintainers.

Jan


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 00/22] Cleanup and splitting of xl.cfg parsing
  2023-08-03 17:48         ` Julien Grall
@ 2023-08-12  5:27           ` Elliott Mitchell
  0 siblings, 0 replies; 30+ messages in thread
From: Elliott Mitchell @ 2023-08-12  5:27 UTC (permalink / raw)
  To: Julien Grall
  Cc: Jan Beulich, Wei Liu, Anthony PERARD, Juergen Gross, xen-devel

On Thu, Aug 03, 2023 at 06:48:33PM +0100, Julien Grall wrote:
> Hi,
> 
> On 03/08/2023 18:45, Elliott Mitchell wrote:
> > On Thu, Aug 03, 2023 at 05:34:31PM +0100, Julien Grall wrote:
> >>
> >> Not sure if this is related to the lack of answer. But I didn't receive
> >> any of your patches via xen-devel (I received your replies). Skimming
> >> through the bounce for the xenproject mail server, I noticed a lot of
> >> the following:
> >>
> >>       host gmail-smtp-in.l.google.com [142.250.123.26]
> >>       SMTP error from remote mail server after pipelined end of data:
> >>       550-5.7.1 This message is not RFC 5322 compliant. There are
> >> multiple Cc headers.
> >>       550-5.7.1 To reduce the amount of spam sent to Gmail, this message
> >> has been
> >>       550-5.7.1 blocked. Please visit
> >>       550 5.7.1
> >> https://support.google.com/mail/?p=RfcMessageNonCompliant
> >> t7-20020a81e447000000b005839e8b595dsi12027284ywl.554 - gsmtp
> > 
> > That seems to be repotting a bug in `scripts/add_maintainers.pl`.
> 
> I am curious to know why you think so?
> 
> I have been using scripts/add_maintainers.pl for quite a while and so 
> far never seen any of my e-mail blocked.
> 
> My usual runes are:
> 
> 42sh> scripts/add_maintainers.pl -d .
> 42sh> git-send-email *.patch
> 
> What's yours?

Final steps are:

scp -r snd mailserver:
for f in snd/0*.patch
do sendmail -t < "$f"
	sleep 45
done

Issue with `git send-email` is it really needs all the setup of a MUA,
and I prefer to keep `git` on a distinct host.


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg@m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445




^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2023-08-12  5:28 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 15:33 [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Elliott Mitchell
2023-07-09 23:06 ` [PATCH 16/22] tools/utils: move XLU_Operation to libxlu_cfg_y.h Elliott Mitchell
2023-07-10 22:55 ` [PATCH 01/22] tools/utils: cleanup formatting of libxlutil.h Elliott Mitchell
2023-07-13  6:29 ` [PATCH 02/22] tools/utils: rename "n" arguments to "key" Elliott Mitchell
2023-07-14  2:01 ` [PATCH 15/22] tools/utils: move XLU_Config to libxlu_cfg.c Elliott Mitchell
2023-07-14  2:01 ` [PATCH 14/22] tools/utils: introduce xlu_cfg_printf() function Elliott Mitchell
2023-07-18 23:31 ` [PATCH 10/22] tools/utils: move XLU_ConfigSetting to libxl_cfg.c Elliott Mitchell
2023-07-19  5:02 ` [PATCH 06/22] tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c Elliott Mitchell
2023-07-19  6:07 ` [PATCH 11/22] tools/utils: move XLU_ConfigValue to libxl_cfg.c Elliott Mitchell
2023-07-19  6:07 ` [PATCH 13/22] tools/utils: move XLU_ConfigList " Elliott Mitchell
2023-07-19  6:07 ` [PATCH 12/22] tools/utils: remove YYLTYPE definition from libxlu_internal.h Elliott Mitchell
2023-07-19 17:31 ` [PATCH 18/22] tools/utils: spread xlu_cfg_printf() over libxlu_cfg.c Elliott Mitchell
2023-07-25 18:06 ` [PATCH 17/22] tools/utils: move setting free loop to xlu__cfg_set_free() Elliott Mitchell
2023-07-25 22:50 ` [PATCH 22/22] tools/utils: break flex/bison parser away from main config file Elliott Mitchell
2023-07-26  3:11 ` [PATCH 21/22] tools/utils: add settings get function Elliott Mitchell
2023-07-26  3:26 ` [PATCH 20/22] tools/utils: add wrapper for readfile()/readdata() functions Elliott Mitchell
2023-07-26 21:22 ` [PATCH 19/22] tools/utils: add pointer to in-progress settings to CfgParseContext Elliott Mitchell
2023-07-27  4:09 ` [PATCH 03/22] tools/utils: remove old declaration of xlu__cfg_yyparse() Elliott Mitchell
2023-07-27  4:56 ` [PATCH 09/22] tools/utils: move CfgParseContext to top of libxlu_cfg_y.y Elliott Mitchell
2023-07-27 21:43 ` [PATCH 04/22] tools/utils: enable all Bison warnings Elliott Mitchell
2023-07-28 19:10 ` [PATCH 07/22] tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y Elliott Mitchell
2023-07-29 23:04 ` [PATCH 05/22] tools/utils: update Bison parser directives Elliott Mitchell
2023-07-30  0:03 ` [PATCH 08/22] tools/utils: Bison: switch from name-prefix to api.prefix Elliott Mitchell
2023-08-03  8:35 ` [PATCH 00/22] Cleanup and splitting of xl.cfg parsing Jan Beulich
2023-08-03 16:13   ` Elliott Mitchell
2023-08-03 16:34     ` Julien Grall
2023-08-03 17:45       ` Elliott Mitchell
2023-08-03 17:48         ` Julien Grall
2023-08-12  5:27           ` Elliott Mitchell
2023-08-04  5:53     ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.