diff options
author | pjd <pjd@FreeBSD.org> | 2011-12-15 22:03:17 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-12-15 22:03:17 +0000 |
commit | 91f3438889ab17eaa33e9ce6eef2de5870a6e77f (patch) | |
tree | 6b3a39c0b8e233b9d63de9f90f33acd2b9b3f8e9 | |
parent | a852ec0ef9cf5eaf7b41fa570bc5bc8e25a6a356 (diff) | |
download | FreeBSD-src-91f3438889ab17eaa33e9ce6eef2de5870a6e77f.zip FreeBSD-src-91f3438889ab17eaa33e9ce6eef2de5870a6e77f.tar.gz |
Simplify code by changing functions types from int to avoid, as the functions
always return 0.
Found by: Clang Static Analyzer
MFC after: 1 week
-rw-r--r-- | sbin/hastd/hast_checksum.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/sbin/hastd/hast_checksum.c b/sbin/hastd/hast_checksum.c index 1133aea..795744e 100644 --- a/sbin/hastd/hast_checksum.c +++ b/sbin/hastd/hast_checksum.c @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #define MAX_HASH_SIZE 4 #endif -static int +static void hast_crc32_checksum(const unsigned char *data, size_t size, unsigned char *hash, size_t *hsizep) { @@ -58,12 +58,10 @@ hast_crc32_checksum(const unsigned char *data, size_t size, /* XXXPJD: Do we have to use htole32() on crc first? */ bcopy(&crc, hash, sizeof(crc)); *hsizep = sizeof(crc); - - return (0); } #ifdef HAVE_CRYPTO -static int +static void hast_sha256_checksum(const unsigned char *data, size_t size, unsigned char *hash, size_t *hsizep) { @@ -73,8 +71,6 @@ hast_sha256_checksum(const unsigned char *data, size_t size, SHA256_Update(&ctx, data, size); SHA256_Final(hash, &ctx); *hsizep = SHA256_DIGEST_LENGTH; - - return (0); } #endif /* HAVE_CRYPTO */ @@ -99,25 +95,21 @@ checksum_send(const struct hast_resource *res, struct nv *nv, void **datap, { unsigned char hash[MAX_HASH_SIZE]; size_t hsize; - int ret; switch (res->hr_checksum) { case HAST_CHECKSUM_NONE: return (0); case HAST_CHECKSUM_CRC32: - ret = hast_crc32_checksum(*datap, *sizep, hash, &hsize); + hast_crc32_checksum(*datap, *sizep, hash, &hsize); break; #ifdef HAVE_CRYPTO case HAST_CHECKSUM_SHA256: - ret = hast_sha256_checksum(*datap, *sizep, hash, &hsize); + hast_sha256_checksum(*datap, *sizep, hash, &hsize); break; #endif default: PJDLOG_ABORT("Invalid checksum: %d.", res->hr_checksum); } - - if (ret != 0) - return (ret); nv_add_string(nv, checksum_name(res->hr_checksum), "checksum"); nv_add_uint8_array(nv, hash, hsize, "hash"); if (nv_error(nv) != 0) { @@ -135,7 +127,6 @@ checksum_recv(const struct hast_resource *res __unused, struct nv *nv, const unsigned char *rhash; size_t chsize, rhsize; const char *algo; - int ret; algo = nv_get_string(nv, "checksum"); if (algo == NULL) @@ -146,10 +137,10 @@ checksum_recv(const struct hast_resource *res __unused, struct nv *nv, return (-1); /* Hash not found. */ } if (strcmp(algo, "crc32") == 0) - ret = hast_crc32_checksum(*datap, *sizep, chash, &chsize); + hast_crc32_checksum(*datap, *sizep, chash, &chsize); #ifdef HAVE_CRYPTO else if (strcmp(algo, "sha256") == 0) - ret = hast_sha256_checksum(*datap, *sizep, chash, &chsize); + hast_sha256_checksum(*datap, *sizep, chash, &chsize); #endif else { pjdlog_error("Unknown checksum algorithm '%s'.", algo); |