From e0e1a01632cf95c0df96933b3c9b8ee67b76a311 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Dec 2019 14:04:58 +0000 Subject: [PATCH] privcache: Transpose scheme lookup and file opening This makes no real difference, except that it provides a different error message if both things are wrong. This new odrering is more consistent with a change we are about to make. Signed-off-by: Ian Jackson --- privcache.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/privcache.c b/privcache.c index f95ee37..ba756ff 100644 --- a/privcache.c +++ b/privcache.c @@ -49,6 +49,19 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, struct hash_if *defhash=st->defhash; struct buffer_if *databuf=&st->databuf; + struct sigprivkey_if *sigpriv=0; + const struct sigscheme_info *scheme; + for (scheme=sigschemes; + scheme->name; + scheme++) + if (scheme->algid == id->b[GRPIDSZ]) + goto found; + + slilog(log,M_ERR,"private key file %s not loaded (unknown algid)", + path); + goto out; + + found: f = fopen(path,"rb"); if (!f) { if (errno == ENOENT) { @@ -76,19 +89,6 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, } fclose(f); f=0; - struct sigprivkey_if *sigpriv=0; - const struct sigscheme_info *scheme; - for (scheme=sigschemes; - scheme->name; - scheme++) - if (scheme->algid == id->b[GRPIDSZ]) - goto found; - - slilog(log,M_ERR,"private key file %s not loaded (unknown algid)", - path); - goto out; - - found: databuf->start=databuf->base; databuf->size=got; struct cloc loc = { .file=path, .line=0 }; -- 2.30.2