chiark / gitweb /
privcache: Transpose scheme lookup and file opening
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Dec 2019 14:04:58 +0000 (14:04 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:54 +0000 (21:56 +0000)
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 <ijackson@chiark.greenend.org.uk>
privcache.c

index f95ee37a6600e0d2b280dc614652b7c31300ad93..ba756ffda8d38117ff766935103e86221b501c7d 100644 (file)
@@ -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 };