dedup

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

commit 9220cd260336728228b3ece0f09864b171fd9217
parent 2b088f26ee40608a5ba20edc9175595939cdfa44
Author: sin <sin@2f30.org>
Date:   Wed, 21 Mar 2018 23:14:03 +0000

Use consistent style

Diffstat:
dedup.c | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -115,7 +115,7 @@ xread(int fd, void *buf, size_t nbytes) ssize_t n; n = read(fd, buf, nbytes); - if (n == -1) + if (n < 0) err(1, "read"); return n; } @@ -126,7 +126,7 @@ xwrite(int fd, const void *buf, size_t nbytes) ssize_t n; n = write(fd, buf, nbytes); - if (n == -1) + if (n < 0) err(1, "write"); return n; } @@ -234,7 +234,7 @@ storefile_nblks(void) { struct stat sb; - if (fstat(sfd, &sb) == -1) + if (fstat(sfd, &sb) < 0) err(1, "fstat"); return sb.st_size / sizeof(struct blk); } @@ -244,7 +244,7 @@ cachefile_nblks(void) { struct stat sb; - if (fstat(cfd, &sb) == -1) + if (fstat(cfd, &sb) < 0) err(1, "fstat"); return sb.st_size / sizeof(struct cache_data); } @@ -357,7 +357,7 @@ dedup(int fd) /* Prepare for adding a new block index for this entry */ ent = grow_ent(ent, ent->nblks + 1); - if (lookup_blk(&blk, &blkidx) == -1) { + if (lookup_blk(&blk, &blkidx) < 0) { struct cache_ent *cache_ent; blkidx = storefile_nblks(); @@ -495,18 +495,18 @@ init(void) struct stat sb; ifd = open(INDEXF, O_RDWR | O_CREAT, 0600); - if (ifd == -1) + if (ifd < 0) err(1, "open %s", INDEXF); sfd = open(STOREF, O_RDWR | O_CREAT, 0600); - if (sfd == -1) + if (sfd < 0) err(1, "open %s", STOREF); cfd = open(CACHEF, O_RDWR | O_CREAT, 0600); - if (cfd == -1) + if (cfd < 0) err(1, "open %s", CACHEF); - if (fstat(ifd, &sb) == -1) + if (fstat(ifd, &sb) < 0) err(1, "fstat %s", INDEXF); if (sb.st_size != 0) xread(ifd, &enthdr, sizeof(enthdr)); @@ -569,11 +569,11 @@ main(int argc, char *argv[]) } else if (argc == 1) { if (id) { fd = open(argv[0], O_RDWR | O_CREAT, 0600); - if (fd == -1) + if (fd < 0) err(1, "open %s", argv[0]); } else { fd = open(argv[0], O_RDONLY); - if (fd == -1) + if (fd < 0) err(1, "open %s", argv[0]); } } else {