diff mbox series

[15/22] tools/utils: move XLU_Config to libxlu_cfg.c

Message ID e685f7dd1464953fe59dfa29115cfac669e00df0.1690990428.git.ehem+xen@m5p.com (mailing list archive)
State New, archived
Headers show
Series Cleanup and splitting of xl.cfg parsing | expand

Commit Message

Elliott Mitchell July 14, 2023, 2:01 a.m. UTC
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 mbox series

Patch

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)