From 71eeec8c78b176b890d99f7e6c4d95f9ac65e8ab Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 10 Nov 2020 19:39:50 +0100 Subject: [PATCH] device: fix _Generic() types for _NM_DEVICE_CAST() macro clang (x86_64, 3.4.2-9.el7) fails: ../src/devices/nm-device-6lowpan.c:161:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice6Lowpan *const') not compatible with any generic association type _LOGW(LOGD_DEVICE, "could not get 6lowpan properties"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../shared/nm-glib-aux/nm-logging-fwd.h:165:20: note: expanded from macro '_LOGW' #define _LOGW(...) _NMLOG(_LOGL_WARN, __VA_ARGS__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/devices/nm-device-logging.h:32:81: note: expanded from macro '_NMLOG' const char *const _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \ ^~~~~ ../src/devices/nm-device-logging.h:17:19: note: expanded from macro '_NM_DEVICE_CAST' _Generic((self), _NMLOG_DEVICE_TYPE * \ ^ Fixes: cc35dc3bdf5f ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type') --- src/devices/nm-device-logging.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device-logging.h b/src/devices/nm-device-logging.h index ff3d4180d..34ba4172f 100644 --- a/src/devices/nm-device-logging.h +++ b/src/devices/nm-device-logging.h @@ -13,10 +13,12 @@ #elif !defined(_NMLOG_DEVICE_TYPE) #define _NM_DEVICE_CAST(self) _NM_ENSURE_TYPE(NMDevice *, self) #else - #define _NM_DEVICE_CAST(self) \ - _Generic((self), _NMLOG_DEVICE_TYPE * \ - : ((NMDevice *) (self)), NMDevice * \ - : ((NMDevice *) (self))) + #define _NM_DEVICE_CAST(self) \ + _Generic((self), \ + _NMLOG_DEVICE_TYPE * : ((NMDevice *) (self)), \ + _NMLOG_DEVICE_TYPE * const: ((NMDevice *) (self)), \ + NMDevice * : ((NMDevice *) (self)), \ + NMDevice * const: ((NMDevice *) (self))) #endif #undef _NMLOG_ENABLED