]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fundamental: unify gcc warning pragmas at one place
authorLennart Poettering <lennart@poettering.net>
Thu, 16 Jan 2025 15:01:56 +0000 (16:01 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 16 Jan 2025 19:08:58 +0000 (04:08 +0900)
This also drops HAVE_WSTRINGOP_TRUNCATION as the corresponding option
was introduced in GCC 8, and our baseline is GCC 8.4.

meson.build
src/basic/macro.h
src/fundamental/macro-fundamental.h
src/resolve/resolved-dns-dnssec.c
src/shared/ethtool-util.c

index 5c364e137903e30085115dbeba8c4f570ea86446..f9f400a7d64bd2c1e73cf5f2b155a98210a4eea3 100644 (file)
@@ -538,14 +538,11 @@ endif
 
 cpp = ' '.join(cc.cmd_array() + get_option('c_args')) + ' -E'
 
-has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
-
 #####################################################################
 # compilation result tests
 
 conf.set('_GNU_SOURCE', 1)
 conf.set('__SANE_USERSPACE_TYPES__', true)
-conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
 
 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
index 68eb7bbd0e544ffb8597bbad01a2239d1890cd2b..026ec136376169949ae131d8f3b0be5aa1daa98a 100644 (file)
 #define _function_no_sanitize_float_cast_overflow_
 #endif
 
-#if HAVE_WSTRINGOP_TRUNCATION
-#  define DISABLE_WARNING_STRINGOP_TRUNCATION                           \
-        _Pragma("GCC diagnostic push");                                 \
-        _Pragma("GCC diagnostic ignored \"-Wstringop-truncation\"")
-#else
-#  define DISABLE_WARNING_STRINGOP_TRUNCATION                           \
-        _Pragma("GCC diagnostic push")
-#endif
-
 /* test harness */
 #define EXIT_TEST_SKIP 77
 
index 709657dd2852163170088983984b7de544de70ae..6122a0a92b3b2200380ff48103a63642cfd87499 100644 (file)
         _Pragma("GCC diagnostic push");                                 \
         _Pragma("GCC diagnostic ignored \"-Waddress\"")
 
+#define DISABLE_WARNING_STRINGOP_TRUNCATION                             \
+        _Pragma("GCC diagnostic push");                                 \
+        _Pragma("GCC diagnostic ignored \"-Wstringop-truncation\"")
+
+#define DISABLE_WARNING_ZERO_LENGTH_BOUNDS                              \
+        _Pragma("GCC diagnostic push");                                 \
+        _Pragma("GCC diagnostic ignored \"-Wzero-length-bounds\"")
+
 #define REENABLE_WARNING                                                \
         _Pragma("GCC diagnostic pop")
 
index 09cc2cb7313471556e8bab1f2441f6e4e9845b79..aff185a2dd9b4f15c6c72bcbf45dcb2cb464964d 100644 (file)
 #include "string-table.h"
 
 #if PREFER_OPENSSL && OPENSSL_VERSION_MAJOR >= 3
-#  pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+DISABLE_WARNING_DEPRECATED_DECLARATIONS;
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(RSA*, RSA_free, NULL);
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EC_KEY*, EC_KEY_free, NULL);
-#  pragma GCC diagnostic pop
+REENABLE_WARNING;
 #endif
 
 #define VERIFY_RRS_MAX 256
@@ -101,8 +100,7 @@ static int dnssec_rsa_verify_raw(
         int r;
 
 #if PREFER_OPENSSL
-#  pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+        DISABLE_WARNING_DEPRECATED_DECLARATIONS;
         _cleanup_(RSA_freep) RSA *rpubkey = NULL;
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *epubkey = NULL;
         _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = NULL;
@@ -153,7 +151,7 @@ static int dnssec_rsa_verify_raw(
                 return log_debug_errno(SYNTHETIC_ERRNO(EIO),
                                        "Signature verification failed: 0x%lx", ERR_get_error());
 
-#  pragma GCC diagnostic pop
+        REENABLE_WARNING;
 #else
         gcry_sexp_t public_key_sexp = NULL, data_sexp = NULL, signature_sexp = NULL;
         gcry_mpi_t n = NULL, e = NULL, s = NULL;
@@ -303,8 +301,7 @@ static int dnssec_ecdsa_verify_raw(
         int k;
 
 #if PREFER_OPENSSL
-#  pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+        DISABLE_WARNING_DEPRECATED_DECLARATIONS;
         _cleanup_(EC_GROUP_freep) EC_GROUP *ec_group = NULL;
         _cleanup_(EC_POINT_freep) EC_POINT *p = NULL;
         _cleanup_(EC_KEY_freep) EC_KEY *eckey = NULL;
@@ -365,7 +362,7 @@ static int dnssec_ecdsa_verify_raw(
                 return log_debug_errno(SYNTHETIC_ERRNO(EIO),
                                        "Signature verification failed: 0x%lx", ERR_get_error());
 
-#  pragma GCC diagnostic pop
+        REENABLE_WARNING;
 #else
         gcry_sexp_t public_key_sexp = NULL, data_sexp = NULL, signature_sexp = NULL;
         gcry_mpi_t q = NULL, r = NULL, s = NULL;
index 51c75780cd6fee8c6f2aae518db4dc01c6666c9b..aeed917a6a599df003aa3b252da788dae2cbb535 100644 (file)
@@ -11,6 +11,7 @@
 #include "extract-word.h"
 #include "fd-util.h"
 #include "log.h"
+#include "macro-fundamental.h"
 #include "memory-util.h"
 #include "socket-util.h"
 #include "string-table.h"
@@ -452,12 +453,9 @@ static int get_stringset(int ethtool_fd, const char *ifname, enum ethtool_string
         if (buffer.info.sset_mask == 0)
                 return -EOPNOTSUPP;
 
-#pragma GCC diagnostic push
-#if HAVE_ZERO_LENGTH_BOUNDS
-#  pragma GCC diagnostic ignored "-Wzero-length-bounds"
-#endif
+        DISABLE_WARNING_ZERO_LENGTH_BOUNDS;
         len = buffer.info.data[0];
-#pragma GCC diagnostic pop
+        REENABLE_WARNING;
         if (len == 0)
                 return -EOPNOTSUPP;