Skip to content

Commit

Permalink
Merge pull request #6620 from douzzer/20230714-WC_DO_NOTHING
Browse files Browse the repository at this point in the history
20230714-WC_DO_NOTHING
  • Loading branch information
JacobBarthelmeh committed Jul 18, 2023
2 parents fd13d37 + f6f8d2e commit 8065ba1
Show file tree
Hide file tree
Showing 51 changed files with 203 additions and 195 deletions.
2 changes: 1 addition & 1 deletion IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*----------------------------------------------------------------------------*/
#include "stm32f2xx.h"

#define assert_param(a)
#define assert_param(a) /* null expansion */

#define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
#define SYNCHRO_TIMEOUT ((uint32_t) 0x00008000)
Expand Down
8 changes: 4 additions & 4 deletions linuxkm/module_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,11 @@ static int set_up_wolfssl_linuxkm_pie_redirect_table(void) {

#include <wolfssl/wolfcrypt/coding.h>

PRAGMA_GCC_DIAG_PUSH;
PRAGMA_GCC("GCC diagnostic ignored \"-Wnested-externs\"");
PRAGMA_GCC("GCC diagnostic ignored \"-Wpointer-arith\"");
PRAGMA_GCC_DIAG_PUSH
PRAGMA_GCC("GCC diagnostic ignored \"-Wnested-externs\"")
PRAGMA_GCC("GCC diagnostic ignored \"-Wpointer-arith\"")
#include <crypto/hash.h>
PRAGMA_GCC_DIAG_POP;
PRAGMA_GCC_DIAG_POP

extern char verifyCore[WC_SHA256_DIGEST_SIZE*2 + 1];
extern const char coreKey[WC_SHA256_DIGEST_SIZE*2 + 1];
Expand Down
2 changes: 1 addition & 1 deletion src/crl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ static int StopMonitor(wolfSSL_CRL_mfd_t mfd)
LocalFree(lpMsgBuf); \
} while(0)
#else
#define SHOW_WINDOWS_ERROR()
#define SHOW_WINDOWS_ERROR() WC_DO_NOTHING
#endif

#define DM_ERROR() do { \
Expand Down
8 changes: 4 additions & 4 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -24483,18 +24483,18 @@ void SetErrorString(int error, char* str)
#ifndef NO_ERROR_STRINGS
#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
#define SUITE_INFO(x,y,z,w,v,u) {(x),(y),(z),(w),(v),(u),WOLFSSL_CIPHER_SUITE_FLAG_NONE}
#define SUITE_ALIAS(x,z,w,v,u)
#define SUITE_ALIAS(x,z,w,v,u) /* null expansion */
#else
#define SUITE_INFO(x,y,z,w,v,u) {(x),(y),(z),(w),WOLFSSL_CIPHER_SUITE_FLAG_NONE}
#define SUITE_ALIAS(x,z,w,v,u)
#define SUITE_ALIAS(x,z,w,v,u) /* null expansion */
#endif
#else
#if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
#define SUITE_INFO(x,y,z,w,v,u) {(x),(z),(w),(v),(u),WOLFSSL_CIPHER_SUITE_FLAG_NONE}
#define SUITE_ALIAS(x,z,w,v,u)
#define SUITE_ALIAS(x,z,w,v,u) /* null expansion */
#else
#define SUITE_INFO(x,y,z,w,v,u) {(x),(z),(w),WOLFSSL_CIPHER_SUITE_FLAG_NONE}
#define SUITE_ALIAS(x,z,w,v,u)
#define SUITE_ALIAS(x,z,w,v,u) /* null expansion */
#endif
#endif
#else /* !NO_CIPHER_SUITE_ALIASES */
Expand Down
12 changes: 6 additions & 6 deletions src/sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ static void UpdateMissedDataSessions(void)

