From patchwork Fri Apr 13 17:26:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 898043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40N4ZM6qllz9s0t for ; Sat, 14 Apr 2018 03:31:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5E76CE16; Fri, 13 Apr 2018 17:27:19 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7DD35DE3 for ; Fri, 13 Apr 2018 17:27:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EFC8C672 for ; Fri, 13 Apr 2018 17:27:15 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4F52A240008; Fri, 13 Apr 2018 19:27:13 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 13 Apr 2018 10:26:54 -0700 Message-Id: <20180413172655.31638-10-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180413172655.31638-1-blp@ovn.org> References: <20180413172655.31638-1-blp@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 10/11] ovn-nbctl: Simplify lb_info_add_smap(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Ben Pfaff --- ovn/utilities/ovn-nbctl.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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); } }