From patchwork Mon Aug 7 18:01:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 798808 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=) 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 3xR54m3cVjz9s1h for ; Tue, 8 Aug 2017 04:03:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D5BD9B63; Mon, 7 Aug 2017 18:02:22 +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 7C228B30 for ; Mon, 7 Aug 2017 18:02:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7B32920C for ; Mon, 7 Aug 2017 18:01:51 +0000 (UTC) Received: from mfilter11-d.gandi.net (mfilter11-d.gandi.net [217.70.178.131]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 5C1A141C084 for ; Mon, 7 Aug 2017 20:01:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter11-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter11-d.gandi.net (mfilter11-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id MctVMwFDhm6P for ; Mon, 7 Aug 2017 20:01:48 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 20B7141C09B for ; Mon, 7 Aug 2017 20:01:47 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Mon, 7 Aug 2017 11:01:32 -0700 Message-Id: <20170807180133.19988-3-joe@ovn.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170807180133.19988-1-joe@ovn.org> References: <20170807180133.19988-1-joe@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/3] ovsdb-idl: Avoid new expression. 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 In C++, 'new' is a keyword. If this is used as the name for a field, then C++ compilers can get confused about the context and fail to compile references to such fields. Rename the field to 'new_' to avoid this issue. Signed-off-by: Joe Stringer --- lib/ovsdb-data.h | 4 +-- lib/ovsdb-idl-provider.h | 2 +- lib/ovsdb-idl.c | 76 ++++++++++++++++++++++++------------------------ 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/ovsdb-data.h b/lib/ovsdb-data.h index 1bf90d59c30f..521bc553897a 100644 --- a/lib/ovsdb-data.h +++ b/lib/ovsdb-data.h @@ -222,10 +222,10 @@ void ovsdb_datum_subtract(struct ovsdb_datum *a, /* Generate and apply diffs */ void ovsdb_datum_diff(struct ovsdb_datum *diff, const struct ovsdb_datum *old, - const struct ovsdb_datum *new, + const struct ovsdb_datum *new_, const struct ovsdb_type *type); -struct ovsdb_error *ovsdb_datum_apply_diff(struct ovsdb_datum *new, +struct ovsdb_error *ovsdb_datum_apply_diff(struct ovsdb_datum *new_, const struct ovsdb_datum *old, const struct ovsdb_datum *diff, const struct ovsdb_type *type) diff --git a/lib/ovsdb-idl-provider.h b/lib/ovsdb-idl-provider.h index 09cff143f07f..3578f89cb07c 100644 --- a/lib/ovsdb-idl-provider.h +++ b/lib/ovsdb-idl-provider.h @@ -70,7 +70,7 @@ struct ovsdb_idl_row { struct ovsdb_datum *old; /* Committed data (null if orphaned). */ /* Transactional data. */ - struct ovsdb_datum *new; /* Modified data (null to delete row). */ + struct ovsdb_datum *new_; /* Modified data (null to delete row). */ unsigned long int *prereqs; /* Bitmap of columns to verify in "old". */ unsigned long int *written; /* Bitmap of columns from "new" to write. */ struct hmap_node txn_node; /* Node in ovsdb_idl_txn's list. */ diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index d0ecad7cf097..41f98a7df74c 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -761,11 +761,11 @@ ovsdb_idl_check_consistency(const struct ovsdb_idl *idl) const struct ovsdb_idl_row *row; HMAP_FOR_EACH (row, hmap_node, &table->rows) { size_t n_dsts = 0; - if (row->new) { + if (row->new_) { size_t n_columns = shash_count(&row->table->columns); for (size_t j = 0; j < n_columns; j++) { const struct ovsdb_type *type = &class->columns[j].type; - const struct ovsdb_datum *datum = &row->new[j]; + const struct ovsdb_datum *datum = &row->new_[j]; add_row_references(&type->key, datum->keys, datum->n, &row->uuid, &dsts, &n_dsts, &allocated_dsts); @@ -1978,7 +1978,7 @@ ovsdb_idl_row_apply_diff(struct ovsdb_idl_row *row, static bool ovsdb_idl_row_is_orphan(const struct ovsdb_idl_row *row) { - return !row->old && !row->new; + return !row->old && !row->new_; } /* Returns true if 'row' is conceptually part of the database as modified by @@ -2000,7 +2000,7 @@ ovsdb_idl_row_is_orphan(const struct ovsdb_idl_row *row) static bool ovsdb_idl_row_exists(const struct ovsdb_idl_row *row) { - return row->new != NULL; + return row->new_ != NULL; } static void @@ -2030,7 +2030,7 @@ ovsdb_idl_row_unparse(struct ovsdb_idl_row *row) static void ovsdb_idl_row_clear_old(struct ovsdb_idl_row *row) { - ovs_assert(row->old == row->new); + ovs_assert(row->old == row->new_); if (!ovsdb_idl_row_is_orphan(row)) { const struct ovsdb_idl_table_class *class = row->table->class_; size_t i; @@ -2039,28 +2039,28 @@ ovsdb_idl_row_clear_old(struct ovsdb_idl_row *row) ovsdb_datum_destroy(&row->old[i], &class->columns[i].type); } free(row->old); - row->old = row->new = NULL; + row->old = row->new_ = NULL; } } static void ovsdb_idl_row_clear_new(struct ovsdb_idl_row *row) { - if (row->old != row->new) { - if (row->new) { + if (row->old != row->new_) { + if (row->new_) { const struct ovsdb_idl_table_class *class = row->table->class_; size_t i; if (row->written) { BITMAP_FOR_EACH_1 (i, class->n_columns, row->written) { - ovsdb_datum_destroy(&row->new[i], &class->columns[i].type); + ovsdb_datum_destroy(&row->new_[i], &class->columns[i].type); } } - free(row->new); + free(row->new_); free(row->written); row->written = NULL; } - row->new = row->old; + row->new_ = row->old; } } @@ -2226,8 +2226,8 @@ ovsdb_idl_insert_row(struct ovsdb_idl_row *row, const struct json *row_json) const struct ovsdb_idl_table_class *class = row->table->class_; size_t i; - ovs_assert(!row->old && !row->new); - row->old = row->new = xmalloc(class->n_columns * sizeof *row->old); + ovs_assert(!row->old && !row->new_); + row->old = row->new_ = xmalloc(class->n_columns * sizeof *row->old); for (i = 0; i < class->n_columns; i++) { ovsdb_datum_init_default(&row->old[i], &class->columns[i].type); } @@ -2330,7 +2330,7 @@ ovsdb_idl_get_row_arc(struct ovsdb_idl_row *src, * * Just return the destination row, if there is one and it has not been * deleted. */ - if (dst && (hmap_node_is_null(&dst->txn_node) || dst->new)) { + if (dst && (hmap_node_is_null(&dst->txn_node) || dst->new_)) { return dst; } return NULL; @@ -2427,11 +2427,11 @@ ovsdb_idl_read(const struct ovsdb_idl_row *row, class = row->table->class_; column_idx = column - class->columns; - ovs_assert(row->new != NULL); + ovs_assert(row->new_ != NULL); ovs_assert(column_idx < class->n_columns); if (row->written && bitmap_is_set(row->written, column_idx)) { - return &row->new[column_idx]; + return &row->new_[column_idx]; } else if (row->old) { return &row->old[column_idx]; } else { @@ -2470,7 +2470,7 @@ bool ovsdb_idl_is_mutable(const struct ovsdb_idl_row *row, const struct ovsdb_idl_column *column) { - return column->mutable || (row->new && !row->old); + return column->mutable || (row->new_ && !row->old); } /* Returns false if 'row' was obtained from the IDL, true if it was initialized @@ -2699,7 +2699,7 @@ substitute_uuids(struct json *json, const struct ovsdb_idl_txn *txn) const struct ovsdb_idl_row *row; row = ovsdb_idl_txn_get_row(txn, &uuid); - if (row && !row->old && row->new) { + if (row && !row->old && row->new_) { json_destroy(json); return json_array_create_2( @@ -2788,8 +2788,8 @@ ovsdb_idl_txn_extract_mutations(struct ovsdb_idl_row *row, value_type = column->type.value.type; /* Get the value to be changed */ - if (row->new && row->written && bitmap_is_set(row->written,idx)) { - old_datum = &row->new[idx]; + if (row->new_ && row->written && bitmap_is_set(row->written,idx)) { + old_datum = &row->new_[idx]; } else if (row->old != NULL) { old_datum = &row->old[idx]; } else { @@ -2896,8 +2896,8 @@ ovsdb_idl_txn_extract_mutations(struct ovsdb_idl_row *row, key_type = column->type.key.type; /* Get the value to be changed */ - if (row->new && row->written && bitmap_is_set(row->written,idx)) { - old_datum = &row->new[idx]; + if (row->new_ && row->written && bitmap_is_set(row->written,idx)) { + old_datum = &row->new_[idx]; } else if (row->old != NULL) { old_datum = &row->old[idx]; } else { @@ -3072,7 +3072,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) HMAP_FOR_EACH (row, txn_node, &txn->txn_rows) { const struct ovsdb_idl_table_class *class = row->table->class_; - if (!row->new) { + if (!row->new_) { if (class->is_root) { struct json *op = json_object_create(); json_object_put_string(op, "op", "delete"); @@ -3083,7 +3083,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) } else { /* Let ovsdb-server decide whether to really delete it. */ } - } else if (row->old != row->new) { + } else if (row->old != row->new_) { struct json *row_json; struct json *op; size_t idx; @@ -3118,11 +3118,11 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) &class->columns[idx]; if (row->old - || !ovsdb_datum_is_default(&row->new[idx], + || !ovsdb_datum_is_default(&row->new_[idx], &column->type)) { json_object_put(row_json, column->name, substitute_uuids( - ovsdb_datum_to_json(&row->new[idx], + ovsdb_datum_to_json(&row->new_[idx], &column->type), txn)); @@ -3131,7 +3131,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) * or transactions would become nonatomic (see the big * comment inside ovsdb_idl_txn_write()). */ if (!any_updates && row->old && - !ovsdb_datum_equals(&row->old[idx], &row->new[idx], + !ovsdb_datum_equals(&row->old[idx], &row->new_[idx], &column->type)) { any_updates = true; } @@ -3370,7 +3370,7 @@ ovsdb_idl_txn_write__(const struct ovsdb_idl_row *row_, column_idx = column - class->columns; write_only = row->table->modes[column_idx] == OVSDB_IDL_MONITOR; - ovs_assert(row->new != NULL); + ovs_assert(row->new_ != NULL); ovs_assert(column_idx < class->n_columns); ovs_assert(row->old == NULL || row->table->modes[column_idx] & OVSDB_IDL_MONITOR); @@ -3401,24 +3401,24 @@ ovsdb_idl_txn_write__(const struct ovsdb_idl_row *row_, hmap_insert(&row->table->idl->txn->txn_rows, &row->txn_node, uuid_hash(&row->uuid)); } - if (row->old == row->new) { - row->new = xmalloc(class->n_columns * sizeof *row->new); + if (row->old == row->new_) { + row->new_ = xmalloc(class->n_columns * sizeof *row->new_); } if (!row->written) { row->written = bitmap_allocate(class->n_columns); } if (bitmap_is_set(row->written, column_idx)) { - ovsdb_datum_destroy(&row->new[column_idx], &column->type); + ovsdb_datum_destroy(&row->new_[column_idx], &column->type); } else { bitmap_set1(row->written, column_idx); } if (owns_datum) { - row->new[column_idx] = *datum; + row->new_[column_idx] = *datum; } else { - ovsdb_datum_clone(&row->new[column_idx], datum, &column->type); + ovsdb_datum_clone(&row->new_[column_idx], datum, &column->type); } (column->unparse)(row); - (column->parse)(row, &row->new[column_idx]); + (column->parse)(row, &row->new_[column_idx]); return; discard_datum: @@ -3511,7 +3511,7 @@ ovsdb_idl_txn_verify(const struct ovsdb_idl_row *row_, class = row->table->class_; column_idx = column - class->columns; - ovs_assert(row->new != NULL); + ovs_assert(row->new_ != NULL); ovs_assert(row->old == NULL || row->table->modes[column_idx] & OVSDB_IDL_MONITOR); if (!row->old @@ -3545,7 +3545,7 @@ ovsdb_idl_txn_delete(const struct ovsdb_idl_row *row_) return; } - ovs_assert(row->new != NULL); + ovs_assert(row->new_ != NULL); if (!row->old) { ovsdb_idl_row_unparse(row); ovsdb_idl_row_clear_new(row); @@ -3560,7 +3560,7 @@ ovsdb_idl_txn_delete(const struct ovsdb_idl_row *row_) uuid_hash(&row->uuid)); } ovsdb_idl_row_clear_new(row); - row->new = NULL; + row->new_ = NULL; } /* Inserts and returns a new row in the table with the specified 'class' in the @@ -3590,7 +3590,7 @@ ovsdb_idl_txn_insert(struct ovsdb_idl_txn *txn, } row->table = ovsdb_idl_table_from_class(txn->idl, class); - row->new = xmalloc(class->n_columns * sizeof *row->new); + row->new_ = xmalloc(class->n_columns * sizeof *row->new_); hmap_insert(&row->table->rows, &row->hmap_node, uuid_hash(&row->uuid)); hmap_insert(&txn->txn_rows, &row->txn_node, uuid_hash(&row->uuid)); return row;