From 0037d80883eb0e4bde85537da04ab76dc747389a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Dec 2019 13:01:32 +0000 Subject: [PATCH] privcache: uncached_get: Introduce `path' local This is a bit more convenient and will also make a future commit much easier too read. Signed-off-by: Ian Jackson --- privcache.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/privcache.c b/privcache.c index 790281d..3197329 100644 --- a/privcache.c +++ b/privcache.c @@ -45,14 +45,16 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, sprintf(st->path.write_here, SIGKEYID_PR_FMT, SIGKEYID_PR_VAL(id)); - f = fopen(st->path.buffer,"rb"); + const char *path=st->path.buffer; + + f = fopen(path,"rb"); if (!f) { if (errno == ENOENT) { slilog(log,M_DEBUG,"private key %s not found", - st->path.buffer); + path); } else { slilog(log,M_ERR,"failed to open private key file %s", - st->path.buffer); + path); } goto out; } @@ -62,12 +64,12 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, ssize_t got=fread(st->databuf.base,1,st->databuf.alloclen,f); if (ferror(f)) { slilog(log,M_ERR,"failed to read private-key file %s", - st->path.buffer); + path); goto out; } if (!feof(f)) { slilog(log,M_ERR,"private key file %s longer than max %d", - st->path.buffer, (int)st->databuf.alloclen); + path, (int)st->databuf.alloclen); goto out; } fclose(f); f=0; @@ -81,13 +83,13 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, goto found; slilog(log,M_ERR,"private key file %s not loaded (unknown algid)", - st->path.buffer); + path); goto out; found: st->databuf.start=st->databuf.base; st->databuf.size=got; - struct cloc loc = { .file=st->path.buffer, .line=0 }; + struct cloc loc = { .file=path, .line=0 }; ok=scheme->loadpriv(scheme, &st->databuf, &sigpriv, log, loc); if (!ok) goto out; /* loadpriv will have logged */ @@ -95,7 +97,7 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, if (!st->defhash) { slilog(log,M_ERR, "private key %s requires `hash' config key for privcache to load", - st->path.buffer); + path); sigpriv->dispose(sigpriv->st); sigpriv=0; goto out; -- 2.30.2