commit 5064abfd02125645e6099f376feca283e1edd745
parent 7d0f66f519a36d47db6919100238e74a5eeba713
Author: sin <sin@2f30.org>
Date: Thu, 16 May 2019 14:36:11 +0300
Fold checks into one
Diffstat:
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/block.c b/block.c
@@ -147,20 +147,13 @@ bcheck(struct bctx *bctx, unsigned char *md)
}
n = BSIZEMAX;
- if (bcompressops()->get(bctx, md, buf, &n) < 0) {
+ if (bcompressops()->get(bctx, md, buf, &n) < 0 ||
+ bhash(buf, n, tmp) < 0 ||
+ memcmp(tmp, md, MDSIZE) != 0) {
free(buf);
return -1;
}
- if (bhash(buf, n, tmp) < 0) {
- free(buf);
- return -1;
- }
-
- if (memcmp(tmp, md, MDSIZE) != 0) {
- free(buf);
- return -1;
- }
free(buf);
return 0;
}