diff mbox series

[ovs-dev,10/11] ovn-nbctl: Simplify lb_info_add_smap().

Message ID 20180413172655.31638-10-blp@ovn.org
State Accepted
Headers show
Series [ovs-dev,01/11] socket-util: Fix error in comment on ss_format_address(). | expand

Commit Message

Ben Pfaff April 13, 2018, 5:26 p.m. UTC
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ovn/utilities/ovn-nbctl.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 16698de1f049..85d4d3534b54 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1945,11 +1945,9 @@  static void
 lb_info_add_smap(const struct nbrec_load_balancer *lb,
                  struct smap *lbs, int vip_width)
 {
-    struct ds key = DS_EMPTY_INITIALIZER;
-    struct ds val = DS_EMPTY_INITIALIZER;
-
     const struct smap_node **nodes = smap_sort(&lb->vips);
     if (nodes) {
+        struct ds val = DS_EMPTY_INITIALIZER;
         for (int i = 0; i < smap_count(&lb->vips); i++) {
             const struct smap_node *node = nodes[i];
 
@@ -1971,11 +1969,8 @@  lb_info_add_smap(const struct nbrec_load_balancer *lb,
                         node->key, node->value);
         }
 
-        ds_put_format(&key, "%-20.16s", lb->name);
-        smap_add(lbs, ds_cstr(&key), ds_cstr(&val));
-
-        ds_destroy(&key);
-        ds_destroy(&val);
+        smap_add_nocopy(lbs, xasprintf("%-20.16s", lb->name),
+                        ds_steal_cstr(&val));
         free(nodes);
     }
 }