dedup

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

commit 7dbf6de1389b8b7b56017da2ff20fcdfccb40ca4
parent 4254c18ccefe1aec0ed1bae902202e0ca5f8ad10
Author: sin <sin@2f30.org>
Date:   Mon, 20 May 2019 13:02:05 +0300

No need to call strerror() for malloc()/calloc() failure

Diffstat:
Mbcompress.c | 9++++-----
Mbencrypt.c | 9++++-----
Mblock.c | 5++---
Mbstorage.c | 12++++++------
Msnap.c | 10+++++-----
5 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/bcompress.c b/bcompress.c @@ -3,7 +3,6 @@ #include <sys/stat.h> #include <assert.h> -#include <errno.h> #include <fcntl.h> #include <stdint.h> #include <stdio.h> @@ -111,7 +110,7 @@ bccreat(struct bctx *bctx, char *path, int mode) bctx->cctx = calloc(1, sizeof(struct cctx)); if (bctx->cctx == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } cctx = bctx->cctx; @@ -143,7 +142,7 @@ bcopen(struct bctx *bctx, char *path, int flags, int mode) bctx->cctx = calloc(1, sizeof(struct cctx)); if (bctx->cctx == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } cctx = bctx->cctx; @@ -181,7 +180,7 @@ bcput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) cbuf = malloc(CDSIZE + cn); if (cbuf == NULL) { - seterr("malloc: %s", strerror(errno)); + seterr("malloc: out of memory"); return -1; } @@ -244,7 +243,7 @@ bcget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) cbuf = malloc(size); if (cbuf == NULL) { - seterr("malloc: %s", strerror(errno)); + seterr("malloc: out of memory"); return -1; } diff --git a/bencrypt.c b/bencrypt.c @@ -3,7 +3,6 @@ #include <sys/stat.h> #include <assert.h> -#include <errno.h> #include <fcntl.h> #include <stdint.h> #include <stdio.h> @@ -122,7 +121,7 @@ becreat(struct bctx *bctx, char *path, int mode) bctx->ectx = calloc(1, sizeof(struct ectx)); if (bctx->ectx == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } ectx = bctx->ectx; @@ -164,7 +163,7 @@ beopen(struct bctx *bctx, char *path, int flags, int mode) bctx->ectx = calloc(1, sizeof(struct ectx)); if (bctx->ectx == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } ectx = bctx->ectx; @@ -199,7 +198,7 @@ beput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) ebuf = malloc(EDSIZE + en); if (ebuf == NULL) { - seterr("malloc: %s", strerror(errno)); + seterr("malloc: out of memory"); return -1; } @@ -257,7 +256,7 @@ beget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) ebuf = malloc(size); if (ebuf == NULL) { - seterr("malloc: %s", strerror(errno)); + seterr("malloc: out of memory"); return -1; } diff --git a/block.c b/block.c @@ -2,7 +2,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <errno.h> #include <fcntl.h> #include <stdint.h> #include <stdio.h> @@ -36,7 +35,7 @@ bcreat(char *path, int mode, struct bctx **bctx) *bctx = calloc(1, sizeof(**bctx)); if (*bctx == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -62,7 +61,7 @@ bopen(char *path, int flags, int mode, struct bctx **bctx) *bctx = calloc(1, sizeof(**bctx)); if (*bctx == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } diff --git a/bstorage.c b/bstorage.c @@ -191,7 +191,7 @@ loadbd(struct sctx *sctx) bd = calloc(1, sizeof(*bd)); if (bd == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -282,7 +282,7 @@ bscreat(struct bctx *bctx, char *path, int mode) bctx->sctx = calloc(1, sizeof(struct sctx)); if (bctx->sctx == NULL) { close(fd); - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -336,7 +336,7 @@ bsopen(struct bctx *bctx, char *path, int flags, int mode) bctx->sctx = calloc(1, sizeof(struct sctx)); if (bctx->sctx == NULL) { close(fd); - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -428,7 +428,7 @@ bsput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) bd = calloc(1, sizeof(*bd)); if (bd == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } bd->type = BDTYPE; @@ -479,7 +479,7 @@ bsget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) memcpy(key.md, md, MDSIZE); bd = RB_FIND(bdcache, &sctx->bdcache, &key); if (bd == NULL) { - seterr("unknown block"); + seterr("block not found"); return -1; } @@ -513,7 +513,7 @@ bsrm(struct bctx *bctx, unsigned char *md) memcpy(key.md, md, MDSIZE); bd = RB_FIND(bdcache, &sctx->bdcache, &key); if (bd == NULL) { - seterr("unknown block"); + seterr("block not found"); return -1; } diff --git a/snap.c b/snap.c @@ -104,7 +104,7 @@ loadmdnone(struct sctx *sctx, int first) mdnode = calloc(1, sizeof(*mdnode)); if (mdnode == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -142,7 +142,7 @@ loadmdchacha(struct sctx *sctx, int first) mdnode = calloc(1, sizeof(*mdnode)); if (mdnode == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -230,7 +230,7 @@ screat(char *path, int mode, struct sctx **sctx) *sctx = calloc(1, sizeof(**sctx)); if (*sctx == NULL) { close(fd); - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -303,7 +303,7 @@ sopen(char *path, int flags, int mode, struct sctx **sctx) *sctx = calloc(1, sizeof(**sctx)); if (*sctx == NULL) { close(fd); - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } @@ -359,7 +359,7 @@ sput(struct sctx *sctx, unsigned char *md) mdnode = calloc(1, sizeof(*mdnode)); if (mdnode == NULL) { - seterr("calloc: %s", strerror(errno)); + seterr("calloc: out of memory"); return -1; } shdr = &sctx->shdr;