Some cleanup of tools utility library
cover Some cleanup of tools utility library
These have been hanging around in my repository for a while. The original submission pass got bungled and other things came up. Simply some small bits of formatting cleanup.
Elliott Mitchell (3):
tools/utils: cleanup formatting of libxlutil.h tools/utils: rename "n" arguments to "key" tools/utils: remove old declaration of xlu__cfg_yyparse()
tools/include/libxlutil.h | 26 +++++++++++++------------- tools/libs/util/libxlu_cfg.c | 6 +++--- tools/libs/util/libxlu_cfg_i.h | 6 ------ 3 files changed, 16 insertions(+), 22 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/3 tools/utils: cleanup formatting of libxlutil.h
Date: Mon, 10 Jul 2023 15:55:30 -0700
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.
--- tools/include/libxlutil.h | 22 +++++++++++----------- tools/libs/util/libxlu_cfg.c | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-)
tools/include/libxlutil.h +11 -11
@@ -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) */
tools/libs/util/libxlu_cfg.c +3 -3
@@ -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 ; }
Signature · 1 line
2.47.3
PATCH 2/3 tools/utils: rename "n" arguments to "key"
In reply to Elliott MitchellDate: Wed, 12 Jul 2023 23:29:59 -0700
Hopefully make it clearer to others this is the key associated with the storage value to retrieve.
--- tools/include/libxlutil.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/include/libxlutil.h +7 -7
@@ -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
Signature · 1 line
2.47.3
PATCH 3/3 tools/utils: remove old declaration of xlu__cfg_yyparse()
In reply to Elliott MitchellDate: Wed, 26 Jul 2023 21:09:21 -0700
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.
--- tools/libs/util/libxlu_cfg_i.h | 6 ------ 1 file changed, 6 deletions(-)
tools/libs/util/libxlu_cfg_i.h +0 -6
@@ -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*/ /*
Signature · 1 line
2.47.3