#ifdef WOLFSSL_SNIFFER_STATS
#ifdef HAVE_C___ATOMIC
#define LOCK_STAT()
#define UNLOCK_STAT()
#define LOCK_STAT() WC_DO_NOTHING
#define UNLOCK_STAT() WC_DO_NOTHING
#define NOLOCK_ADD_TO_STAT(x,y) ({ TraceStat(#x, y); \
__atomic_fetch_add(&x, y, __ATOMIC_RELAXED); })
#else
Expand All @@ -636,10 +636,10 @@ static void UpdateMissedDataSessions(void)
#endif /* WOLFSSL_SNIFFER_STATS */

#ifdef HAVE_C___ATOMIC
#define LOCK_SESSION()
#define UNLOCK_SESSION()
#define LOCK_SERVER_LIST()
#define UNLOCK_SERVER_LIST()
#define LOCK_SESSION() WC_DO_NOTHING
#define UNLOCK_SESSION() WC_DO_NOTHING
#define LOCK_SERVER_LIST() WC_DO_NOTHING
#define UNLOCK_SERVER_LIST() WC_DO_NOTHING
#else
#define LOCK_SESSION() wc_LockMutex(&SessionMutex)
#define UNLOCK_SESSION() wc_UnLockMutex(&SessionMutex)
Expand Down
10 changes: 5 additions & 5 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14963,10 +14963,10 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
/* myBuffer may not be initialized fully, but the span up to the
* sending length will be.
*/
PRAGMA_GCC_DIAG_PUSH;
PRAGMA_GCC("GCC diagnostic ignored \"-Wmaybe-uninitialized\"");
PRAGMA_GCC_DIAG_PUSH
PRAGMA_GCC("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
ret = wolfSSL_write(ssl, myBuffer, sending);
PRAGMA_GCC_DIAG_POP;
PRAGMA_GCC_DIAG_POP

if (dynamic)
XFREE(myBuffer, ssl->heap, DYNAMIC_TYPE_WRITEV);
Expand Down Expand Up @@ -26693,8 +26693,8 @@ WOLFSSL_EVP_PKEY *wolfSSL_PEM_read_PUBKEY(XFILE fp, WOLFSSL_EVP_PKEY **key,

WOLFSSL_ENTER("wolfSSL_PEM_read_PUBKEY");

if (pem_read_file_key(fp, cb, pass, PUBLICKEY_TYPE, &keyFormat, &der)
>= 0) {
if ((pem_read_file_key(fp, cb, pass, PUBLICKEY_TYPE, &keyFormat, &der)
>= 0) && (der != NULL)) {
const unsigned char* ptr = der->buffer;

/* handle case where reuse is attempted */
Expand Down
34 changes: 17 additions & 17 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ int TLSX_ALPN_GetRequest(TLSX* extensions, void** data, word16 *dataSz)

#else /* HAVE_ALPN */

#define ALPN_FREE_ALL(list, heap)
#define ALPN_FREE_ALL(list, heap) WC_DO_NOTHING
#define ALPN_GET_SIZE(list) 0
#define ALPN_WRITE(a, b) 0
#define ALPN_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -2504,7 +2504,7 @@ int TLSX_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz,

#else

#define SNI_FREE_ALL(list, heap)
#define SNI_FREE_ALL(list, heap) WC_DO_NOTHING
#define SNI_GET_SIZE(list) 0
#define SNI_WRITE(a, b) 0
#define SNI_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -2844,7 +2844,7 @@ int TLSX_UseTrustedCA(TLSX** extensions, byte type,

#else /* HAVE_TRUSTED_CA */

#define TCA_FREE_ALL(list, heap)
#define TCA_FREE_ALL(list, heap) WC_DO_NOTHING
#define TCA_GET_SIZE(list) 0
#define TCA_WRITE(a, b) 0
#define TCA_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -2938,7 +2938,7 @@ int TLSX_UseMaxFragment(TLSX** extensions, byte mfl, void* heap)

#else

#define MFL_FREE_ALL(a, b)
#define MFL_FREE_ALL(a, b) WC_DO_NOTHING
#define MFL_GET_SIZE(a) 0
#define MFL_WRITE(a, b) 0
#define MFL_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -3445,7 +3445,7 @@ int TLSX_UseCertificateStatusRequest(TLSX** extensions, byte status_type,

#else

#define CSR_FREE_ALL(data, heap)
#define CSR_FREE_ALL(data, heap) WC_DO_NOTHING
#define CSR_GET_SIZE(a, b) 0
#define CSR_WRITE(a, b, c) 0
#define CSR_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -3891,7 +3891,7 @@ int TLSX_UseCertificateStatusRequestV2(TLSX** extensions, byte status_type,

#else

#define CSR2_FREE_ALL(data, heap)
#define CSR2_FREE_ALL(data, heap) WC_DO_NOTHING
#define CSR2_GET_SIZE(a, b) 0
#define CSR2_WRITE(a, b, c) 0
#define CSR2_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -5113,18 +5113,18 @@ int TLSX_UsePointFormat(TLSX** extensions, byte format, void* heap)

#else

#define EC_FREE_ALL(list, heap)
#define EC_FREE_ALL(list, heap) WC_DO_NOTHING
#define EC_GET_SIZE(list) 0
#define EC_WRITE(a, b) 0
#define EC_PARSE(a, b, c, d, e) 0
#define EC_VALIDATE_REQUEST(a, b)
#define EC_VALIDATE_REQUEST(a, b) WC_DO_NOTHING

#define PF_FREE_ALL(list, heap)
#define PF_FREE_ALL(list, heap) WC_DO_NOTHING
#define PF_GET_SIZE(list) 0
#define PF_WRITE(a, b) 0
#define PF_PARSE(a, b, c, d) 0
#define PF_VALIDATE_REQUEST(a, b)
#define PF_VALIDATE_RESPONSE(a, b)
#define PF_VALIDATE_REQUEST(a, b) WC_DO_NOTHING
#define PF_VALIDATE_RESPONSE(a, b) WC_DO_NOTHING

#endif /* HAVE_SUPPORTED_CURVES */

Expand Down Expand Up @@ -5319,7 +5319,7 @@ int TLSX_AddEmptyRenegotiationInfo(TLSX** extensions, void* heap)

#else

#define SCR_FREE_ALL(a, heap)
#define SCR_FREE_ALL(a, heap) WC_DO_NOTHING
#define SCR_GET_SIZE(a, b) 0
#define SCR_WRITE(a, b, c) 0
#define SCR_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -5525,8 +5525,8 @@ int TLSX_UseSessionTicket(TLSX** extensions, SessionTicket* ticket, void* heap)

#else

#define WOLF_STK_FREE(a, b)
#define WOLF_STK_VALIDATE_REQUEST(a)
#define WOLF_STK_FREE(a, b) WC_DO_NOTHING
#define WOLF_STK_VALIDATE_REQUEST(a) WC_DO_NOTHING
#define WOLF_STK_GET_SIZE(a, b) 0
#define WOLF_STK_WRITE(a, b, c) 0
#define WOLF_STK_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -5882,7 +5882,7 @@ static int TLSX_UseSRTP(TLSX** extensions, word16 profiles, void* heap)
#define SRTP_WRITE TLSX_UseSRTP_Write
#define SRTP_GET_SIZE TLSX_UseSRTP_GetSize
#else
#define SRTP_FREE(a, b)
#define SRTP_FREE(a, b) WC_DO_NOTHING
#define SRTP_PARSE(a, b, c, d) 0
#define SRTP_WRITE(a, b) 0
#define SRTP_GET_SIZE(a) 0
Expand Down Expand Up @@ -9657,7 +9657,7 @@ int TLSX_KeyShare_DeriveSecret(WOLFSSL *ssl)

#else

#define KS_FREE_ALL(a, b)
#define KS_FREE_ALL(a, b) WC_DO_NOTHING
#define KS_GET_SIZE(a, b) 0
#define KS_WRITE(a, b, c) 0
#define KS_PARSE(a, b, c, d) 0
Expand Down Expand Up @@ -10167,7 +10167,7 @@ int TLSX_PreSharedKey_Use(TLSX** extensions, const byte* identity, word16 len,

#else

#define PSK_FREE_ALL(a, b)
#define PSK_FREE_ALL(a, b) WC_DO_NOTHING
#define PSK_GET_SIZE(a, b, c) 0
#define PSK_WRITE(a, b, c, d) 0
#define PSK_PARSE(a, b, c, d) 0
Expand Down
12 changes: 6 additions & 6 deletions src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
/* hash buffer may not be fully initialized, but the sending length won't
* extend beyond the initialized span.
*/
PRAGMA_GCC_DIAG_PUSH;
PRAGMA_GCC("GCC diagnostic ignored \"-Wmaybe-uninitialized\"");
PRAGMA_GCC_DIAG_PUSH
PRAGMA_GCC("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
(void)ssl;
(void)side;
return wc_Tls13_HKDF_Expand_Label(okm, okmLen, prk, prkLen,
protocol, protocolLen,
label, labelLen,
info, infoLen, digest);
PRAGMA_GCC_DIAG_POP;
PRAGMA_GCC_DIAG_POP
}
#endif /* !HAVE_FIPS || !wc_Tls13_HKDF_Expand_Label */

Expand Down Expand Up @@ -476,8 +476,8 @@ int Tls13DeriveKey(WOLFSSL* ssl, byte* output, int outputLen,
/* hash buffer may not be fully initialized, but the sending length won't
* extend beyond the initialized span.
*/
PRAGMA_GCC_DIAG_PUSH;
PRAGMA_GCC("GCC diagnostic ignored \"-Wmaybe-uninitialized\"");
PRAGMA_GCC_DIAG_PUSH
PRAGMA_GCC("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
PRIVATE_KEY_UNLOCK();
#if defined(HAVE_FIPS) && defined(wc_Tls13_HKDF_Expand_Label)
(void)side;
Expand All @@ -495,7 +495,7 @@ int Tls13DeriveKey(WOLFSSL* ssl, byte* output, int outputLen,
wc_MemZero_Add("TLS 1.3 derived key", output, outputLen);
#endif
return ret;
PRAGMA_GCC_DIAG_POP;
PRAGMA_GCC_DIAG_POP
}

/* Convert TLS mac ID to a hash algorithm ID
Expand Down
4 changes: 2 additions & 2 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2189,8 +2189,8 @@ void DEBUG_WRITE_DER(const byte* der, int derSz, const char* fileName)
}
}
#else
#define DEBUG_WRITE_CERT_X509(x509, fileName)
#define DEBUG_WRITE_DER(der, derSz, fileName)
#define DEBUG_WRITE_CERT_X509(x509, fileName) WC_DO_NOTHING
#define DEBUG_WRITE_DER(der, derSz, fileName) WC_DO_NOTHING
#endif


Expand Down
26 changes: 13 additions & 13 deletions tests/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <wolfssl/test.h> /* thread and tcp stuff */

#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
#define XABORT()
#define XABORT() WC_DO_NOTHING
#else
#define XABORT() abort()
#endif
Expand Down Expand Up @@ -99,17 +99,17 @@
#else

#define AssertPtr(x, y, op, er) do { \
PRAGMA_GCC_DIAG_PUSH; \
PRAGMA_GCC_DIAG_PUSH \
/* remarkably, without this inhibition, */ \
/* the _Pragma()s make the declarations warn. */ \
PRAGMA_GCC("GCC diagnostic ignored \"-Wdeclaration-after-statement\""); \
PRAGMA_GCC("GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
/* inhibit "ISO C forbids conversion of function pointer */ \
/* to object pointer type [-Werror=pedantic]" */ \
PRAGMA_GCC("GCC diagnostic ignored \"-Wpedantic\""); \
PRAGMA_GCC("GCC diagnostic ignored \"-Wpedantic\"") \
void* _x = (void*)(x); \
void* _y = (void*)(y); \
Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%p " #er " %p", _x, _y)); \
PRAGMA_GCC_DIAG_POP; \
PRAGMA_GCC_DIAG_POP \
} while(0)

#endif
Expand Down Expand Up @@ -189,17 +189,17 @@

#define ExpectPtr(x, y, op, er) do { \
if (_ret != TEST_FAIL) { \
PRAGMA_DIAG_PUSH; \
PRAGMA_DIAG_PUSH \
/* remarkably, without this inhibition, */ \
/* the _Pragma()s make the declarations warn. */ \
PRAGMA("GCC diagnostic ignored \"-Wdeclaration-after-statement\""); \
PRAGMA("GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
/* inhibit "ISO C forbids conversion of function pointer */ \
/* to object pointer type [-Werror=pedantic]" */ \
PRAGMA("GCC diagnostic ignored \"-Wpedantic\""); \
PRAGMA("GCC diagnostic ignored \"-Wpedantic\"") \
void* _x = (void*)(x); \
void* _y = (void*)(y); \
Expect(_x op _y, ("%s " #op " %s", #x, #y), ("%p " #er " %p", _x, _y));\
PRAGMA_DIAG_POP; \
PRAGMA_DIAG_POP \
} \
} while(0)

Expand Down Expand Up @@ -261,17 +261,17 @@
#define DoExpectStrLE(x, y) DoExpectStr(x, y, <=, >)

#define DoExpectPtr(x, y, op, er) do { \
PRAGMA_DIAG_PUSH; \
PRAGMA_DIAG_PUSH \
/* remarkably, without this inhibition, */ \
/* the _Pragma()s make the declarations warn. */ \
PRAGMA("GCC diagnostic ignored \"-Wdeclaration-after-statement\""); \
PRAGMA("GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
/* inhibit "ISO C forbids conversion of function pointer */ \
/* to object pointer type [-Werror=pedantic]" */ \
PRAGMA("GCC diagnostic ignored \"-Wpedantic\""); \
PRAGMA("GCC diagnostic ignored \"-Wpedantic\"") \
void* _x = (void*)(x); \
void* _y = (void*)(y); \
Expect(_x op _y, ("%s " #op " %s", #x, #y), ("%p " #er " %p", _x, _y)); \
PRAGMA_DIAG_POP; \
PRAGMA_DIAG_POP \
} while(0)

#define DoExpectPtrEq(x, y) DoExpectPtr(x, y, ==, !=)
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
/* fflush in Zephyr doesn't work on stdout and stderr. Use
* CONFIG_LOG_MODE_IMMEDIATE compilation option instead. */
#undef XFFLUSH
#define XFFLUSH(...) do {} while (0)
#define XFFLUSH(...) WC_DO_NOTHING
#endif

/* only for stack size check */
Expand Down Expand Up @@ -457,7 +457,7 @@
/* optional macro to add sleep between tests */
#ifndef TEST_SLEEP
/* stub the sleep macro */
#define TEST_SLEEP()
#define TEST_SLEEP() WC_DO_NOTHING
#endif

#define TEST_STRING "Everyone gets Friday off."
Expand Down Expand Up @@ -1446,7 +1446,7 @@ static const char* bench_result_words2[][5] = {
}
return 0;
}
#define bench_async_poll(p)
#define bench_async_poll(p) WC_DO_NOTHING
#endif /* WOLFSSL_ASYNC_CRYPT */


Expand Down
Loading

0 comments on commit 8065ba1

Please sign in to comment.