From 0a2869d524fc3612b4b77a9df4991bff2aa3b465 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 18 Feb 2016 15:13:09 -0800 Subject: 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 Acked-by: Jarno Rajahalme --- lib/ofp-msgs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/ofp-msgs.c') 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); } -- cgit v1.2.1