Browse Source

Add GCC extension to bypass select `-pedantic` warnings

Add wrapper macro for `__extension__` to suppress pedantic warnings
Elms 3 years ago
parent
commit
5c01613acb

+ 1 - 1
examples/benchmark/tls_bench.c

@@ -127,7 +127,7 @@ bench_tls(args);
 static const char* kShutdown = "shutdown";
 
 #ifndef NO_WOLFSSL_CLIENT
-static const char* kTestStr =
+PEDANTIC_EXTENSION static const char* kTestStr =
 "Biodiesel cupidatat marfa, cliche aute put a bird on it incididunt elit\n"
 "polaroid. Sunt tattooed bespoke reprehenderit. Sint twee organic id\n"
 "marfa. Commodo veniam ad esse gastropub. 3 wolf moon sartorial vero,\n"

+ 5 - 5
tests/api.c

@@ -23879,9 +23879,9 @@ static void test_wc_PKCS7_EncodeSignedData(void)
     PKCS7*      pkcs7;
     WC_RNG      rng;
     byte        output[FOURK_BUF];
-    byte        badOut[0];
+    byte        badOut[1];
     word32      outputSz = (word32)sizeof(output);
-    word32      badOutSz = (word32)sizeof(badOut);
+    word32      badOutSz = 0;
     byte        data[] = "Test data to encode.";
 
 #ifndef NO_RSA
@@ -24360,8 +24360,8 @@ static void test_wc_PKCS7_VerifySignedData(void)
     byte   output[FOURK_BUF];
     word32 outputSz = sizeof(output);
     byte   data[] = "Test data to encode.";
-    byte   badOut[0];
-    word32 badOutSz = (word32)sizeof(badOut);
+    byte   badOut[1];
+    word32 badOutSz = 0;
     byte   badContent[] = "This is different content than was signed";
 
     AssertIntGT((outputSz = CreatePKCS7SignedData(output, outputSz, data,
@@ -41391,7 +41391,7 @@ static void test_wolfssl_EVP_aes_gcm_zeroLen(void)
     byte iv[]  = {
         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
     }; /* align */
-    byte plaintxt[0];
+    byte plaintxt[1];
     int ivSz  = 12;
     int plaintxtSz = 0;
     unsigned char tag[16];

+ 4 - 4
tests/unit.h

@@ -53,10 +53,10 @@
 #define AssertFalse(x)   Assert(!(x), ("%s is false",    #x), (#x " => TRUE"))
 #define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL"))
 
-#define AssertNull(x) do {                                                     \
-    void* _x = (void *) (x);                                                   \
-                                                                               \
-    Assert(!_x, ("%s is null", #x), (#x " => %p", _x));                        \
+#define AssertNull(x) do {                              \
+    PEDANTIC_EXTENSION void* _x = (void *) (x);         \
+                                                        \
+    Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \
 } while(0)
 
 #define AssertInt(x, y, op, er) do {                                           \

+ 1 - 1
wolfcrypt/src/logging.c

@@ -141,7 +141,7 @@ const char *wolfSSL_configure_args(void) {
 #endif
 }
 
-const char *wolfSSL_global_cflags(void) {
+PEDANTIC_EXTENSION const char *wolfSSL_global_cflags(void) {
 #ifdef LIBWOLFSSL_GLOBAL_CFLAGS
   /* the spaces on either side are to make matching simple and efficient. */
   return " " LIBWOLFSSL_GLOBAL_CFLAGS " ";

+ 1 - 1
wolfcrypt/src/poly1305.c

@@ -109,7 +109,7 @@ static word32 cpu_flags_set = 0;
 
     #elif defined(__GNUC__)
         #if defined(__SIZEOF_INT128__)
-            typedef unsigned __int128 word128;
+            PEDANTIC_EXTENSION typedef unsigned __int128 word128;
         #else
             typedef unsigned word128 __attribute__((mode(TI)));
         #endif

+ 1 - 1
wolfcrypt/test/test.c

@@ -26445,7 +26445,7 @@ WOLFSSL_TEST_SUBROUTINE int ed448_test(void)
     WOLFSSL_SMALL_STACK_STATIC const byte* sigs[] = {sig1, sig2, sig3, sig4, sig5, sig6};
     #define SIGSZ sizeof(sig1)
 
-    WOLFSSL_SMALL_STACK_STATIC const byte msg1[]  = { };
+    PEDANTIC_EXTENSION WOLFSSL_SMALL_STACK_STATIC const byte msg1[]  = { };
     WOLFSSL_SMALL_STACK_STATIC const byte msg2[]  = { 0x03 };
     WOLFSSL_SMALL_STACK_STATIC const byte msg3[]  = { 0x64, 0xa6, 0x5f, 0x3c, 0xde, 0xdc, 0xdd,
                                   0x66, 0x81, 0x1e, 0x29, 0x15 };

+ 8 - 0
wolfssl/wolfcrypt/types.h

@@ -1007,6 +1007,14 @@ decouple library dependencies with standard string, memory and so on.
         #endif
     #endif /* WOLFSSL_AESNI || WOLFSSL_ARMASM */
 
+    #if !defined(PEDANTIC_EXTENSION)
+        #if defined(__GNUC__)
+            #define PEDANTIC_EXTENSION __extension__
+        #else
+            #define PEDANTIC_EXTENSION
+        #endif
+    #endif /* !PEDANTIC_EXTENSION */
+
 
     #ifndef TRUE
         #define TRUE  1