From 225c9660a5a3435d9bcfc9166b9f79f132996249 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 10 Sep 2020 16:34:17 +0100 Subject: [PATCH] Ignore unused return values from some sk_*() macros Some compilers are very picky about unused return values. Reviewed-by: Richard Levitte Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/12781) --- crypto/ex_data.c | 6 +++++- crypto/property/property.c | 2 +- crypto/x509/v3_addr.c | 2 +- crypto/x509/x509_vfy.c | 2 +- crypto/x509/x_name.c | 2 +- ssl/ssl_ciph.c | 2 +- test/stack_test.c | 4 ++-- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crypto/ex_data.c b/crypto/ex_data.c index cc9ebc36f4..c1467a51dc 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -445,7 +445,11 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val) return 0; } } - sk_void_set(ad->sk, idx, val); + if (sk_void_set(ad->sk, idx, val) != val) { + /* Probably the index is out of bounds */ + CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_PASSED_INVALID_ARGUMENT); + return 0; + } return 1; } diff --git a/crypto/property/property.c b/crypto/property/property.c index 608a909d49..c2238ac63d 100644 --- a/crypto/property/property.c +++ b/crypto/property/property.c @@ -316,7 +316,7 @@ int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid, if (impl->method.method == method) { impl_free(impl); - sk_IMPLEMENTATION_delete(alg->impls, i); + (void)sk_IMPLEMENTATION_delete(alg->impls, i); ossl_property_unlock(store); return 1; } diff --git a/crypto/x509/v3_addr.c b/crypto/x509/v3_addr.c index 64127cff6b..7d4e99be5a 100644 --- a/crypto/x509/v3_addr.c +++ b/crypto/x509/v3_addr.c @@ -1257,7 +1257,7 @@ static int addr_validate_path_internal(X509_STORE_CTX *ctx, || addr_contains(fp->ipAddressChoice->u.addressesOrRanges, fc->ipAddressChoice->u.addressesOrRanges, length_from_afi(X509v3_addr_get_afi(fc)))) - sk_IPAddressFamily_set(child, j, fp); + (void)sk_IPAddressFamily_set(child, j, fp); else validation_err(X509_V_ERR_UNNESTED_RESOURCE); } diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index d4a085ddb0..5520f08e28 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -1683,7 +1683,7 @@ static int check_policy(X509_STORE_CTX *ctx) ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain, ctx->param->policies, ctx->param->flags); if (ctx->bare_ta_signed) - sk_X509_pop(ctx->chain); + (void)sk_X509_pop(ctx->chain); if (ret == X509_PCY_TREE_INTERNAL) { X509err(X509_F_CHECK_POLICY, ERR_R_MALLOC_FAILURE); diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c index 692bd6566a..a85b10f1cf 100644 --- a/crypto/x509/x_name.c +++ b/crypto/x509/x_name.c @@ -186,7 +186,7 @@ static int x509_name_ex_d2i(ASN1_VALUE **val, entry->set = i; if (!sk_X509_NAME_ENTRY_push(nm.x->entries, entry)) goto err; - sk_X509_NAME_ENTRY_set(entries, j, NULL); + (void)sk_X509_NAME_ENTRY_set(entries, j, NULL); } } ret = x509_name_canon(nm.x); diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 05add36d47..b8d22a72ce 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -1379,7 +1379,7 @@ static int update_cipher_list(STACK_OF(SSL_CIPHER) **cipher_list, while (sk_SSL_CIPHER_num(tmp_cipher_list) > 0 && sk_SSL_CIPHER_value(tmp_cipher_list, 0)->min_tls == TLS1_3_VERSION) - sk_SSL_CIPHER_delete(tmp_cipher_list, 0); + (void)sk_SSL_CIPHER_delete(tmp_cipher_list, 0); /* Insert the new TLSv1.3 ciphersuites */ for (i = 0; i < sk_SSL_CIPHER_num(tls13_ciphersuites); i++) diff --git a/test/stack_test.c b/test/stack_test.c index 1f4cb1cafa..3aa0b08a43 100644 --- a/test/stack_test.c +++ b/test/stack_test.c @@ -131,7 +131,7 @@ static int test_int_stack(int reserve) /* sorting */ if (!TEST_false(sk_sint_is_sorted(s))) goto end; - sk_sint_set_cmp_func(s, &int_compare); + (void)sk_sint_set_cmp_func(s, &int_compare); sk_sint_sort(s); if (!TEST_true(sk_sint_is_sorted(s))) goto end; @@ -237,7 +237,7 @@ static int test_uchar_stack(int reserve) goto end; /* set */ - sk_uchar_set(r, 1, v + 1); + (void)sk_uchar_set(r, 1, v + 1); for (i = 0; i < 2; i++) if (!TEST_ptr_eq(sk_uchar_value(r, i), v + i)) { TEST_info("uchar set %d", i);