diff options
author | Ben Pfaff <blp@ovn.org> | 2017-08-02 15:03:06 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-08-02 15:03:35 -0700 |
commit | 71f21279f62c2cca39ff1522f4d25b5de74992e3 (patch) | |
tree | a97490d3be210eb0ae0813a2aea69ef160ffc57f /ovsdb | |
parent | b24fa3f486d4061cb9facd181fd6234f281904df (diff) | |
download | openvswitch-71f21279f62c2cca39ff1522f4d25b5de74992e3.tar.gz |
Eliminate most shadowing for local variable names.
Shadowing is when a variable with a given name in an inner scope hides a
different variable with the same name in a surrounding scope. This is
generally undesirable because it can confuse programmers. This commit
eliminates most of it.
Found with -Wshadow=local in GCC 7. The repo is not really ready to enable
this option by default because of a few cases that are harder to fix, and
harmless, such as nested use of CMAP_FOR_EACH.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
Diffstat (limited to 'ovsdb')
-rw-r--r-- | ovsdb/jsonrpc-server.c | 6 | ||||
-rw-r--r-- | ovsdb/replication.c | 48 |
2 files changed, 29 insertions, 25 deletions
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 1770c2616..27cbd8449 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -1480,10 +1480,10 @@ ovsdb_jsonrpc_monitor_cond_change(struct ovsdb_jsonrpc_session *s, &m->unflushed, m->condition, m->version); if (update_json) { struct jsonrpc_msg *msg; - struct json *params; + struct json *p; - params = json_array_create_2(json_clone(m->monitor_id), update_json); - msg = ovsdb_jsonrpc_create_notify(m, params); + p = json_array_create_2(json_clone(m->monitor_id), update_json); + msg = ovsdb_jsonrpc_create_notify(m, p); jsonrpc_session_send(s->js, msg); } diff --git a/ovsdb/replication.c b/ovsdb/replication.c index b896adc41..304212d9d 100644 --- a/ovsdb/replication.c +++ b/ovsdb/replication.c @@ -145,6 +145,30 @@ replication_add_local_db(const char *database, struct ovsdb *db) shash_add_assert(&local_dbs, database, db); } +static void +send_schema_requests(const struct json *result) +{ + for (size_t i = 0; i < result->u.array.n; i++) { + const struct json *name = result->u.array.elems[i]; + if (name->type == JSON_STRING) { + /* Send one schema request for each remote DB. */ + const char *db_name = json_string(name); + struct ovsdb *db = find_db(db_name); + if (db) { + struct jsonrpc_msg *request = + jsonrpc_create_request( + "get_schema", + json_array_create_1( + json_string_create(db_name)), + NULL); + + request_ids_add(request->id, db); + jsonrpc_session_send(session, request); + } + } + } +} + void replication_run(void) { @@ -245,26 +269,7 @@ replication_run(void) ovsdb_error_assert(error); state = RPL_S_ERR; } else { - size_t i; - for (i = 0; i < msg->result->u.array.n; i++) { - const struct json *name = msg->result->u.array.elems[i]; - if (name->type == JSON_STRING) { - /* Send one schema request for each remote DB. */ - const char *db_name = json_string(name); - struct ovsdb *db = find_db(db_name); - if (db) { - struct jsonrpc_msg *request = - jsonrpc_create_request( - "get_schema", - json_array_create_1( - json_string_create(db_name)), - NULL); - - request_ids_add(request->id, db); - jsonrpc_session_send(session, request); - } - } - } + send_schema_requests(msg->result); VLOG_DBG("Send schema requests"); state = RPL_S_SCHEMA_REQUESTED; } @@ -299,7 +304,7 @@ replication_run(void) SHASH_FOR_EACH_SAFE (node, next, replication_dbs) { db = node->data; - struct ovsdb_error *error = reset_database(db); + error = reset_database(db); if (error) { const char *db_name = db->schema->name; shash_find_and_delete(replication_dbs, db_name); @@ -315,7 +320,6 @@ replication_run(void) } else { SHASH_FOR_EACH (node, replication_dbs) { db = node->data; - struct ovsdb *db = node->data; struct jsonrpc_msg *request = create_monitor_request(db); |