summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-02-17 11:24:38 +0100
committerThomas Haller <thaller@redhat.com>2019-02-21 21:02:51 +0100
commit873a7d796c59672a477919d49bc91069c05a21c4 (patch)
tree7c4830ac2f1f00fe9cd33900728e6b8acad545e3
parent11f01bde151820140d180a47e29ed5a9241a7300 (diff)
downloadNetworkManager-873a7d796c59672a477919d49bc91069c05a21c4.tar.gz
platform: drop READ_STAT64() macro from _new_from_nl_link()
It doesn't make it easier to read. Also, the code comment points out something rather obvious, as we later use unaligned API to access the fields.
-rw-r--r--src/platform/nm-linux-platform.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 52dd65fef7..14384065f3 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2736,18 +2736,12 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
}
if (tb[IFLA_STATS64]) {
- /* tb[IFLA_STATS64] is only guaranteed to be 32bit-aligned,
- * so in general we can't access the rtnl_link_stats64 struct
- * members directly on 64bit architectures. */
- char *stats = nla_data (tb[IFLA_STATS64]);
-
-#define READ_STAT64(member) \
- unaligned_read_ne64 (stats + offsetof (struct rtnl_link_stats64, member))
-
- obj->link.rx_packets = READ_STAT64 (rx_packets);
- obj->link.rx_bytes = READ_STAT64 (rx_bytes);
- obj->link.tx_packets = READ_STAT64 (tx_packets);
- obj->link.tx_bytes = READ_STAT64 (tx_bytes);
+ const char *stats = nla_data (tb[IFLA_STATS64]);
+
+ obj->link.rx_packets = unaligned_read_ne64 (&stats[G_STRUCT_OFFSET (struct rtnl_link_stats64, rx_packets)]);
+ obj->link.rx_bytes = unaligned_read_ne64 (&stats[G_STRUCT_OFFSET (struct rtnl_link_stats64, rx_bytes)]);
+ obj->link.tx_packets = unaligned_read_ne64 (&stats[G_STRUCT_OFFSET (struct rtnl_link_stats64, tx_packets)]);
+ obj->link.tx_bytes = unaligned_read_ne64 (&stats[G_STRUCT_OFFSET (struct rtnl_link_stats64, tx_bytes)]);
}
obj->link.n_ifi_flags = ifi->ifi_flags;