From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft] netlink: use nftnl_udata_put_u32()/nftnl_udata_get_u32()
Date: Mon, 6 Mar 2017 17:48:36 +0100 [thread overview]
Message-ID: <1488818916-4172-1-git-send-email-pablo@netfilter.org> (raw)
Use these new type-specific helper functions instead available in
libnftnl.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/netlink.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/netlink.c b/src/netlink.c
index 8b0fc9403361..2ff9afcefa20 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1143,9 +1143,11 @@ static struct set *netlink_delinearize_set(struct netlink_ctx *ctx,
}
if (ud[UDATA_SET_KEYBYTEORDER])
- keybyteorder = *((uint32_t *)nftnl_udata_get(ud[UDATA_SET_KEYBYTEORDER]));
+ keybyteorder =
+ nftnl_udata_get_u32(ud[UDATA_SET_KEYBYTEORDER]);
if (ud[UDATA_SET_DATABYTEORDER])
- databyteorder = *((uint32_t *)nftnl_udata_get(ud[UDATA_SET_DATABYTEORDER]));
+ databyteorder =
+ nftnl_udata_get_u32(ud[UDATA_SET_DATABYTEORDER]);
}
key = nftnl_set_get_u32(nls, NFTNL_SET_KEY_TYPE);
@@ -1284,13 +1286,13 @@ static int netlink_add_set_batch(struct netlink_ctx *ctx,
udbuf = nftnl_udata_buf_alloc(NFT_USERDATA_MAXLEN);
if (!udbuf)
memory_allocation_error();
- if (!nftnl_udata_put(udbuf, UDATA_SET_KEYBYTEORDER, sizeof(uint32_t),
- &set->keytype->byteorder))
+ if (!nftnl_udata_put_u32(udbuf, UDATA_SET_KEYBYTEORDER,
+ set->keytype->byteorder))
memory_allocation_error();
if (set->flags & NFT_SET_MAP &&
- !nftnl_udata_put(udbuf, UDATA_SET_DATABYTEORDER, sizeof(uint32_t),
- &set->datatype->byteorder))
+ !nftnl_udata_put_u32(udbuf, UDATA_SET_DATABYTEORDER,
+ set->datatype->byteorder))
memory_allocation_error();
nftnl_set_set_data(nls, NFTNL_SET_USERDATA, nftnl_udata_buf_data(udbuf),
--
2.1.4
reply other threads:[~2017-03-06 16:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488818916-4172-1-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).