diff options
author | Ben Pfaff <blp@nicira.com> | 2010-12-02 14:53:12 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-12-07 13:44:17 -0800 |
commit | 0bc9407dbbe18734c25e9dc470592def5cb27077 (patch) | |
tree | eac858aaf3b8b7e803b21ed146161a7894b09356 /lib/netlink.c | |
parent | 4b87bea69dd12deed4e20fc389b78f76d47f7984 (diff) |
ofpbuf: New function ofpbuf_use_const().
This is a code cleanup.
Suggested-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'lib/netlink.c')
-rw-r--r-- | lib/netlink.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/netlink.c b/lib/netlink.c index ba32ca3a..f4af2527 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -882,8 +882,7 @@ nl_msg_next(struct ofpbuf *buffer, struct ofpbuf *msg) struct nlmsghdr *nlmsghdr = nl_msg_nlmsghdr(buffer); size_t len = nlmsghdr->nlmsg_len; if (len >= sizeof *nlmsghdr && len <= buffer->size) { - msg->data = nlmsghdr; - msg->size = len; + ofpbuf_use_const(msg, nlmsghdr, len); ofpbuf_pull(buffer, len); return nlmsghdr; } @@ -979,13 +978,11 @@ nl_attr_get_string(const struct nlattr *nla) return nl_attr_get(nla); } -/* Initializes 'nested' to the payload of 'nla'. Doesn't initialize every - * field in 'nested', but enough to poke around with it in a read-only way. */ +/* Initializes 'nested' to the payload of 'nla'. */ void nl_attr_get_nested(const struct nlattr *nla, struct ofpbuf *nested) { - nested->data = (void *) nl_attr_get(nla); - nested->size = nl_attr_get_size(nla); + ofpbuf_use_const(nested, nl_attr_get(nla), nl_attr_get_size(nla)); } /* Default minimum and maximum payload sizes for each type of attribute. */ @@ -1324,8 +1321,7 @@ log_nlmsg(const char *function, int error, return; } - buffer.data = (void *) message; - buffer.size = size; + ofpbuf_use_const(&buffer, message, size); nlmsg = nlmsg_to_string(&buffer); VLOG_DBG_RL(&rl, "%s (%s): %s", function, strerror(error), nlmsg); free(nlmsg); |