From 26a0d6111545904c378c58f1f0b1c2ad2fe66614 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 24 May 2020 20:33:26 +0100 Subject: [PATCH] config parsing: Break out cfgfatal_cl_type No functional change. We are going to reuse and improve this. Signed-off-by: Ian Jackson --- conffile.c | 2 +- log.c | 7 +++++++ secnet.h | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conffile.c b/conffile.c index e3a74aa..8c4385c 100644 --- a/conffile.c +++ b/conffile.c @@ -667,7 +667,7 @@ void *find_cl_if(dict_t *dict, cstring_t name, uint32_t type, } cl=i->data.closure; if (cl->type!=type) { - cfgfatal(loc,desc,"\"%s\" is the wrong type of closure\n",name); + cfgfatal_cl_type(loc,desc,cl,type,name); } return cl->interface; } diff --git a/log.c b/log.c index 1ff2e5c..dd3e477 100644 --- a/log.c +++ b/log.c @@ -162,6 +162,13 @@ void cfgfatal_maybefile(FILE *maybe_f, struct cloc loc, cstring_t facility, va_end(args); } +void cfgfatal_cl_type(struct cloc loc, const char *facility, + closure_t *cl, uint32_t exp_type, const char *name) +{ + assert(cl->type != exp_type); + cfgfatal(loc,facility,"\"%s\" is the wrong type of closure\n",name); +} + void cfgfatal(struct cloc loc, cstring_t facility, const char *message, ...) { va_list args; diff --git a/secnet.h b/secnet.h index b54df22..743d1b3 100644 --- a/secnet.h +++ b/secnet.h @@ -843,6 +843,10 @@ extern NORETURN(cfgfatal_maybefile(FILE *maybe_f, struct cloc loc, const char *message, ...)) FORMAT(printf,4,5); +extern NORETURN(cfgfatal_cl_type(struct cloc loc, const char *facility, + closure_t *cl, uint32_t exp_type, + const char *name)); + extern void Message(uint32_t class, const char *message, ...) FORMAT(printf,2,3); extern void log_from_fd(int fd, cstring_t prefix, struct log_if *log); -- 2.30.2