mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 19:10:09 +01:00
device: improve "nm-device-logging.h" to support a self pointer of NMDevice type
"nm-device-logging.h" defines logging macros for a NMDevice instance. It also expects a "self" variable in the call environment, and that variable had to be in the type of NMDevice or the NMDevice subclass. Extend the macro foo, so that @self can be either a NMDevice* pointer or a NMDevice$SUBTYPE. Of course, that would have always been possible, if we would simply cast to "(NMDevice *)" where we need it. The trick is that the macro only works if @self is one of the two expected types, and not some arbitrary unrelated type.
This commit is contained in:
parent
7d5ec103df
commit
cc35dc3bdf
29 changed files with 58 additions and 55 deletions
|
|
@ -23,8 +23,8 @@
|
||||||
#include "nm-setting-adsl.h"
|
#include "nm-setting-adsl.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceAdsl
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceAdsl);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
#include "devices/wwan/nm-modem-manager.h"
|
#include "devices/wwan/nm-modem-manager.h"
|
||||||
#include "devices/wwan/nm-modem.h"
|
#include "devices/wwan/nm-modem.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceBt
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceBt);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
#include "nm-setting-6lowpan.h"
|
#include "nm-setting-6lowpan.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDevice6Lowpan
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDevice6Lowpan);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
#include "nm-ip4-config.h"
|
#include "nm-ip4-config.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceBond
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceBond);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
#include "nm-device-factory.h"
|
#include "nm-device-factory.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceBridge
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceBridge);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
#include "nm-setting-dummy.h"
|
#include "nm-setting-dummy.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceDummy
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceDummy);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "nm-udev-aux/nm-udev-utils.h"
|
#include "nm-udev-aux/nm-udev-utils.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceEthernet
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceEthernet);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
#include "nm-act-request.h"
|
#include "nm-act-request.h"
|
||||||
#include "nm-ip4-config.h"
|
#include "nm-ip4-config.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceIPTunnel
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceIPTunnel);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,36 +8,40 @@
|
||||||
|
|
||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
|
|
||||||
#define _LOG_DECLARE_SELF(t) \
|
#if !_NM_CC_SUPPORT_GENERIC
|
||||||
_nm_unused static inline NMDevice *_nm_device_log_self_to_device(t *self) \
|
#define _NM_DEVICE_CAST(self) ((NMDevice *) (self))
|
||||||
{ \
|
#elif !defined(_NMLOG_DEVICE_TYPE)
|
||||||
return (NMDevice *) self; \
|
#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)))
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef _NMLOG_ENABLED
|
#undef _NMLOG_ENABLED
|
||||||
#define _NMLOG_ENABLED(level, domain) (nm_logging_enabled((level), (domain)))
|
#define _NMLOG_ENABLED(level, domain) (nm_logging_enabled((level), (domain)))
|
||||||
#define _NMLOG(level, domain, ...) \
|
#define _NMLOG(level, domain, ...) \
|
||||||
G_STMT_START \
|
G_STMT_START \
|
||||||
{ \
|
{ \
|
||||||
const NMLogLevel _level = (level); \
|
const NMLogLevel _level = (level); \
|
||||||
const NMLogDomain _domain = (domain); \
|
const NMLogDomain _domain = (domain); \
|
||||||
\
|
\
|
||||||
if (nm_logging_enabled(_level, _domain)) { \
|
if (nm_logging_enabled(_level, _domain)) { \
|
||||||
typeof(*self) *const _self = (self); \
|
typeof(*self) *const _self = (self); \
|
||||||
const char *const _ifname = \
|
const char *const _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
|
||||||
_nm_device_get_iface(_nm_device_log_self_to_device(_self)); \
|
\
|
||||||
\
|
nm_log_obj(_level, \
|
||||||
nm_log_obj(_level, \
|
_domain, \
|
||||||
_domain, \
|
_ifname, \
|
||||||
_ifname, \
|
NULL, \
|
||||||
NULL, \
|
_self, \
|
||||||
_self, \
|
"device", \
|
||||||
"device", \
|
"%s%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||||
"%s%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
NM_PRINT_FMT_QUOTED(_ifname, "(", _ifname, ")", "[null]") \
|
||||||
NM_PRINT_FMT_QUOTED(_ifname, "(", _ifname, ")", "[null]") \
|
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
|
||||||
G_STMT_END
|
G_STMT_END
|
||||||
|
|
||||||
#endif /* __NETWORKMANAGER_DEVICE_LOGGING_H__ */
|
#endif /* __NETWORKMANAGER_DEVICE_LOGGING_H__ */
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
#include "supplicant/nm-supplicant-interface.h"
|
#include "supplicant/nm-supplicant-interface.h"
|
||||||
#include "supplicant/nm-supplicant-config.h"
|
#include "supplicant/nm-supplicant-config.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceMacsec
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceMacsec);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
#include "nm-ip4-config.h"
|
#include "nm-ip4-config.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceMacvlan
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceMacvlan);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
#include "ppp/nm-ppp-manager-call.h"
|
#include "ppp/nm-ppp-manager-call.h"
|
||||||
#include "ppp/nm-ppp-status.h"
|
#include "ppp/nm-ppp-status.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDevicePpp
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDevicePpp);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#include "nm-setting-tun.h"
|
#include "nm-setting-tun.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceTun
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceTun);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
#include "platform/nm-platform.h"
|
#include "platform/nm-platform.h"
|
||||||
#include "nm-device-factory.h"
|
#include "nm-device-factory.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceVeth
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceVeth);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
#include "platform/nmp-object.h"
|
#include "platform/nmp-object.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceVlan
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceVlan);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
#include "platform/nm-platform.h"
|
#include "platform/nm-platform.h"
|
||||||
#include "settings/nm-settings.h"
|
#include "settings/nm-settings.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceVrf
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceVrf);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#include "nm-ip4-config.h"
|
#include "nm-ip4-config.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceVxlan
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceVxlan);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
#include "nm-act-request.h"
|
#include "nm-act-request.h"
|
||||||
#include "dns/nm-dns-manager.h"
|
#include "dns/nm-dns-manager.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceWireGuard
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceWireGuard);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
#include "nm-setting-wpan.h"
|
#include "nm-setting-wpan.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceWpan
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceWpan);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@
|
||||||
#include "nm-device-wireguard.h"
|
#include "nm-device-wireguard.h"
|
||||||
|
|
||||||
#include "nm-device-logging.h"
|
#include "nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDevice);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
#include "nm-setting-connection.h"
|
#include "nm-setting-connection.h"
|
||||||
#include "nm-setting-ovs-bridge.h"
|
#include "nm-setting-ovs-bridge.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceOvsBridge
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceOvsBridge);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
#include "nm-setting-ovs-interface.h"
|
#include "nm-setting-ovs-interface.h"
|
||||||
#include "nm-setting-ovs-port.h"
|
#include "nm-setting-ovs-port.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceOvsInterface
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceOvsInterface);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
#include "nm-setting-ovs-port.h"
|
#include "nm-setting-ovs-port.h"
|
||||||
#include "nm-setting-ovs-port.h"
|
#include "nm-setting-ovs-port.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceOvsPort
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceOvsPort);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
#include "nm-ip4-config.h"
|
#include "nm-ip4-config.h"
|
||||||
#include "nm-std-aux/nm-dbus-compat.h"
|
#include "nm-std-aux/nm-dbus-compat.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceTeam
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceTeam);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@
|
||||||
#include "settings/nm-settings.h"
|
#include "settings/nm-settings.h"
|
||||||
#include "supplicant/nm-supplicant-types.h"
|
#include "supplicant/nm-supplicant-types.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceIwd
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceIwd);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
#include "nm-manager.h"
|
#include "nm-manager.h"
|
||||||
#include "platform/nm-platform.h"
|
#include "platform/nm-platform.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceOlpcMesh
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceOlpcMesh);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@
|
||||||
#include "platform/nmp-object.h"
|
#include "platform/nmp-object.h"
|
||||||
#include "settings/nm-settings.h"
|
#include "settings/nm-settings.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceWifiP2P
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceWifiP2P);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
#include "nm-config.h"
|
#include "nm-config.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceWifi
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceWifi);
|
|
||||||
|
|
||||||
#define SCAN_INTERVAL_SEC_MIN 3
|
#define SCAN_INTERVAL_SEC_MIN 3
|
||||||
#define SCAN_INTERVAL_SEC_STEP 20
|
#define SCAN_INTERVAL_SEC_STEP 20
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
|
|
||||||
|
#define _NMLOG_DEVICE_TYPE NMDeviceModem
|
||||||
#include "devices/nm-device-logging.h"
|
#include "devices/nm-device-logging.h"
|
||||||
_LOG_DECLARE_SELF(NMDeviceModem);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue