From 90ad284f4e76254f8d67686ae3a5d6c576037091 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 12 May 2020 10:27:46 +0200 Subject: PROV: make some DER AID arrays non-static, to avoid clang complaints The problem encountered is that some arrays were deemed unnecessary by clang, for example: providers/common/der/der_rsa.c:424:28: error: variable 'der_aid_sha224Identifier' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static const unsigned char der_aid_sha224Identifier[] = { ^ However, these arrays are used in sizeof() expressions in other parts of the code that's actually used, making that warning-turned-error a practical problem. We solve this by making the array non-static, which guarantees that the arrays will be emitted, even though unnecessarily. Fortunately, they are very small. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/11710) --- providers/common/der/der_rsa.c.in | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'providers') diff --git a/providers/common/der/der_rsa.c.in b/providers/common/der/der_rsa.c.in index d3bab85d1f..30e945cf58 100644 --- a/providers/common/der/der_rsa.c.in +++ b/providers/common/der/der_rsa.c.in @@ -50,13 +50,20 @@ * sha384Identifier AlgorithmIdentifier ::= { id-sha384, NULL } * sha512Identifier AlgorithmIdentifier ::= { id-sha512, NULL } */ +/* + * NOTE: Some of the arrays aren't used other than inside sizeof(), which + * clang complains about (-Wno-unneeded-internal-declaration). To get + * around that, we make them non-static, and declare them an extra time to + * avoid compilers complaining about definitions without declarations. + */ #if 0 /* Currently unused */ #define DER_AID_V_sha1Identifier \ DER_P_SEQUENCE|DER_F_CONSTRUCTED, \ DER_OID_SZ_id_sha1 + DER_SZ_NULL, \ DER_OID_V_id_sha1, \ DER_V_NULL -static const unsigned char der_aid_sha1Identifier[] = { +extern const unsigned char der_aid_sha1Identifier[]; +const unsigned char der_aid_sha1Identifier[] = { DER_AID_V_sha1Identifier }; #define DER_AID_SZ_sha1Identifier sizeof(der_aid_sha1Identifier) @@ -67,7 +74,8 @@ static const unsigned char der_aid_sha1Identifier[] = { DER_OID_SZ_id_sha224 + DER_SZ_NULL, \ DER_OID_V_id_sha224, \ DER_V_NULL -static const unsigned char der_aid_sha224Identifier[] = { +extern const unsigned char der_aid_sha224Identifier[]; +const unsigned char der_aid_sha224Identifier[] = { DER_AID_V_sha224Identifier }; #define DER_AID_SZ_sha224Identifier sizeof(der_aid_sha224Identifier) @@ -77,7 +85,8 @@ static const unsigned char der_aid_sha224Identifier[] = { DER_OID_SZ_id_sha256 + DER_SZ_NULL, \ DER_OID_V_id_sha256, \ DER_V_NULL -static const unsigned char der_aid_sha256Identifier[] = { +extern const unsigned char der_aid_sha256Identifier[]; +const unsigned char der_aid_sha256Identifier[] = { DER_AID_V_sha256Identifier }; #define DER_AID_SZ_sha256Identifier sizeof(der_aid_sha256Identifier) @@ -87,7 +96,8 @@ static const unsigned char der_aid_sha256Identifier[] = { DER_OID_SZ_id_sha384 + DER_SZ_NULL, \ DER_OID_V_id_sha384, \ DER_V_NULL -static const unsigned char der_aid_sha384Identifier[] = { +extern const unsigned char der_aid_sha384Identifier[]; +const unsigned char der_aid_sha384Identifier[] = { DER_AID_V_sha384Identifier }; #define DER_AID_SZ_sha384Identifier sizeof(der_aid_sha384Identifier) @@ -97,7 +107,8 @@ static const unsigned char der_aid_sha384Identifier[] = { DER_OID_SZ_id_sha512 + DER_SZ_NULL, \ DER_OID_V_id_sha512, \ DER_V_NULL -static const unsigned char der_aid_sha512Identifier[] = { +extern const unsigned char der_aid_sha512Identifier[]; +const unsigned char der_aid_sha512Identifier[] = { DER_AID_V_sha512Identifier }; #define DER_AID_SZ_sha512Identifier sizeof(der_aid_sha512Identifier) @@ -107,7 +118,8 @@ static const unsigned char der_aid_sha512Identifier[] = { DER_OID_SZ_id_sha512_224 + DER_SZ_NULL, \ DER_OID_V_id_sha512_224, \ DER_V_NULL -static const unsigned char der_aid_sha512_224Identifier[] = { +extern const unsigned char der_aid_sha512_224Identifier[]; +const unsigned char der_aid_sha512_224Identifier[] = { DER_AID_V_sha512_224Identifier }; #define DER_AID_SZ_sha512_224Identifier sizeof(der_aid_sha512_224Identifier) @@ -117,7 +129,8 @@ static const unsigned char der_aid_sha512_224Identifier[] = { DER_OID_SZ_id_sha512_256 + DER_SZ_NULL, \ DER_OID_V_id_sha512_256, \ DER_V_NULL -static const unsigned char der_aid_sha512_256Identifier[] = { +extern const unsigned char der_aid_sha512_256Identifier[]; +const unsigned char der_aid_sha512_256Identifier[] = { DER_AID_V_sha512_256Identifier }; #define DER_AID_SZ_sha512_256Identifier sizeof(der_aid_sha512_256Identifier) -- cgit v1.2.3