]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rework DIAG_ON and DIAG_OFF macros to behave consistently.
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 25 Jan 2021 17:16:16 +0000 (17:16 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 25 Jan 2021 17:16:21 +0000 (17:16 +0000)
Add DIAG_OFF_OPTIONAL and DIAG_ON_OPTIONAL which ignore unknown pragmas

13 files changed:
src/include/build.h
src/lib/curl/base.h
src/lib/curl/io.c
src/lib/json/base.h
src/lib/json/json_missing.h
src/lib/util/dbuff_tests.c
src/lib/util/event.c
src/modules/rlm_mruby/rlm_mruby.c
src/modules/rlm_mruby/rlm_mruby.h
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_rest/rest.c
src/modules/rlm_unbound/io.h
src/modules/rlm_unbound/log.h

index 291efe3b3951a9e4efcb7d148267d7c5f2c75799..1f136d0788acd02cb731f5290410e0123d376043 100644 (file)
@@ -168,31 +168,41 @@ extern "C" {
 /*
  *     Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
  */
-#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
-#  define DIAG_PRAGMA(_x) PRAGMA(GCC diagnostic _x)
-#  if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
-#    define DIAG_OFF(_x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored JOINSTR(-W,_x))
-#    define DIAG_ON(_x) DIAG_PRAGMA(pop)
-#  else
-#    define DIAG_OFF(_x) DIAG_PRAGMA(ignored JOINSTR(-W,_x))
-#    define DIAG_ON(_x)  DIAG_PRAGMA(warning JOINSTR(-W,_x))
-#  endif
-#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
+#if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
 #  define DIAG_PRAGMA(_x) PRAGMA(clang diagnostic _x)
-#  define DIAG_OFF(_x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored JOINSTR(-W,_x))
-#  define DIAG_ON(_x) DIAG_PRAGMA(pop)
+#  define DIAG_OFF(_x) DIAG_PRAGMA(ignored JOINSTR(-W,_x))
+#  define DIAG_ON(_x) DIAG_PRAGMA(warning JOINSTR(-W,_x))
+#  define DIAG_OFF_OPTIONAL(_x) \
+       DIAG_OFF(ignored unknown-pragmas) \
+       DIAG_OFF(_x) \
+       DIAG_ON(warning unknown-pragmas)
+#  define DIAG_ON_OPTIONAL(_x) \
+       DIAG_OFF(unknown-pragmas) \
+       DIAG_ON(_x) \
+       DIAG_ON(unknown-pragmas)
+#  define DIAG_PUSH() DIAG_PRAGMA(push)
+#  define DIAG_POP() DIAG_PRAGMA(pop)
+#elif !defined(__clang__) && defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+#  define DIAG_PRAGMA(_x) PRAGMA(GCC diagnostic _x)
+#  define DIAG_OFF(_x) DIAG_PRAGMA(ignored JOINSTR(-W,_x))
+#  define DIAG_ON(_x)  DIAG_PRAGMA(warning JOINSTR(-W,_x))
+#  define DIAG_OFF_OPTIONAL(_x) \
+       DIAG_OFF(pragmas) \
+       DIAG_OFF(_x) \
+       DIAG_ON(pragmas)
+#  define DIAG_ON_OPTIONAL(_x) \
+       DIAG_OFF(pragmas)
+       DIAG_ON(_x) \
+       DIAG_ON(pragmas)
+#  define DIAG_PUSH() DIAG_PRAGMA(push)
+#  define DIAG_POP() DIAG_PRAGMA(pop)
 #else
 #  define DIAG_OFF(_x)
 #  define DIAG_ON(_x)
-#endif
-
-/*
- *     GCC and clang use different macros
- */
-#ifdef __clang__
-# define DIAG_OPTIONAL DIAG_OFF(unknown-pragmas)
-#else
-# define DIAG_OPTIONAL DIAG_OFF(pragmas)
+#  define DIAG_OFF_OPTIONAL(_x)
+#  define DIAG_ON_OPTIONAL(_x)
+#  define DIAG_PUSH()
+#  define DIAG_POP()
 #endif
 
 /*
index b6be40b6c145ba07be0b80878f231fba42a0e927..1b71c6fa8da0da18ac63d6d9ade0331b0d5dd020 100644 (file)
@@ -36,8 +36,7 @@ extern "C" {
 #include <freeradius-devel/util/event.h>
 #include <freeradius-devel/server/module.h>
 
-DIAG_OPTIONAL
-DIAG_OFF(disabled-macro-expansion)
+DIAG_OFF_OPTIONAL(disabled-macro-expansion)
 #define FR_CURL_SET_OPTION(_x, _y)\
 do {\
        int _ret;\
@@ -72,7 +71,7 @@ do {\
 } while (0)
 
 /*
- *␉·····We have to use this as curl uses lots of enums
+ * We have to use this as curl uses lots of enums
  */
 #ifndef CURL_AT_LEAST_VERSION
 #  define CURL_VERSION_BITS(x, y, z) ((x) << 16 | (y) << 8 | (z))
index 17bad21711e257b5b2e39520c1196878ced5ed60..14ab4da80f33d5ff520ae4e3eac220f327eb0504 100644 (file)
@@ -32,8 +32,7 @@
  *
  *  #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
  */
-DIAG_OPTIONAL
-DIAG_OFF(disabled-macro-expansion)
+DIAG_OFF_OPTIONAL(disabled-macro-expansion)
 #define SET_MOPTION(_mandle, _opt, _val)\
 do {\
        if ((ret = curl_multi_setopt(mandle, _opt, _val)) != CURLM_OK) {\
index a8dadeba3e6c495c6b72a97cb890e771152d1ad4..75a5906820893e2c02855e9f920a8c7a8b2c5d50 100644 (file)
@@ -34,14 +34,9 @@ RCSIDH(json_h, "$Id$")
 #ifdef HAVE_JSON
 #  if defined(HAVE_JSONMC_JSON_H)
 
-#ifdef __clang__
-DIAG_OFF(documentation-deprecated-sync)
-#endif
+DIAG_OFF_OPTIONAL(documentation-deprecated-sync)
 #    include <json-c/json.h>
-
-#ifdef __clang__
-DIAG_ON(documentation-deprecated-sync)
-#endif
+DIAG_ON_OPTIONAL(documentation-deprecated-sync)
 
 #  elif defined(HAVE_JSON_JSON_H)
 #    include <json/json.h>
index 161d0693fb495aea65f0cef46c4d4afa737b4ee3..ae614b0bbd76e1e4ac415a3b313eff3b31231b6e 100644 (file)
@@ -29,13 +29,9 @@ RCSIDH(jsonc_missing_h, "$Id$")
 #ifdef HAVE_JSON
 #  if defined(HAVE_JSONMC_JSON_H)
 
-#ifdef __clang__
-DIAG_OFF(documentation-deprecated-sync)
-#endif
+DIAG_OFF_OPTIONAL(documentation-deprecated-sync)
 #    include <json-c/json.h>
-#ifdef __clang__
-DIAG_ON(documentation-deprecated-sync)
-#endif
+DIAG_ON_OPTIONAL(documentation-deprecated-sync)
 
 #  elif defined(HAVE_JSON_JSON_H)
 #    include <json/json.h>
index 70fe95a5bc1131e74c2f8bc6040ce8f7d0a4d1f3..cb8c730c3a2959b98108e83a5106196c55199bb4 100644 (file)
@@ -13,8 +13,6 @@
  *     the floats are equal on a *bit* level, not on a *semantic*
  *     level.
  */
-DIAG_OFF(float-equal)
-
 #define TEST_CHECK_LEN(_got, _exp) \
 do { \
        size_t _our_got = (_got); \
index 3741f16753d58d7cdfa41106c558ad3f00a21ae9..1a6535226a4e3ac86f0ae359327bb7fb5fa59a65 100644 (file)
@@ -50,8 +50,7 @@ RCSID("$Id$")
  *     Turn off documentation warnings as file/line
  *     args aren't used for non-debug builds.
  */
-DIAG_OPTIONAL
-DIAG_OFF(documentation)
+DIAG_OFF_OPTIONAL(documentation)
 #endif
 
 #define FR_EV_BATCH_FDS (256)
index b0a33aae4e688b1a36063080cbf80e7d0e4889f6..991b3c68ae74ce78186340189a08c98575043917 100644 (file)
@@ -413,13 +413,9 @@ static unlang_action_t CC_HINT(nonnull) do_mruby(rlm_rcode_t *p_result, request_
        mruby_set_vps(request, mrb, mruby_request, "@control", &request->control_pairs);
        mruby_set_vps(request, mrb, mruby_request, "@session_state", &request->session_state_pairs);
 
-#ifdef __clang__
-DIAG_OFF(class-varargs)
-#endif
+DIAG_OFF_OPTIONAL(class-varargs)
        mruby_result = mrb_funcall(mrb, mrb_obj_value(inst->mruby_module), function_name, 1, mruby_request);
-#ifdef __clang__
-DIAG_ON(class-varargs)
-#endif
+DIAG_ON_OPTIONAL(class-varargs)
 
        /* Two options for the return value:
         * - a fixnum: convert to rlm_rcode_t, and return that
index bb88612f19bf26fd6ef7258448e4c56464dfea61..0c067dcf171e17a8b01c738330385913b619e1a1 100644 (file)
@@ -23,9 +23,7 @@
  * @copyright 2016 The FreeRADIUS server project
  */
 
-#ifdef HAVE_WDOCUMENTATION
-DIAG_OFF(documentation)
-#endif
+DIAG_OFF_OPTIONAL(documentation)
 #include <mruby.h>
 #include <mruby/compile.h>
 #include <mruby/array.h>
@@ -33,8 +31,6 @@ DIAG_OFF(documentation)
 #include <mruby/numeric.h>
 #include <mruby/string.h>
 #include <mruby/variable.h>
-#ifdef HAVE_WDOCUMENTATION
-DIAG_ON(documentation)
-#endif
+DIAG_ON_OPTIONAL(documentation)
 
 struct RClass *mruby_request_class(mrb_state *mrb, struct RClass *parent);
index 40797d0309a45062d8ef7f9cc4d3aaf61525e3bb..8cabde4fbfa755fd586492fbea41361129b26e4d 100644 (file)
@@ -197,7 +197,7 @@ static void rlm_perl_close_handles(void **handles)
        talloc_free(handles);
 }
 
-DIAG_OFF(shadow)
+DIAG_OFF_OPTIONAL(shadow)
 static void rlm_perl_destruct(PerlInterpreter *perl)
 {
        dTHXa(perl);
@@ -223,7 +223,7 @@ static void rlm_perl_destruct(PerlInterpreter *perl)
        perl_destruct(perl);
        perl_free(perl);
 }
-DIAG_ON(shadow)
+DIAG_ON_OPTIONAL(shadow)
 
 static void rlm_destroy_perl(PerlInterpreter *perl)
 {
index 6d5c43c8097dec62975440bb7a6730c9b3e582f2..749e423db3c9acfbf41208bfcf5eec42147bb19c 100644 (file)
@@ -96,9 +96,6 @@ const http_body_type_t http_body_type_supported[REST_HTTP_BODY_NUM_ENTRIES] = {
  *
  *  #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
  */
-DIAG_OPTIONAL
-DIAG_OFF(disabled-macro-expansion)
-
 const unsigned long http_curl_auth[REST_HTTP_AUTH_NUM_ENTRIES] = {
        [REST_HTTP_AUTH_UNKNOWN]                = 0,
        [REST_HTTP_AUTH_NONE]                   = 0,
index 9469b4cdb038577463fdd3cd32568d871ff528cc..bbfb49ac3b53f07e1fe596628b468cea3b9e5699 100644 (file)
@@ -30,14 +30,10 @@ RCSIDH(rlm_unbound_io_h, "$Id$")
 extern "C" {
 #endif
 
-#ifdef HAVE_WDOCUMENTATION
-DIAG_OFF(documentation)
-#endif
+DIAG_OFF_OPTIONAL(documentation)
 #include <unbound.h>
 #include <unbound-event.h>
-#ifdef HAVE_WDOCUMENTATION
-DIAG_ON(documentation)
-#endif
+DIAG_ON_OPTIONAL(documentation)
 
 /** Wrapper around our event loop specifying callbacks for creating new event handles
  *
index 32131f46f38e19e7d6cbc7e99d9d3b9fa0b7b6d3..0643d1fceaba3a31170f9e75c84b5d2ae3a6028b 100644 (file)
@@ -32,19 +32,15 @@ extern "C" {
 
 #include <freeradius-devel/server/request.h>
 
-#ifdef HAVE_WDOCUMENTATION
-DIAG_OFF(documentation)
-#endif
+DIAG_OFF_OPTIONAL(documentation)
 #include <unbound.h>
-#ifdef HAVE_WDOCUMENTATION
-DIAG_ON(documentation)
-#endif
+DIAG_ON_OPTIONAL(documentation)
 
 /** Logging state
  *
  */
 typedef struct {
-       request_t               *request;               //!< Request we're logging to.
+       request_t       *request;               //!< Request we're logging to.
        FILE            *stream;                //!< Stream we use to interface with the
                                                ///< FreeRADIUS logging functions.
 } unbound_log_t;