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-22 09:58:09 +0100
commitdca6d24aab693401483551457942325079206ed2 (patch)
tree6b9872d9eef88d6e5922a141cd96c37beb6ef2a0
parent9cc592ae05a63b162de34d339ac385e3acb7a9ff (diff)
downloadNetworkManager-dca6d24aab693401483551457942325079206ed2.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;