From patchwork Thu Oct 6 03:16:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 678722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sqHsC49Vdz9sQw for ; Thu, 6 Oct 2016 14:17:51 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id E796710910; Wed, 5 Oct 2016 20:17:03 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id CBB011090B for ; Wed, 5 Oct 2016 20:17:02 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 65105161510 for ; Wed, 5 Oct 2016 21:17:02 -0600 (MDT) X-ASG-Debug-ID: 1475723821-0b32372589613c0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar6.cudamail.com with ESMTP id DZwJeSKAx0nZH9Jh (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 05 Oct 2016 21:17:01 -0600 (MDT) X-Barracuda-Envelope-From: blp@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO relay3-d.mail.gandi.net) (217.70.183.195) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 6 Oct 2016 03:17:01 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at ovn.org designates 217.70.183.195 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.195 X-Barracuda-RBL-IP: 217.70.183.195 Received: from mfilter47-d.gandi.net (mfilter47-d.gandi.net [217.70.178.178]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 07470A80C7; Thu, 6 Oct 2016 05:17:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter47-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter47-d.gandi.net (mfilter47-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id e5OAijt6y8KL; Thu, 6 Oct 2016 05:16:58 +0200 (CEST) X-Originating-IP: 173.228.112.90 Received: from sigabrt.gateway.sonic.net (173-228-112-90.dsl.dynamic.fusionbroadband.com [173.228.112.90]) (Authenticated sender: blp@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id C1D4BA80CD; Thu, 6 Oct 2016 05:16:57 +0200 (CEST) X-CudaMail-Envelope-Sender: blp@ovn.org From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1004093876 X-CudaMail-DTE: 100516 X-CudaMail-Originating-IP: 217.70.183.195 Date: Wed, 5 Oct 2016 20:16:45 -0700 X-ASG-Orig-Subj: [##CM-E2-1004093876##][PATCH 08/15] ovsdb-idlc: Consolidate assertions. Message-Id: <1475723812-20932-8-git-send-email-blp@ovn.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1475723812-20932-1-git-send-email-blp@ovn.org> References: <1475723812-20932-1-git-send-email-blp@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1475723821 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 08/15] ovsdb-idlc: Consolidate assertions. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" There were lots of bits of code emitting "assert(inited);". This combines many of them. Signed-off-by: Ben Pfaff --- ovsdb/ovsdb-idlc.in | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 6a2dc6b..f6f00b3 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -345,6 +345,7 @@ static struct %(s)s * static void %(s)s_parse_%(c)s(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum) { + ovs_assert(inited); struct %(s)s *row = %(s)s_cast(row_);''' % {'s': structName, 'c': columnName} type = column.type @@ -356,7 +357,6 @@ static void valueVar = None if type.is_smap(): - print " ovs_assert(inited);" print " smap_init(&row->%s);" % columnName print " for (size_t i = 0; i < datum->n; i++) {" print " smap_add(&row->%s," % columnName @@ -365,7 +365,6 @@ static void print " }" elif (type.n_min == 1 and type.n_max == 1) or type.is_optional_pointer(): print - print " ovs_assert(inited);" print " if (datum->n >= 1) {" if not type.key.ref_table: print " %s = datum->keys[0].%s;" % (keyVar, type.key.type.to_string()) @@ -388,7 +387,6 @@ static void nMax = "n" else: nMax = "datum->n" - print " ovs_assert(inited);" print " %s = NULL;" % keyVar if valueVar: print " %s = NULL;" % valueVar @@ -706,18 +704,20 @@ const struct ovsdb_datum * nVar = members[1]['name'] print comment - print 'void' - print '%(s)s_set_%(c)s(const struct %(s)s *row, %(args)s)' % \ - {'s': structName, 'c': columnName, - 'args': ', '.join(['%(type)s%(name)s' % m for m in members])} - print "{" - print " struct ovsdb_datum datum;" + print """\ +void +%(s)s_set_%(c)s(const struct %(s)s *row, %(args)s) +{ + ovs_assert(inited); + struct ovsdb_datum datum;""" % {'s': structName, + 'c': columnName, + 'args': ', '.join(['%(type)s%(name)s' + % m for m in members])} if type.n_min == 1 and type.n_max == 1: print " union ovsdb_atom key;" if type.value: print " union ovsdb_atom value;" print - print " ovs_assert(inited);" print " datum.n = 1;" print " datum.keys = &key;" print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar) @@ -730,7 +730,6 @@ const struct ovsdb_datum * elif type.is_optional_pointer(): print " union ovsdb_atom key;" print - print " ovs_assert(inited);" print " if (%s) {" % keyVar print " datum.n = 1;" print " datum.keys = &key;" @@ -744,7 +743,6 @@ const struct ovsdb_datum * elif type.n_max == 1: print " union ovsdb_atom key;" print - print " ovs_assert(inited);" print " if (%s) {" % nVar print " datum.n = 1;" print " datum.keys = &key;" @@ -757,7 +755,6 @@ const struct ovsdb_datum * txn_write_func = "ovsdb_idl_txn_write_clone" else: print - print " ovs_assert(inited);" print " datum.n = %s;" % nVar print " datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar) if type.value: @@ -955,6 +952,7 @@ void {'s': structName, 'c': columnName, 'args': ', '.join(['%(type)s%(name)s' % m for m in members])} print "{" + print " ovs_assert(inited);" print " struct ovsdb_datum datum;" free = [] if type.n_min == 1 and type.n_max == 1: @@ -962,7 +960,6 @@ void if type.value: print " union ovsdb_atom value;" print - print " ovs_assert(inited);" print " datum.n = 1;" print " datum.keys = &key;" print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar, refTable=False) @@ -974,7 +971,6 @@ void elif type.is_optional_pointer(): print " union ovsdb_atom key;" print - print " ovs_assert(inited);" print " if (%s) {" % keyVar print " datum.n = 1;" print " datum.keys = &key;" @@ -987,7 +983,6 @@ void elif type.n_max == 1: print " union ovsdb_atom key;" print - print " ovs_assert(inited);" print " if (%s) {" % nVar print " datum.n = 1;" print " datum.keys = &key;" @@ -998,7 +993,6 @@ void print " }" print " datum.values = NULL;" else: - print " ovs_assert(inited);" print " datum.n = %s;" % nVar print " datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar) free += ['datum.keys'] @@ -1112,6 +1106,7 @@ void {'s': structName, 'c': columnName, 'args': ', '.join(['%(type)s%(name)s' % m for m in members])} print "{" + print " ovs_assert(inited);" print " struct ovsdb_datum datum;" free = [] if type.n_min == 1 and type.n_max == 1: @@ -1119,7 +1114,6 @@ void if type.value: print " union ovsdb_atom value;" print - print " ovs_assert(inited);" print " datum.n = 1;" print " datum.keys = &key;" print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar, refTable=False) @@ -1131,7 +1125,6 @@ void elif type.is_optional_pointer(): print " union ovsdb_atom key;" print - print " ovs_assert(inited);" print " if (%s) {" % keyVar print " datum.n = 1;" print " datum.keys = &key;" @@ -1144,7 +1137,6 @@ void elif type.n_max == 1: print " union ovsdb_atom key;" print - print " ovs_assert(inited);" print " if (%s) {" % nVar print " datum.n = 1;" print " datum.keys = &key;" @@ -1155,7 +1147,6 @@ void print " }" print " datum.values = NULL;" else: - print " ovs_assert(inited);" print " datum.n = %s;" % nVar print " datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar) free += ['datum.keys']