dedup

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

commit 6fa8f387de8c032029f8a3e9994d5ac5be5c7670
parent 41eca06f70153b7adc9364f35ece24fd628a96dd
Author: sin <sin@2f30.org>
Date:   Mon, 25 Feb 2019 09:51:58 +0000

Use local variable

Diffstat:
Mdedup.c | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -295,11 +295,12 @@ extract(struct snapshot *snap, void *arg) buf[0] = alloc_buf(BLKSIZE_MAX); buf[1] = alloc_buf(comp_size(BLKSIZE_MAX)); for (i = 0; i < snap->nr_blk_descs; i++) { + struct blk_desc *blk_desc; size_t blksize; - read_blk(buf[1], &snap->blk_desc[i]); - blksize = decomp(buf[1], buf[0], snap->blk_desc[i].size, - BLKSIZE_MAX); + blk_desc = &snap->blk_desc[i]; + read_blk(buf[1], blk_desc); + blksize = decomp(buf[1], buf[0], blk_desc->size, BLKSIZE_MAX); xwrite(args->fd, buf[0], blksize); } free_buf(buf[1]); @@ -321,14 +322,16 @@ check(struct snapshot *snap, void *arg) * against snapshot entry block descriptor */ for (i = 0; i < snap->nr_blk_descs; i++) { - read_blk(buf, &snap->blk_desc[i]); + struct blk_desc *blk_desc; + + blk_desc = &snap->blk_desc[i]; + read_blk(buf, blk_desc); SHA256_Init(&ctx); - SHA256_Update(&ctx, buf, snap->blk_desc[i].size); + SHA256_Update(&ctx, buf, blk_desc->size); SHA256_Final(md, &ctx); - if (memcmp(snap->blk_desc[i].md, md, - sizeof(snap->blk_desc[i]).md) == 0) + if (memcmp(blk_desc->md, md, sizeof(blk_desc->md)) == 0) continue; fprintf(stderr, "Block hash mismatch\n"); @@ -339,9 +342,9 @@ check(struct snapshot *snap, void *arg) print_md(stderr, md, sizeof(md)); fputc('\n', stderr); fprintf(stderr, " Offset: %llu\n", - (unsigned long long)snap->blk_desc[i].offset); + (unsigned long long)blk_desc->offset); fprintf(stderr, " Size: %llu\n", - (unsigned long long)snap->blk_desc[i].size); + (unsigned long long)blk_desc->size); } free_buf(buf); return WALK_CONTINUE;