summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-03-03 18:42:26 +0100
committerThomas Haller <thaller@redhat.com>2016-03-03 18:45:17 +0100
commit2eccc2fa591fcfb5e4181296f1938fde3d0cbd43 (patch)
treeea251122720cf08bb9cf2867c81e0c96d0765f53
parent4174ba1f8dc3be68eb150d6f1a49da7f9c8dd6b4 (diff)
downloadNetworkManager-bg/logging-messages-bgo763040.tar.gz
fixup! dhcp: client: use logging helpersbg/logging-messages-bgo763040
nm_logging_enabled() is very fast, and for most cases (DEBUG) it returns false. I makes sense to first check whether we would log for either v4 or v6, and only then proceed. Also, drop "NM_IS_DHCP_CLIENT(self) ? ((NMDhcpClient *) self) : NULL". @self really should not be a dangling pointer of a pointer to anything else then a NMDhcpClient. Also, already nm_dhcp_client_get_iface() and nm_dhcp_client_get_ipv6() both already check "g_return_val_if_fail (NM_IS_DHCP_CLIENT(self), ...)".
-rw-r--r--src/dhcp-manager/nm-dhcp-client-logging.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client-logging.h b/src/dhcp-manager/nm-dhcp-client-logging.h
index 970ca6ff35..4d289d8432 100644
--- a/src/dhcp-manager/nm-dhcp-client-logging.h
+++ b/src/dhcp-manager/nm-dhcp-client-logging.h
@@ -27,15 +27,16 @@
#define _NMLOG_PREFIX_NAME "dhcp"
#define _NMLOG(level, ...) \
G_STMT_START { \
- NMDhcpClient *_self = NM_IS_DHCP_CLIENT(self) ? ((NMDhcpClient *) self) : NULL; \
const NMLogLevel _level = (level); \
- const NMLogDomain _domain = !_self ? LOGD_DHCP : \
- nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4; \
\
- if (nm_logging_enabled (_level, _domain)) { \
+ if (nm_logging_enabled (_level, LOGD_DHCP)) { \
+ NMDhcpClient *_self = (NMDhcpClient *) (self); \
const char *__ifname = _self ? nm_dhcp_client_get_iface (_self) : NULL; \
+ const NMLogDomain _domain = !_self \
+ ? LOGD_DHCP \
+ : (nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4); \
\
- _nm_log (_level, _domain, 0, \
+ nm_log (_level, _domain, \
"%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \