From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 11 Nov 2021 12:53:45 -0600 Subject: [PATCH] libmultipath: use typedef for keyword handler function Don't keep writing out the function type. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/parser.c | 6 +++--- libmultipath/parser.h | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libmultipath/parser.c b/libmultipath/parser.c index 611054f7..ebe1cbd9 100644 --- a/libmultipath/parser.c +++ b/libmultipath/parser.c @@ -33,7 +33,7 @@ static int line_nr; int keyword_alloc(vector keywords, char *string, - int (*handler) (struct config *, vector), + handler_fn *handler, print_fn *print, int unique) { @@ -72,7 +72,7 @@ install_sublevel_end(void) int _install_keyword(vector keywords, char *string, - int (*handler) (struct config *, vector), + handler_fn *handler, print_fn *print, int unique) { @@ -558,7 +558,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 b43d46f8..3452bde1 100644 --- a/libmultipath/parser.h +++ b/libmultipath/parser.h @@ -43,10 +43,11 @@ struct strbuf; /* keyword definition */ typedef int print_fn(struct config *, struct strbuf *, const void *); +typedef int handler_fn(struct config *, vector); struct keyword { char *string; - int (*handler) (struct config *, vector); + handler_fn *handler; print_fn *print; vector sub; int unique; @@ -62,18 +63,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), - print_fn *print, - 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), - print_fn *print, - 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);