Merge pull request #4286 from douzzer/cryptocb-pedantic-c99

--enable-cryptocb CFLAGS='-std=c99 -pedantic'
This commit is contained in:
David Garske
2021-08-09 08:29:36 -07:00
committed by GitHub
4 changed files with 41 additions and 7 deletions

View File

@@ -34338,7 +34338,7 @@ static void test_wolfSSL_HMAC(void)
#endif #endif
} }
static void test_wolfSSL_CMAC() static void test_wolfSSL_CMAC(void)
{ {
#if defined(OPENSSL_EXTRA) && defined(WOLFSSL_CMAC) #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_CMAC)
@@ -36727,7 +36727,7 @@ static int check_result(unsigned char *data, int len)
static int r_offset; static int r_offset;
static int w_offset; static int w_offset;
static void init_offset() static void init_offset(void)
{ {
r_offset = 0; r_offset = 0;
w_offset = 0; w_offset = 0;
@@ -46558,7 +46558,7 @@ static void test_wolfSSL_ERR_strings(void)
printf(resultFmt, passed); printf(resultFmt, passed);
#endif #endif
} }
static void test_wolfSSL_EVP_shake128() static void test_wolfSSL_EVP_shake128(void)
{ {
#if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA3) && \ #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA3) && \
defined(WOLFSSL_SHAKE128) defined(WOLFSSL_SHAKE128)
@@ -46571,7 +46571,7 @@ static void test_wolfSSL_EVP_shake128()
#endif #endif
} }
static void test_wolfSSL_EVP_shake256() static void test_wolfSSL_EVP_shake256(void)
{ {
#if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA3) && \ #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SHA3) && \
defined(WOLFSSL_SHAKE256) defined(WOLFSSL_SHAKE256)
@@ -46584,7 +46584,7 @@ static void test_wolfSSL_EVP_shake256()
#endif #endif
} }
static void test_EVP_blake2() static void test_EVP_blake2(void)
{ {
#if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)) #if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S))
printf(testingFmt, "test_EVP_blake2"); printf(testingFmt, "test_EVP_blake2");
@@ -46645,7 +46645,7 @@ static void list_md_fn(const EVP_MD* m, const char* from,
} }
#endif #endif
static void test_EVP_MD_do_all() static void test_EVP_MD_do_all(void)
{ {
#if defined(OPENSSL_EXTRA) #if defined(OPENSSL_EXTRA)
printf(testingFmt, "test_EVP_MD_do_all"); printf(testingFmt, "test_EVP_MD_do_all");
@@ -46683,7 +46683,7 @@ static void obj_name_t(const OBJ_NAME* nm, void* arg)
} }
#endif #endif
static void test_OBJ_NAME_do_all() static void test_OBJ_NAME_do_all(void)
{ {
#if defined(OPENSSL_EXTRA) #if defined(OPENSSL_EXTRA)
printf(testingFmt, "test_OBJ_NAME_do_all"); printf(testingFmt, "test_OBJ_NAME_do_all");

View File

@@ -75,10 +75,15 @@
/* Crypto Information Structure for callbacks */ /* Crypto Information Structure for callbacks */
typedef struct wc_CryptoInfo { typedef struct wc_CryptoInfo {
int algo_type; /* enum wc_AlgoType */ int algo_type; /* enum wc_AlgoType */
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
union {
#endif
#if !defined(NO_RSA) || defined(HAVE_ECC) #if !defined(NO_RSA) || defined(HAVE_ECC)
struct { struct {
int type; /* enum wc_PkType */ int type; /* enum wc_PkType */
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
union { union {
#endif
#ifndef NO_RSA #ifndef NO_RSA
struct { struct {
const byte* in; const byte* in;
@@ -182,14 +187,18 @@ typedef struct wc_CryptoInfo {
byte contextLen; byte contextLen;
} ed25519verify; } ed25519verify;
#endif #endif
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
}; };
#endif
} pk; } pk;
#endif /* !NO_RSA || HAVE_ECC */ #endif /* !NO_RSA || HAVE_ECC */
#if !defined(NO_AES) || !defined(NO_DES3) #if !defined(NO_AES) || !defined(NO_DES3)
struct { struct {
int type; /* enum wc_CipherType */ int type; /* enum wc_CipherType */
int enc; int enc;
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
union { union {
#endif
#ifdef HAVE_AESGCM #ifdef HAVE_AESGCM
struct { struct {
Aes* aes; Aes* aes;
@@ -232,7 +241,9 @@ typedef struct wc_CryptoInfo {
word32 sz; word32 sz;
} des3; } des3;
#endif #endif
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
}; };
#endif
} cipher; } cipher;
#endif /* !NO_AES || !NO_DES3 */ #endif /* !NO_AES || !NO_DES3 */
#if !defined(NO_SHA) || !defined(NO_SHA256) || \ #if !defined(NO_SHA) || !defined(NO_SHA256) || \
@@ -242,7 +253,9 @@ typedef struct wc_CryptoInfo {
const byte* in; const byte* in;
word32 inSz; word32 inSz;
byte* digest; byte* digest;
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
union { union {
#endif
#ifndef NO_SHA #ifndef NO_SHA
wc_Sha* sha1; wc_Sha* sha1;
#endif #endif
@@ -255,7 +268,9 @@ typedef struct wc_CryptoInfo {
#ifdef WOLFSSL_SHA512 #ifdef WOLFSSL_SHA512
wc_Sha512* sha512; wc_Sha512* sha512;
#endif #endif
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
}; };
#endif
} hash; } hash;
#endif /* !NO_SHA || !NO_SHA256 */ #endif /* !NO_SHA || !NO_SHA256 */
#ifndef NO_HMAC #ifndef NO_HMAC
@@ -292,6 +307,9 @@ typedef struct wc_CryptoInfo {
int type; int type;
} cmac; } cmac;
#endif #endif
#if HAVE_ANONYMOUS_INLINE_AGGREGATES
};
#endif
} wc_CryptoInfo; } wc_CryptoInfo;

View File

@@ -95,6 +95,17 @@ decouple library dependencies with standard string, memory and so on.
typedef const char* const wcchar; typedef const char* const wcchar;
#endif #endif
#ifndef HAVE_ANONYMOUS_INLINE_AGGREGATES
/* if __STDC__, pivot on the version, otherwise guess it's allowed,
* subject to override.
*/
#if !defined(__STDC__) \
|| (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201101L))
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 1
#else
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 0
#endif
#endif
/* try to set SIZEOF_LONG or SIZEOF_LONG_LONG if user didn't */ /* try to set SIZEOF_LONG or SIZEOF_LONG_LONG if user didn't */
#if defined(_MSC_VER) || defined(HAVE_LIMITS_H) #if defined(_MSC_VER) || defined(HAVE_LIMITS_H)

View File

@@ -130,6 +130,11 @@
_Pragma("GCC diagnostic pop"); _Pragma("GCC diagnostic pop");
/* the kernel uses -std=c89, but not -pedantic, and makes full use of anon
* structs/unions, so we should too.
*/
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 1
/* Linux headers define these using C expressions, but we need /* Linux headers define these using C expressions, but we need
* them to be evaluable by the preprocessor, for use in sp_int.h. * them to be evaluable by the preprocessor, for use in sp_int.h.
*/ */