From 02cccc69bcca9148fda5c488784a6bd3c23bf1b4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 15 Dec 2016 19:31:21 +0100 Subject: [PATCH] utils/trivial: rename internal _nl_offset_plus_sizeof() macro to _nl_offsetofend() Kernel calls a very similar macro "offsetofend". So use that name as it migth be more familiar to the reader. Signed-off-by: Thomas Haller --- include/netlink-private/utils.h | 2 +- lib/route/link.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h index 0d5ca9f..f038a80 100644 --- a/include/netlink-private/utils.h +++ b/include/netlink-private/utils.h @@ -25,6 +25,6 @@ extern const char * nl_strerror_l(int err); /* internal macro to calculate the size of a struct @type up to (and including) @field. * this will be used for .minlen policy fields, so that we require only a field of up * to the given size. */ -#define _nl_offset_plus_sizeof(type, field) (offsetof (type, field) + sizeof (((type *) NULL)->field)) +#define _nl_offsetofend(type, field) (offsetof (type, field) + sizeof (((type *) NULL)->field)) #endif diff --git a/lib/route/link.c b/lib/route/link.c index b26f871..4840c23 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -346,8 +346,8 @@ struct nla_policy rtln_link_policy[IFLA_MAX+1] = { [IFLA_LINKINFO] = { .type = NLA_NESTED }, [IFLA_QDISC] = { .type = NLA_STRING, .maxlen = IFQDISCSIZ }, - [IFLA_STATS] = { .minlen = _nl_offset_plus_sizeof (struct rtnl_link_stats, tx_compressed) }, - [IFLA_STATS64] = { .minlen = _nl_offset_plus_sizeof (struct rtnl_link_stats64, tx_compressed) }, + [IFLA_STATS] = { .minlen = _nl_offsetofend (struct rtnl_link_stats, tx_compressed) }, + [IFLA_STATS64] = { .minlen = _nl_offsetofend (struct rtnl_link_stats64, tx_compressed) }, [IFLA_MAP] = { .minlen = sizeof(struct rtnl_link_ifmap) }, [IFLA_IFALIAS] = { .type = NLA_STRING, .maxlen = IFALIASZ }, [IFLA_NUM_VF] = { .type = NLA_U32 }, @@ -413,9 +413,9 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb) link->l_stats[RTNL_LINK_TX_COMPRESSED] = st->tx_compressed; /* beware: @st might not be the full struct, only fields up to - * tx_compressed are present. See _nl_offset_plus_sizeof() above. */ + * tx_compressed are present. See _nl_offsetofend() above. */ - if (nla_len(tb[IFLA_STATS]) >= _nl_offset_plus_sizeof (struct rtnl_link_stats, rx_nohandler)) + if (nla_len(tb[IFLA_STATS]) >= _nl_offsetofend (struct rtnl_link_stats, rx_nohandler)) link->l_stats[RTNL_LINK_RX_NOHANDLER] = st->rx_nohandler; else link->l_stats[RTNL_LINK_RX_NOHANDLER] = 0; @@ -463,7 +463,7 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb) link->l_stats[RTNL_LINK_TX_COMPRESSED] = st.tx_compressed; /* beware: @st might not be the full struct, only fields up to - * tx_compressed are present. See _nl_offset_plus_sizeof() above. */ + * tx_compressed are present. See _nl_offsetofend() above. */ link->l_stats[RTNL_LINK_RX_NOHANDLER] = st.rx_nohandler; -- 2.40.0