Skip to content

Commit 02cccc6

Browse files
committed
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 <[email protected]>
1 parent c033ee8 commit 02cccc6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

include/netlink-private/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ extern const char * nl_strerror_l(int err);
2525
/* internal macro to calculate the size of a struct @type up to (and including) @field.
2626
* this will be used for .minlen policy fields, so that we require only a field of up
2727
* to the given size. */
28-
#define _nl_offset_plus_sizeof(type, field) (offsetof (type, field) + sizeof (((type *) NULL)->field))
28+
#define _nl_offsetofend(type, field) (offsetof (type, field) + sizeof (((type *) NULL)->field))
2929

3030
#endif

lib/route/link.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ struct nla_policy rtln_link_policy[IFLA_MAX+1] = {
346346
[IFLA_LINKINFO] = { .type = NLA_NESTED },
347347
[IFLA_QDISC] = { .type = NLA_STRING,
348348
.maxlen = IFQDISCSIZ },
349-
[IFLA_STATS] = { .minlen = _nl_offset_plus_sizeof (struct rtnl_link_stats, tx_compressed) },
350-
[IFLA_STATS64] = { .minlen = _nl_offset_plus_sizeof (struct rtnl_link_stats64, tx_compressed) },
349+
[IFLA_STATS] = { .minlen = _nl_offsetofend (struct rtnl_link_stats, tx_compressed) },
350+
[IFLA_STATS64] = { .minlen = _nl_offsetofend (struct rtnl_link_stats64, tx_compressed) },
351351
[IFLA_MAP] = { .minlen = sizeof(struct rtnl_link_ifmap) },
352352
[IFLA_IFALIAS] = { .type = NLA_STRING, .maxlen = IFALIASZ },
353353
[IFLA_NUM_VF] = { .type = NLA_U32 },
@@ -413,9 +413,9 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb)
413413
link->l_stats[RTNL_LINK_TX_COMPRESSED] = st->tx_compressed;
414414

415415
/* beware: @st might not be the full struct, only fields up to
416-
* tx_compressed are present. See _nl_offset_plus_sizeof() above. */
416+
* tx_compressed are present. See _nl_offsetofend() above. */
417417

418-
if (nla_len(tb[IFLA_STATS]) >= _nl_offset_plus_sizeof (struct rtnl_link_stats, rx_nohandler))
418+
if (nla_len(tb[IFLA_STATS]) >= _nl_offsetofend (struct rtnl_link_stats, rx_nohandler))
419419
link->l_stats[RTNL_LINK_RX_NOHANDLER] = st->rx_nohandler;
420420
else
421421
link->l_stats[RTNL_LINK_RX_NOHANDLER] = 0;
@@ -463,7 +463,7 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb)
463463
link->l_stats[RTNL_LINK_TX_COMPRESSED] = st.tx_compressed;
464464

465465
/* beware: @st might not be the full struct, only fields up to
466-
* tx_compressed are present. See _nl_offset_plus_sizeof() above. */
466+
* tx_compressed are present. See _nl_offsetofend() above. */
467467

468468
link->l_stats[RTNL_LINK_RX_NOHANDLER] = st.rx_nohandler;
469469

0 commit comments

Comments
 (0)