dedup

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

commit 3fbc1d134902429f10721548d9a1d997a38d8ffe
parent 1f0d8ef4ab43be2906c3a2b3be7d4a70a3b138b7
Author: sin <sin@2f30.org>
Date:   Sat,  2 Mar 2019 13:53:26 +0000

Use *_SIZE instead of *_LEN

Diffstat:
Mdedup.c | 22+++++++++++-----------
Mdedup.h | 10+++++-----
Mtypes.c | 40++++++++++++++++++++--------------------
3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -106,13 +106,13 @@ print_stats(struct stats *st) static void append_snap(struct snapshot *snap) { - if (mul_overflow(snap->nr_blk_descs, BLK_DESC_LEN)) + if (mul_overflow(snap->nr_blk_descs, BLK_DESC_SIZE)) errx(1, "%s: overflow", __func__); - snap->size = snap->nr_blk_descs * BLK_DESC_LEN; + snap->size = snap->nr_blk_descs * BLK_DESC_SIZE; - if (add_overflow(SNAPSHOT_LEN, snap->size)) + if (add_overflow(SNAPSHOT_SIZE, snap->size)) errx(1, "%s: overflow", __func__); - snap->size += SNAPSHOT_LEN; + snap->size += SNAPSHOT_SIZE; xlseek(ifd, snap_hdr.size, SEEK_SET); write_snapshot(ifd, snap); @@ -460,9 +460,9 @@ load_cache(void) if (fstat(cfd, &sb) < 0) err(1, "fstat"); - nr_entries = sb.st_size / CACHE_ENTRY_LEN; + nr_entries = sb.st_size / CACHE_ENTRY_SIZE; if (nr_entries == 0) { - xlseek(ifd, SNAP_HDR_LEN, SEEK_SET); + xlseek(ifd, SNAP_HDR_SIZE, SEEK_SET); walk_snap(rebuild_cache, NULL); return; } @@ -488,7 +488,7 @@ static void init_blk_hdr(void) { blk_hdr.flags = (VER_MAJ << 8) | VER_MIN; - blk_hdr.size = BLK_HDR_LEN; + blk_hdr.size = BLK_HDR_SIZE; } static void @@ -509,7 +509,7 @@ static void init_snap_hdr(void) { snap_hdr.flags = (VER_MAJ << 8) | VER_MIN; - snap_hdr.size = SNAP_HDR_LEN; + snap_hdr.size = SNAP_HDR_SIZE; snap_hdr.st.min_blk_size = comp_size(BLKSIZE_MAX); } @@ -663,14 +663,14 @@ main(int argc, char *argv[]) } if (cflag) { - xlseek(ifd, SNAP_HDR_LEN, SEEK_SET); + xlseek(ifd, SNAP_HDR_SIZE, SEEK_SET); walk_snap(check, NULL); term(); return 0; } if (lflag) { - xlseek(ifd, SNAP_HDR_LEN, SEEK_SET); + xlseek(ifd, SNAP_HDR_SIZE, SEEK_SET); walk_snap(list, NULL); term(); return 0; @@ -679,7 +679,7 @@ main(int argc, char *argv[]) if (id) { struct extract_args args; - xlseek(ifd, SNAP_HDR_LEN, SEEK_SET); + xlseek(ifd, SNAP_HDR_SIZE, SEEK_SET); str2bin(id, md); args.md = md; args.fd = fd; diff --git a/dedup.h b/dedup.h @@ -6,11 +6,11 @@ * using the helpers from types.c. Any modification made to * the structs below will need to be reflected here and in types.c. */ -#define SNAP_HDR_LEN 104 -#define BLK_HDR_LEN 16 -#define BLK_DESC_LEN 48 -#define SNAPSHOT_LEN 304 -#define CACHE_ENTRY_LEN 48 +#define SNAP_HDR_SIZE 104 +#define BLK_HDR_SIZE 16 +#define BLK_DESC_SIZE 48 +#define SNAPSHOT_SIZE 304 +#define CACHE_ENTRY_SIZE 48 #define MSGSIZE 256 #define MDSIZE 32 diff --git a/types.c b/types.c @@ -9,7 +9,7 @@ void read_snap_hdr(int fd, struct snapshot_hdr *hdr) { - uint8_t buf[SNAP_HDR_LEN]; + uint8_t buf[SNAP_HDR_SIZE]; int n; if (xread(fd, buf, sizeof(buf)) == 0) @@ -34,13 +34,13 @@ read_snap_hdr(int fd, struct snapshot_hdr *hdr) &hdr->st.reserved[2], &hdr->st.reserved[3]); - assert(n == SNAP_HDR_LEN); + assert(n == SNAP_HDR_SIZE); } void write_snap_hdr(int fd, struct snapshot_hdr *hdr) { - uint8_t buf[SNAP_HDR_LEN]; + uint8_t buf[SNAP_HDR_SIZE]; int n; n = pack(buf, "qqq", @@ -62,14 +62,14 @@ write_snap_hdr(int fd, struct snapshot_hdr *hdr) hdr->st.reserved[2], hdr->st.reserved[3]); - assert(n == SNAP_HDR_LEN); + assert(n == SNAP_HDR_SIZE); xwrite(fd, buf, n); } void read_blk_hdr(int fd, struct blk_hdr *hdr) { - uint8_t buf[BLK_HDR_LEN]; + uint8_t buf[BLK_HDR_SIZE]; int n; if (xread(fd, buf, sizeof(buf)) == 0) @@ -79,27 +79,27 @@ read_blk_hdr(int fd, struct blk_hdr *hdr) &hdr->flags, &hdr->size); - assert(n == BLK_HDR_LEN); + assert(n == BLK_HDR_SIZE); } void write_blk_hdr(int fd, struct blk_hdr *hdr) { - uint8_t buf[BLK_HDR_LEN]; + uint8_t buf[BLK_HDR_SIZE]; int n; n = pack(buf, "qq", hdr->flags, hdr->size); - assert(n == BLK_HDR_LEN); + assert(n == BLK_HDR_SIZE); xwrite(fd, buf, n); } void read_blk_desc(int fd, struct blk_desc *desc) { - uint8_t buf[BLK_DESC_LEN]; + uint8_t buf[BLK_DESC_SIZE]; char fmt[BUFSIZ]; int n; @@ -112,13 +112,13 @@ read_blk_desc(int fd, struct blk_desc *desc) &desc->offset, &desc->size); - assert(n == BLK_DESC_LEN); + assert(n == BLK_DESC_SIZE); } void write_blk_desc(int fd, struct blk_desc *desc) { - uint8_t buf[BLK_DESC_LEN]; + uint8_t buf[BLK_DESC_SIZE]; char fmt[BUFSIZ]; int n; @@ -128,14 +128,14 @@ write_blk_desc(int fd, struct blk_desc *desc) desc->offset, desc->size); - assert(n == BLK_DESC_LEN); + assert(n == BLK_DESC_SIZE); xwrite(fd, buf, n); } void read_snapshot(int fd, struct snapshot *snap) { - uint8_t buf[SNAPSHOT_LEN]; + uint8_t buf[SNAPSHOT_SIZE]; char fmt[BUFSIZ]; int n; @@ -149,7 +149,7 @@ read_snapshot(int fd, struct snapshot *snap) snap->md, &snap->nr_blk_descs); - assert(n == SNAPSHOT_LEN); + assert(n == SNAPSHOT_SIZE); }; void @@ -164,7 +164,7 @@ read_snapshot_descs(int fd, struct snapshot *snap) void write_snapshot(int fd, struct snapshot *snap) { - uint8_t buf[SNAPSHOT_LEN]; + uint8_t buf[SNAPSHOT_SIZE]; char fmt[BUFSIZ]; int n; @@ -175,7 +175,7 @@ write_snapshot(int fd, struct snapshot *snap) snap->md, snap->nr_blk_descs); - assert(n == SNAPSHOT_LEN); + assert(n == SNAPSHOT_SIZE); xwrite(fd, buf, n); } @@ -191,7 +191,7 @@ write_snapshot_blk_descs(int fd, struct snapshot *snap) void read_cache_entry(int fd, struct cache_entry *cache_entry) { - uint8_t buf[CACHE_ENTRY_LEN]; + uint8_t buf[CACHE_ENTRY_SIZE]; char fmt[BUFSIZ]; int n; @@ -204,13 +204,13 @@ read_cache_entry(int fd, struct cache_entry *cache_entry) &cache_entry->offset, &cache_entry->size); - assert(n == CACHE_ENTRY_LEN); + assert(n == CACHE_ENTRY_SIZE); } void write_cache_entry(int fd, struct cache_entry *cache_entry) { - uint8_t buf[CACHE_ENTRY_LEN]; + uint8_t buf[CACHE_ENTRY_SIZE]; char fmt[BUFSIZ]; int n; @@ -220,6 +220,6 @@ write_cache_entry(int fd, struct cache_entry *cache_entry) cache_entry->offset, cache_entry->size); - assert(n == CACHE_ENTRY_LEN); + assert(n == CACHE_ENTRY_SIZE); xwrite(fd, buf, n); }