More instances of strerror in snap.c - dedup - deduplicating backup program
 (HTM) git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 7e9bd31a78b71aa5451f66808fd57f7eabb4e811
 (DIR) parent 62e3b353d4deb68012b257e9debc351ddf454769
 (HTM) Author: sin <sin@2f30.org>
       Date:   Fri,  3 May 2019 16:40:07 +0100
       
       More instances of strerror in snap.c
       
       Diffstat:
         M snap.c                              |      26 +++++++++++++++-----------
       
       1 file changed, 15 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/snap.c b/snap.c
       @@ -42,12 +42,12 @@ loadmd(struct sctx *sctx)
        
                mdnode = calloc(1, sizeof(*mdnode));
                if (mdnode == NULL) {
       -                sseterr("out of memory");
       +                sseterr("calloc: %s", strerror(errno));
                        return -1;
                }
                if (xread(sctx->fd, mdnode->md, MDSIZE) != MDSIZE) {
                        free(mdnode);
       -                sseterr("failed to read message digest");
       +                sseterr("xread: %s", strerror(errno));
                        return -1;
                }
                SLIST_INSERT_HEAD(&sctx->mdhead, mdnode, e);
       @@ -60,8 +60,10 @@ initmdhead(struct sctx *sctx)
                struct stat st;
                uint64_t i, n;
        
       -        if (fstat(sctx->fd, &st) < 0)
       +        if (fstat(sctx->fd, &st) < 0) {
       +                sseterr("fstat: %s", strerror(errno));
                        return -1;
       +        }
                n = st.st_size / MDSIZE;
                for (i = 0; i < n; i++) {
                        if (loadmd(sctx) == 0)
       @@ -92,14 +94,14 @@ screat(char *path, int mode, struct sctx **sctx)
        
                fd = open(path, O_RDWR | O_CREAT | O_EXCL, mode);
                if (fd < 0) {
       -                sseterr("%s", strerror(errno));
       +                sseterr("open: %s", strerror(errno));
                        return -1;
                }
        
                *sctx = calloc(1, sizeof(**sctx));
                if (*sctx == NULL) {
                        close(fd);
       -                sseterr("out of memory");
       +                sseterr("calloc: %s", strerror(errno));
                        return -1;
                }
        
       @@ -127,14 +129,14 @@ sopen(char *path, int flags, int mode, struct sctx **sctx)
        
                fd = open(path, O_RDONLY, mode);
                if (fd < 0) {
       -                sseterr("%s", strerror(errno));
       +                sseterr("open: %s", strerror(errno));
                        return -1;
                }
        
                *sctx = calloc(1, sizeof(**sctx));
                if (*sctx == NULL) {
                        close(fd);
       -                sseterr("out of memory");
       +                sseterr("calloc: %s", strerror(errno));
                        return -1;
                }
        
       @@ -163,7 +165,7 @@ sput(struct sctx *sctx, unsigned char *md)
        
                mdnode = calloc(1, sizeof(*mdnode));
                if (mdnode == NULL) {
       -                sseterr("out of memory");
       +                sseterr("calloc: %s", strerror(errno));
                        return -1;
                }
                memcpy(mdnode->md, md, MDSIZE);
       @@ -219,12 +221,14 @@ ssync(struct sctx *sctx)
                        return 0;
        
                if (lseek(sctx->fd, 0, SEEK_SET) < 0) {
       -                sseterr("failed to seek on snapshot descriptor");
       +                sseterr("lseek: %s", strerror(errno));
                        return -1;
                }
                SLIST_FOREACH(mdnode, &sctx->mdhead, e) {
       -                if (xwrite(sctx->fd, mdnode->md, MDSIZE) != MDSIZE)
       +                if (xwrite(sctx->fd, mdnode->md, MDSIZE) != MDSIZE) {
       +                        sseterr("xwrite: %s", strerror(errno));
                                return -1;
       +                }
                }
                fsync(sctx->fd);
                return 0;
       @@ -253,7 +257,7 @@ sclose(struct sctx *sctx)
                r = close(sctx->fd);
                free(sctx);
                if (r < 0)
       -                sseterr("failed to close snapshot descriptor");
       +                sseterr("close: %s", strerror(errno));
                return r;
        }