dedup

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

commit ff783e2a9af6d97d55697d654d759ca48d6a28a1
parent 1dd953c0a3654c65c1bade8096a234e51caed46c
Author: sin <sin@2f30.org>
Date:   Sat, 27 Apr 2019 18:30:41 +0100

Reorder some code in bscheck()

Diffstat:
Mbstorage.c | 15+++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/bstorage.c b/bstorage.c @@ -630,14 +630,12 @@ bscheck(struct bctx *bctx, unsigned char *md) if (bd == NULL) return -1; - buf = malloc(bd->size); - if (buf == NULL) + if (lseek(sctx->fd, bd->offset, SEEK_SET) < 0) return -1; - if (lseek(sctx->fd, bd->offset, SEEK_SET) < 0) { - free(buf); + buf = malloc(bd->size); + if (buf == NULL) return -1; - } if (xread(sctx->fd, buf, bd->size) != bd->size) { free(buf); @@ -648,13 +646,10 @@ bscheck(struct bctx *bctx, unsigned char *md) free(buf); return -1; } + free(buf); - if (memcmp(key.md, md, MDSIZE) != 0) { - free(buf); + if (memcmp(key.md, md, MDSIZE) != 0) return -1; - } - - free(buf); return 0; }