From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 23 Sep 2021 21:39:36 -0500 Subject: [PATCH] libmultipath: use typedef for keyword handler and print functions Don't keep writing out the function type. Signed-off-by: Benjamin Marzinski --- libmultipath/parser.c | 10 +++++----- libmultipath/parser.h | 25 ++++++++++++------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libmultipath/parser.c b/libmultipath/parser.c index 96b95936..e511acf9 100644 --- a/libmultipath/parser.c +++ b/libmultipath/parser.c @@ -32,8 +32,8 @@ static int line_nr; int keyword_alloc(vector keywords, char *string, - int (*handler) (struct config *, vector), - int (*print) (struct config *, char *, int, const void*), + handler_fn *handler, + print_fn *print, int unique) { struct keyword *keyword; @@ -71,8 +71,8 @@ install_sublevel_end(void) int _install_keyword(vector keywords, char *string, - int (*handler) (struct config *, vector), - int (*print) (struct config *, char *, int, const void*), + handler_fn *handler, + print_fn *print, int unique) { int i = 0; @@ -562,7 +562,7 @@ process_stream(struct config *conf, FILE *stream, vector keywords, goto out; } if (keyword->handler) { - t = (*keyword->handler) (conf, strvec); + t = keyword->handler(conf, strvec); r += t; if (t) condlog(1, "multipath.conf +%d, parsing failed: %s", diff --git a/libmultipath/parser.h b/libmultipath/parser.h index b7917052..e8d89607 100644 --- a/libmultipath/parser.h +++ b/libmultipath/parser.h @@ -39,11 +39,15 @@ #define EOB "}" #define MAXBUF 1024 -/* ketword definition */ + +/* keyword definition */ +typedef int print_fn(struct config *, char *, int, const void *); +typedef int handler_fn(struct config *, vector); + struct keyword { char *string; - int (*handler) (struct config *, vector); - int (*print) (struct config *, char *, int, const void *); + handler_fn *handler; + print_fn *print; vector sub; int unique; }; @@ -58,19 +62,14 @@ struct keyword { for (i = 0; i < (k)->sub->allocated && ((p) = (k)->sub->slot[i]); i++) /* Prototypes */ -extern int keyword_alloc(vector keywords, char *string, - int (*handler) (struct config *, vector), - int (*print) (struct config *, char *, int, - const void *), - int unique); +extern int keyword_alloc(vector keywords, char *string, handler_fn *handler, + print_fn *print, int unique); #define install_keyword_root(str, h) keyword_alloc(keywords, str, h, NULL, 1) extern void install_sublevel(void); extern void install_sublevel_end(void); -extern int _install_keyword(vector keywords, char *string, - int (*handler) (struct config *, vector), - int (*print) (struct config *, char *, int, - const void *), - int unique); + +extern int _install_keyword(vector keywords, char *string, handler_fn *handler, + print_fn *print, int unique); #define install_keyword(str, vec, pri) _install_keyword(keywords, str, vec, pri, 1) #define install_keyword_multi(str, vec, pri) _install_keyword(keywords, str, vec, pri, 0) extern void dump_keywords(vector keydump, int level);