]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ofp-util: Rearrange ofputil_append_meter_config() to be clearer.
authorBen Pfaff <blp@ovn.org>
Tue, 5 Jan 2016 01:13:53 +0000 (17:13 -0800)
committerBen Pfaff <blp@ovn.org>
Tue, 5 Jan 2016 16:38:38 +0000 (08:38 -0800)
The code is easier to reason about with all of the assignments to the
members of 'reply' in one place.

Suggested-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
lib/ofp-util.c

index fd23a3ad89a7bcfe5b143252a69974df2f4e312e..19901d11285624dee18088f22f0029e55c805127 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -2033,13 +2033,14 @@ ofputil_append_meter_config(struct ovs_list *replies,
 {
     struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
     size_t start_ofs = msg->size;
-    struct ofp13_meter_config *reply = ofpbuf_put_uninit(msg, sizeof *reply);
-    reply->flags = htons(mc->flags);
-    reply->meter_id = htonl(mc->meter_id);
+    struct ofp13_meter_config *reply;
 
+    ofpbuf_put_uninit(msg, sizeof *reply);
     ofputil_put_bands(mc->n_bands, mc->bands, msg);
 
     reply = ofpbuf_at_assert(msg, start_ofs, sizeof *reply);
+    reply->flags = htons(mc->flags);
+    reply->meter_id = htonl(mc->meter_id);
     reply->length = htons(msg->size - start_ofs);
 
     ofpmp_postappend(replies, start_ofs);