chiark / gitweb /
rsa: Move FREE macro up
[secnet.git] / rsa.c
diff --git a/rsa.c b/rsa.c
index 18b4f3f2e55b592da2bbb28eb191c39c55617103..5921abda151130b2ce20968baf3591ded689249b 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -45,11 +45,14 @@ struct rsacommon {
     uint8_t *hashbuf;
 };
 
+#define FREE(b)                ({ free((b)); (b)=0; })
+
 struct load_ctx {
     void (*verror)(struct load_ctx *l,
                   FILE *maybe_f, bool_t unsup,
                   const char *message, va_list args);
     bool_t (*postreadcheck)(struct load_ctx *l, FILE *f);
+    const char *what;
     struct cloc *loc;
     union {
        struct {
@@ -64,7 +67,7 @@ static void verror_tryload(struct load_ctx *l,
                           const char *message, va_list args)
 {
     int class=unsup ? M_DEBUG : M_ERR;
-    slilog_part(l->u.tryload.log,class,"rsa1priv load: ");
+    slilog_part(l->u.tryload.log,class,"%s: ",l->what);
     vslilog(l->u.tryload.log,class,message,args);
 }
 
@@ -72,7 +75,7 @@ static void verror_cfgfatal(struct load_ctx *l,
                            FILE *maybe_f, bool_t unsup,
                            const char *message, va_list args)
 {
-    vcfgfatal_maybefile(maybe_f,*l->loc,"rsa-private",message,args);
+    vcfgfatal_maybefile(maybe_f,*l->loc,l->what,message,args);
 }
 
 struct rsapriv {
@@ -371,7 +374,6 @@ static void load_error(struct load_ctx *l, FILE *maybe_f,
 #define LDUNSUP(...)      ({ load_error(l,0,1,__VA_ARGS__); goto error_out; })
 #define LDFATAL_FILE(...) ({ load_error(l,f,0,__VA_ARGS__); goto error_out; })
 #define LDUNSUP_FILE(...) ({ load_error(l,f,1,__VA_ARGS__); goto error_out; })
-#define FREE(b)                ({ free((b)); (b)=0; })
 #define KEYFILE_GET(is)   ({                                   \
        uint##is##_t keyfile_get_tmp=keyfile_get_##is(l,f);     \
        if (!l->postreadcheck(l,f)) goto error_out;             \
@@ -658,6 +660,7 @@ bool_t rsa1_loadpriv(const struct sigscheme_info *algo,
     }
 
     struct load_ctx l[1];
+    l->what="rsa1priv load";
     l->verror=verror_tryload;
     l->postreadcheck=postreadcheck_tryload;
     l->loc=&loc;
@@ -691,6 +694,7 @@ static list_t *rsapriv_apply(closure_t *self, struct cloc loc, dict_t *context,
     FILE *f;
     struct load_ctx l[1];
 
+    l->what="rsa-private";
     l->verror=verror_cfgfatal;
     l->postreadcheck=postreadcheck_apply;
     l->loc=&loc;