From: Arran Cudbard-Bell Date: Mon, 11 Oct 2021 16:06:15 +0000 (-0500) Subject: Try and quiet GCC X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07eddc557e9b62926880695d73178ebe47ace54a;p=thirdparty%2Ffreeradius-server.git Try and quiet GCC --- diff --git a/src/lib/util/pair.h b/src/lib/util/pair.h index 242d13c2acf..0665800d8a7 100644 --- a/src/lib/util/pair.h +++ b/src/lib/util/pair.h @@ -44,17 +44,36 @@ extern "C" { # define _CONST #endif + #ifdef WITH_VERIFY_PTR # define VP_VERIFY(_x) fr_pair_verify(__FILE__, __LINE__, _x) # define LIST_VERIFY(_x) fr_pair_list_verify(__FILE__, __LINE__, NULL, _x) #else +DIAG_OFF(nonnull-compare) +/** Wrapper function to defeat nonnull checks + * + * We may sprinkle VP_VERIFY and LIST_VERIFY in functions which + * have their pair argument marked up as nonnull. + * + * This would usually generate errors when WITH_VERIFY_PTR is not + * defined, as the assert macros check for an arguments NULLness. + * + * This function wraps the assert but has nonnull-compare disabled + * meaning a warning won't be emitted. + */ +static inline fr_pair_nonnull_assert(fr_pair_t *vp) +{ + fr_cond_assert(vp) +} +DIAG_ON(nonull-compare) + /* * Even if were building without WITH_VERIFY_PTR * the pointer must not be NULL when these various macros are used * so we can add some sneaky soft asserts. */ -# define VP_VERIFY(_x) fr_cond_assert(_x) -# define LIST_VERIFY(_x) fr_cond_assert(_x) +# define VP_VERIFY(_x) fr_pair_nonnull_assert(_x) +# define LIST_VERIFY(_x) fr_pair_nonnull_assert(_x) #endif /** The type of value a fr_pair_t contains