summaryrefslogtreecommitdiff
path: root/lib/ofp-msgs.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2016-02-18 15:13:09 -0800
committerBen Pfaff <blp@ovn.org>2016-02-19 16:15:44 -0800
commit0a2869d524fc3612b4b77a9df4991bff2aa3b465 (patch)
treec38541ea9f2fb165344974356de31b92c4c872b3 /lib/ofp-msgs.c
parentde658847fd5703ac7ac6413ec29ecf7f4db91421 (diff)
downloadopenvswitch-0a2869d524fc3612b4b77a9df4991bff2aa3b465.tar.gz
ofpbuf: New function ofpbuf_const_initializer().
A number of times I've looked at code and thought that it would be easier to understand if I could write an initializer instead of ofpbuf_use_const(). This commit adds a function for that purpose and adapts a lot of code to use it, in the places where I thought it made the code better. In theory this could improve code generation since the new function can be inlined whereas ofpbuf_use_const() isn't. But I guess that's probably insignificant; the intent of this change is code readability. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
Diffstat (limited to 'lib/ofp-msgs.c')
-rw-r--r--lib/ofp-msgs.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c
index bc38f401b..de20655b4 100644
--- a/lib/ofp-msgs.c
+++ b/lib/ofp-msgs.c
@@ -407,9 +407,7 @@ ofphdrs_len(const struct ofphdrs *hdrs)
enum ofperr
ofpraw_decode(enum ofpraw *raw, const struct ofp_header *oh)
{
- struct ofpbuf msg;
-
- ofpbuf_use_const(&msg, oh, ntohs(oh->length));
+ struct ofpbuf msg = ofpbuf_const_initializer(oh, ntohs(oh->length));
return ofpraw_pull(raw, &msg);
}