chiark / gitweb /
vcfgfatal_maybefile: New suffix argument
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Dec 2019 16:27:17 +0000 (16:27 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:51 +0000 (21:56 +0000)
We are going to want to provide a log_if that calls *cfgfatal*.
Messages sent to a log_if do not have a \n, but messages passed to
cfgfatal do.  (This is daft, btw.)

To help resolve this impedance mismatch, provide a "suffix" parameter.
We only need this for vcfgfatal_maybefile, not for any of the other
variants.

No functional change.

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

diff --git a/log.c b/log.c
index 123961202abd5f42faacb0d987779bd612c26d91..e7d974dc853cfe1981afb9f1a3bdd474c0595118 100644 (file)
--- a/log.c
+++ b/log.c
@@ -130,7 +130,8 @@ void fatal_perror_status(int status, const char *message, ...)
 }
 
 void vcfgfatal_maybefile(FILE *maybe_f /* or 0 */, struct cloc loc,
-                        cstring_t facility, const char *message, va_list args)
+                        cstring_t facility, const char *message, va_list args,
+                        const char *suffix)
 {
     enter_phase(PHASE_SHUTDOWN);
 
@@ -152,6 +153,7 @@ void vcfgfatal_maybefile(FILE *maybe_f /* or 0 */, struct cloc loc,
     }
     
     vMessage(M_FATAL,message,args);
+    Message(M_FATAL,"%s",suffix);
     exit(current_phase);
 }
 
@@ -161,7 +163,7 @@ void cfgfatal_maybefile(FILE *maybe_f, struct cloc loc, cstring_t facility,
     va_list args;
 
     va_start(args,message);
-    vcfgfatal_maybefile(maybe_f,loc,facility,message,args);
+    vcfgfatal_maybefile(maybe_f,loc,facility,message,args,0);
     va_end(args);
 }    
 
@@ -170,7 +172,7 @@ void cfgfatal(struct cloc loc, cstring_t facility, const char *message, ...)
     va_list args;
 
     va_start(args,message);
-    vcfgfatal_maybefile(0,loc,facility,message,args);
+    vcfgfatal_maybefile(0,loc,facility,message,args,"");
     va_end(args);
 }
 
diff --git a/rsa.c b/rsa.c
index 8fc976b9fdc4c964d600cd88bd0f7e7bc520b320..ef99f91f4967228908885764fca2ef2599ca111c 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -85,7 +85,7 @@ static void verror_cfgfatal(struct load_ctx *l, struct cloc loc,
                            FILE *maybe_f,
                            const char *message, va_list args)
 {
-    vcfgfatal_maybefile(maybe_f,l->loc,l->what,message,args);
+    vcfgfatal_maybefile(maybe_f,l->loc,l->what,message,args,"");
 }
 
 struct rsapriv {
index dbf33414e1220c6d1721c2c17ac35f025ea3f355..c1397966b83d447abad4fb0288639030b68d0631 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -818,7 +818,7 @@ extern NORETURN(cfgfatal(struct cloc loc, cstring_t facility,
 extern void cfgfile_postreadcheck(struct cloc loc, FILE *f);
 extern NORETURN(vcfgfatal_maybefile(FILE *maybe_f, struct cloc loc,
                                    cstring_t facility, const char *message,
-                                   va_list))
+                                   va_list, const char *suffix))
     FORMAT(printf,4,0);
 extern NORETURN(cfgfatal_maybefile(FILE *maybe_f, struct cloc loc,
                                   cstring_t facility,