diff options
author | Daiki Ueno <ueno@gnu.org> | 2021-04-23 09:50:16 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2021-04-23 09:50:16 +0200 |
commit | 79d0ffdefc592be847f26520e4dbd954b3faff2e (patch) | |
tree | 39195a41666b121d8cd2b155ce36111782b04261 | |
parent | ff797edab9f1a76aafb8c17bde3c607862921b87 (diff) | |
download | gnutls-79d0ffdefc592be847f26520e4dbd954b3faff2e.tar.gz |
afalg: remove unnecessary initialization
That would make it easier to spot any uninitialized memory access with
valgrind.
Signed-off-by: Daiki Ueno <ueno@gnu.org>
-rw-r--r-- | lib/accelerated/afalg.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/accelerated/afalg.c b/lib/accelerated/afalg.c index 138ce9e717..b96aadf1aa 100644 --- a/lib/accelerated/afalg.c +++ b/lib/accelerated/afalg.c @@ -54,7 +54,7 @@ static const char *gnutls_cipher_map[] = { static int afalg_cipher_init(gnutls_cipher_algorithm_t algorithm, void **_ctx, int enc) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; struct kcapi_ctx *ctx; if (kcapi_cipher_init(&handle, gnutls_cipher_map[algorithm], 0) < 0) { @@ -67,7 +67,7 @@ afalg_cipher_init(gnutls_cipher_algorithm_t algorithm, void **_ctx, int enc) return GNUTLS_E_INTERNAL_ERROR; } - ctx = (struct kcapi_ctx *)gnutls_calloc(1, sizeof(struct kcapi_ctx)); + ctx = gnutls_malloc(sizeof(struct kcapi_ctx)); if (ctx == NULL) { gnutls_assert(); kcapi_cipher_destroy(handle); @@ -196,7 +196,7 @@ static int afalg_cipher_register(void) for (i = 0; i < sizeof(gnutls_cipher_map) / sizeof(gnutls_cipher_map[0]); i++) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; if (gnutls_cipher_map[i] == 0) continue; @@ -249,7 +249,7 @@ static void afalg_aead_deinit(void *_ctx) static int afalg_aead_init(gnutls_cipher_algorithm_t algorithm, void **_ctx, int enc) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; struct kcapi_aead_ctx *ctx; if (kcapi_aead_init(&handle, gnutls_aead_map[algorithm], 0) < 0) { @@ -257,8 +257,7 @@ afalg_aead_init(gnutls_cipher_algorithm_t algorithm, void **_ctx, int enc) return GNUTLS_E_MEMORY_ERROR; } - ctx = (struct kcapi_aead_ctx *)gnutls_calloc(1, - sizeof(struct kcapi_aead_ctx)); + ctx = gnutls_malloc(sizeof(struct kcapi_aead_ctx)); if (ctx == NULL) { gnutls_assert(); kcapi_aead_destroy(handle); @@ -531,7 +530,7 @@ static int afalg_aead_register(void) for (i = 0; i < sizeof(gnutls_aead_map) / sizeof(gnutls_aead_map[0]); i++) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; if (gnutls_aead_map[i] == 0) continue; @@ -567,7 +566,7 @@ static const char *gnutls_mac_map[] = { static int afalg_mac_init(gnutls_mac_algorithm_t algorithm, void **ctx) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; if (kcapi_md_init(&handle, gnutls_mac_map[algorithm], 0) < 0) { gnutls_assert(); @@ -636,7 +635,7 @@ static int afalg_mac_fast(gnutls_mac_algorithm_t algorithm, const void *nonce, size_t nonce_size, const void *key, size_t keysize, const void *text, size_t textsize, void *digest) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; int ret = GNUTLS_E_ENCRYPTION_FAILED; if (kcapi_md_init(&handle, gnutls_mac_map[algorithm], 0) < 0) { @@ -693,7 +692,7 @@ static int afalg_mac_register(void) for (i = 0; i < sizeof(gnutls_mac_map) / sizeof(gnutls_mac_map[0]); i++) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; if (gnutls_mac_map[i] == 0) continue; @@ -729,7 +728,7 @@ static const char *gnutls_digest_map[] = { static int afalg_digest_init(gnutls_digest_algorithm_t algorithm, void **ctx) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; if (kcapi_md_init(&handle, gnutls_digest_map[algorithm], 0) < 0) { gnutls_assert(); @@ -744,7 +743,7 @@ static int afalg_digest_init(gnutls_digest_algorithm_t algorithm, void **ctx) static int afalg_digest_fast(gnutls_digest_algorithm_t algorithm, const void *text, size_t textsize, void *digest) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; int ret = GNUTLS_E_ENCRYPTION_FAILED; if (kcapi_md_init(&handle, gnutls_digest_map[algorithm], 0) < 0) { @@ -795,7 +794,7 @@ static int afalg_digest_register(void) for (i = 0; i < sizeof(gnutls_digest_map) / sizeof(gnutls_digest_map[0]); i++) { - struct kcapi_handle *handle = NULL; + struct kcapi_handle *handle; if (gnutls_digest_map[i] == 0) continue; |