chiark / gitweb /
config parsing: Break out cfgfatal_cl_type
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 May 2020 19:33:26 +0000 (20:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 May 2020 19:47:04 +0000 (20:47 +0100)
No functional change.  We are going to reuse and improve this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
conffile.c
log.c
secnet.h

index e3a74aa..8c4385c 100644 (file)
@@ -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 (file)
--- 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;
index b54df22..743d1b3 100644 (file)
--- 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);