]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
afalg: remove unnecessary initialization
authorDaiki Ueno <ueno@gnu.org>
Fri, 23 Apr 2021 07:50:16 +0000 (09:50 +0200)
committerDaiki Ueno <ueno@gnu.org>
Fri, 23 Apr 2021 07:50:16 +0000 (09:50 +0200)
That would make it easier to spot any uninitialized memory access with
valgrind.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/accelerated/afalg.c

index 138ce9e71765da1d2312092d18e627ae99860975..b96aadf1aaaaa9bc289a2cad1c997a98876827f9 100644 (file)
@@ -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;