From ad06cc78dc086115729331f202fa86afd045ae6e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 May 2019 14:56:50 +0200 Subject: [PATCH] platform: make nm_platform_kernel_support_get() macro an inline function clang (3.4.2-9.el7) on CentOS 7.6 fails related to nm_hash_update_vals(). I am not even quoting the error message, it's totally non-understandable. nm_hash_update_vals() uses typeof(), and in some obscure cases, clang dislikes when the argument itself is some complex macro. I didn't fully understand why, but this works around it. I would prefer to fix nm_hash_update_vals() to not have this limitation. But I don't know how. There is probably no downside to have this an inline function instead of a macro. --- src/platform/nm-platform.h | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index a6b5f2c4c3..8c0a8764e2 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -919,28 +919,28 @@ extern volatile int _nm_platform_kernel_support_state[_NM_PLATFORM_KERNEL_SUPPOR int _nm_platform_kernel_support_init (NMPlatformKernelSupportType type, int value); -#define _nm_platform_kernel_support_detected(type) \ - G_LIKELY (({ \ - const NMPlatformKernelSupportType _type = (type); \ - \ - nm_assert (_NM_INT_NOT_NEGATIVE (_type) && _type < G_N_ELEMENTS (_nm_platform_kernel_support_state)); \ - \ - (_nm_platform_kernel_support_state[_type] != 0); \ - })) +static inline gboolean +_nm_platform_kernel_support_detected (NMPlatformKernelSupportType type) +{ + nm_assert ( _NM_INT_NOT_NEGATIVE (type) + && type < G_N_ELEMENTS (_nm_platform_kernel_support_state)); -#define nm_platform_kernel_support_get(type) \ - ({ \ - const NMPlatformKernelSupportType _type = (type); \ - int _v; \ - \ - nm_assert (_NM_INT_NOT_NEGATIVE (_type) && _type < G_N_ELEMENTS (_nm_platform_kernel_support_state)); \ - \ - _v = _nm_platform_kernel_support_state[_type]; \ - if (G_UNLIKELY (_v == 0)) \ - _v = _nm_platform_kernel_support_init (_type, 0); \ - \ - (_v >= 0); \ - }) + return G_LIKELY (_nm_platform_kernel_support_state[type] != 0); +} + +static inline gboolean +nm_platform_kernel_support_get (NMPlatformKernelSupportType type) +{ + int v; + + nm_assert (_NM_INT_NOT_NEGATIVE (type) + && type < G_N_ELEMENTS (_nm_platform_kernel_support_state)); + + v = _nm_platform_kernel_support_state[type]; + if (G_UNLIKELY (v == 0)) + v = _nm_platform_kernel_support_init (type, 0); + return (v >= 0); +} /*****************************************************************************/