dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit e952e5814408ad1c170e1276a2e4ef3a4dcaf3c4
parent 41ef1e9be6c16c307def27c5f9712be313735cac
Author: sin <sin@2f30.org>
Date:   Fri,  3 May 2019 15:09:41 +0100

Error reporting for block.c

Diffstat:
Mblock.c | 44+++++++++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/block.c b/block.c @@ -19,15 +19,19 @@ bcreat(char *path, int mode, struct bparam *bpar, struct bctx **bctx) { struct bops *bops; - if (path == NULL || bctx == NULL) + if (path == NULL || bctx == NULL) { + bseterr("invalid params"); return -1; + } if (bpar == NULL) bpar = bparamdef(); *bctx = calloc(1, sizeof(**bctx)); - if (*bctx == NULL) + if (*bctx == NULL) { + bseterr("out of memory"); return -1; + } bops = bcompressops(); if (bops->creat(*bctx, path, mode, bpar) < 0) { @@ -42,12 +46,16 @@ bopen(char *path, int flags, int mode, struct bparam *bpar, struct bctx **bctx) { struct bops *bops; - if (path == NULL || bpar == NULL || bctx == NULL) + if (path == NULL || bpar == NULL || bctx == NULL) { + bseterr("invalid params"); return -1; + } *bctx = calloc(1, sizeof(**bctx)); - if (*bctx == NULL) + if (*bctx == NULL) { + bseterr("out of memory"); return -1; + } bops = bcompressops(); if (bops->open(*bctx, path, flags, mode, bpar) < 0) { @@ -62,8 +70,10 @@ bput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) { struct bops *bops; - if (bctx == NULL || buf == NULL || n == 0 || md == NULL) + if (bctx == NULL || buf == NULL || n == 0 || md == NULL) { + bseterr("invalid params"); return -1; + } bops = bcompressops(); return bops->put(bctx, buf, n, md); @@ -74,8 +84,10 @@ bget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) { struct bops *bops; - if (bctx == NULL || md == NULL || buf == NULL || n == NULL) + if (bctx == NULL || md == NULL || buf == NULL || n == NULL) { + bseterr("invalid params"); return -1; + } bops = bcompressops(); return bops->get(bctx, md, buf, n); @@ -86,8 +98,10 @@ brm(struct bctx *bctx, unsigned char *md) { struct bops *bops; - if (bctx == NULL || md == NULL) + if (bctx == NULL || md == NULL) { + bseterr("invalid params"); return -1; + } bops = bcompressops(); return bops->rm(bctx, md); @@ -98,8 +112,10 @@ bgc(struct bctx *bctx) { struct bops *bops; - if (bctx == NULL) + if (bctx == NULL) { + bseterr("invalid params"); return -1; + } bops = bcompressops(); return bops->gc(bctx); @@ -110,8 +126,10 @@ bcheck(struct bctx *bctx, unsigned char *md) { struct bops *bops; - if (bctx == NULL || md == NULL) + if (bctx == NULL || md == NULL) { + bseterr("invalid params"); return -1; + } bops = bcompressops(); return bops->check(bctx, md); @@ -122,8 +140,10 @@ bsync(struct bctx *bctx) { struct bops *bops; - if (bctx == NULL) + if (bctx == NULL) { + bseterr("invalid params"); return -1; + } bops = bcompressops(); return bops->sync(bctx); @@ -135,8 +155,10 @@ bclose(struct bctx *bctx) struct bops *bops; int r; - if (bctx == NULL) + if (bctx == NULL) { + bseterr("invalid params"); return -1; + } if (bsync(bctx) < 0) return -1;