diff --git a/include/openvswitch/json.h b/include/openvswitch/json.h index bcf6a2782..73b562e03 100644 --- a/include/openvswitch/json.h +++ b/include/openvswitch/json.h @@ -71,7 +71,7 @@ struct json { long long int integer; double real; char *string; - } u; + }; }; struct json *json_null_create(void); diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index bfd7a54a8..f2a17f7d1 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1809,12 +1809,12 @@ cmd_show_row(struct ctl_context *ctx, const struct ovsdb_idl_row *row, datum = ovsdb_idl_read(row, column); if (column->type.key.type == OVSDB_TYPE_UUID && - column->type.key.u.uuid.refTableName) { + column->type.key.uuid.refTableName) { const struct cmd_show_table *ref_show; size_t j; ref_show = cmd_show_find_table_by_name( - column->type.key.u.uuid.refTableName); + column->type.key.uuid.refTableName); if (ref_show) { for (j = 0; j < datum->n; j++) { const struct ovsdb_idl_row *ref_row; @@ -1830,14 +1830,14 @@ cmd_show_row(struct ctl_context *ctx, const struct ovsdb_idl_row *row, } } else if (ovsdb_type_is_map(&column->type) && column->type.value.type == OVSDB_TYPE_UUID && - column->type.value.u.uuid.refTableName) { + column->type.value.uuid.refTableName) { const struct cmd_show_table *ref_show; size_t j; /* Prints the key to ref'ed table name map if the ref'ed table * is also defined in 'cmd_show_tables'. */ ref_show = cmd_show_find_table_by_name( - column->type.value.u.uuid.refTableName); + column->type.value.uuid.refTableName); if (ref_show && ref_show->name_column) { ds_put_char_multiple(&ctx->output, ' ', (level + 1) * 4); ds_put_format(&ctx->output, "%s:\n", column->name); diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index b8b7f130b..818b184ee 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3061,19 +3061,19 @@ dpif_netdev_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) switch (op->type) { case DPIF_OP_FLOW_PUT: - op->error = dpif_netdev_flow_put(dpif, &op->u.flow_put); + op->error = dpif_netdev_flow_put(dpif, &op->flow_put); break; case DPIF_OP_FLOW_DEL: - op->error = dpif_netdev_flow_del(dpif, &op->u.flow_del); + op->error = dpif_netdev_flow_del(dpif, &op->flow_del); break; case DPIF_OP_EXECUTE: - op->error = dpif_netdev_execute(dpif, &op->u.execute); + op->error = dpif_netdev_execute(dpif, &op->execute); break; case DPIF_OP_FLOW_GET: - op->error = dpif_netdev_flow_get(dpif, &op->u.flow_get); + op->error = dpif_netdev_flow_get(dpif, &op->flow_get); break; } } diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 41f42dc5e..1bd10a6ea 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -1923,7 +1923,7 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, switch (op->type) { case DPIF_OP_FLOW_PUT: - put = &op->u.flow_put; + put = &op->flow_put; dpif_netlink_init_flow_put(dpif, put, &flow); if (put->stats) { flow.nlmsg_flags |= NLM_F_ECHO; @@ -1933,7 +1933,7 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, break; case DPIF_OP_FLOW_DEL: - del = &op->u.flow_del; + del = &op->flow_del; dpif_netlink_init_flow_del(dpif, del, &flow); if (del->stats) { flow.nlmsg_flags |= NLM_F_ECHO; @@ -1945,26 +1945,26 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, case DPIF_OP_EXECUTE: /* Can't execute a packet that won't fit in a Netlink attribute. */ if (OVS_UNLIKELY(nl_attr_oversized( - dp_packet_size(op->u.execute.packet)))) { + dp_packet_size(op->execute.packet)))) { /* Report an error immediately if this is the first operation. * Otherwise the easiest thing to do is to postpone to the next * call (when this will be the first operation). */ if (i == 0) { VLOG_ERR_RL(&error_rl, "dropping oversized %"PRIu32"-byte packet", - dp_packet_size(op->u.execute.packet)); + dp_packet_size(op->execute.packet)); op->error = ENOBUFS; return 1; } n_ops = i; } else { - dpif_netlink_encode_execute(dpif->dp_ifindex, &op->u.execute, + dpif_netlink_encode_execute(dpif->dp_ifindex, &op->execute, &aux->request); } break; case DPIF_OP_FLOW_GET: - get = &op->u.flow_get; + get = &op->flow_get; dpif_netlink_init_flow_get(dpif, get, &flow); aux->txn.reply = get->buffer; dpif_netlink_flow_to_ofpbuf(&flow, &aux->request); @@ -1992,7 +1992,7 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, switch (op->type) { case DPIF_OP_FLOW_PUT: - put = &op->u.flow_put; + put = &op->flow_put; if (put->stats) { if (!op->error) { struct dpif_netlink_flow reply; @@ -2007,7 +2007,7 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, break; case DPIF_OP_FLOW_DEL: - del = &op->u.flow_del; + del = &op->flow_del; if (del->stats) { if (!op->error) { struct dpif_netlink_flow reply; @@ -2025,7 +2025,7 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, break; case DPIF_OP_FLOW_GET: - get = &op->u.flow_get; + get = &op->flow_get; if (!op->error) { struct dpif_netlink_flow reply; @@ -2157,12 +2157,12 @@ parse_flow_put(struct dpif_netlink *dpif, struct dpif_flow_put *put) struct dpif_op op; op.type = DPIF_OP_FLOW_DEL; - op.u.flow_del.key = put->key; - op.u.flow_del.key_len = put->key_len; - op.u.flow_del.ufid = put->ufid; - op.u.flow_del.pmd_id = put->pmd_id; - op.u.flow_del.stats = NULL; - op.u.flow_del.terse = false; + op.flow_del.key = put->key; + op.flow_del.key_len = put->key_len; + op.flow_del.ufid = put->ufid; + op.flow_del.pmd_id = put->pmd_id; + op.flow_del.stats = NULL; + op.flow_del.terse = false; opp = &op; dpif_netlink_operate__(dpif, &opp, 1); @@ -2203,7 +2203,7 @@ try_send_to_netdev(struct dpif_netlink *dpif, struct dpif_op *op) switch (op->type) { case DPIF_OP_FLOW_PUT: { - struct dpif_flow_put *put = &op->u.flow_put; + struct dpif_flow_put *put = &op->flow_put; if (!put->ufid) { break; @@ -2214,7 +2214,7 @@ try_send_to_netdev(struct dpif_netlink *dpif, struct dpif_op *op) break; } case DPIF_OP_FLOW_DEL: { - struct dpif_flow_del *del = &op->u.flow_del; + struct dpif_flow_del *del = &op->flow_del; if (!del->ufid) { break; @@ -2226,9 +2226,9 @@ try_send_to_netdev(struct dpif_netlink *dpif, struct dpif_op *op) break; } case DPIF_OP_FLOW_GET: { - struct dpif_flow_get *get = &op->u.flow_get; + struct dpif_flow_get *get = &op->flow_get; - if (!op->u.flow_get.ufid) { + if (!op->flow_get.ufid) { break; } diff --git a/lib/dpif.c b/lib/dpif.c index 1f5929c62..3c7d3b8a2 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -998,16 +998,16 @@ dpif_flow_get(struct dpif *dpif, struct dpif_op op; op.type = DPIF_OP_FLOW_GET; - op.u.flow_get.key = key; - op.u.flow_get.key_len = key_len; - op.u.flow_get.ufid = ufid; - op.u.flow_get.pmd_id = pmd_id; - op.u.flow_get.buffer = buf; + op.flow_get.key = key; + op.flow_get.key_len = key_len; + op.flow_get.ufid = ufid; + op.flow_get.pmd_id = pmd_id; + op.flow_get.buffer = buf; memset(flow, 0, sizeof *flow); - op.u.flow_get.flow = flow; - op.u.flow_get.flow->key = key; - op.u.flow_get.flow->key_len = key_len; + op.flow_get.flow = flow; + op.flow_get.flow->key = key; + op.flow_get.flow->key_len = key_len; opp = &op; dpif_operate(dpif, &opp, 1); @@ -1028,16 +1028,16 @@ dpif_flow_put(struct dpif *dpif, enum dpif_flow_put_flags flags, struct dpif_op op; op.type = DPIF_OP_FLOW_PUT; - op.u.flow_put.flags = flags; - op.u.flow_put.key = key; - op.u.flow_put.key_len = key_len; - op.u.flow_put.mask = mask; - op.u.flow_put.mask_len = mask_len; - op.u.flow_put.actions = actions; - op.u.flow_put.actions_len = actions_len; - op.u.flow_put.ufid = ufid; - op.u.flow_put.pmd_id = pmd_id; - op.u.flow_put.stats = stats; + op.flow_put.flags = flags; + op.flow_put.key = key; + op.flow_put.key_len = key_len; + op.flow_put.mask = mask; + op.flow_put.mask_len = mask_len; + op.flow_put.actions = actions; + op.flow_put.actions_len = actions_len; + op.flow_put.ufid = ufid; + op.flow_put.pmd_id = pmd_id; + op.flow_put.stats = stats; opp = &op; dpif_operate(dpif, &opp, 1); @@ -1055,12 +1055,12 @@ dpif_flow_del(struct dpif *dpif, struct dpif_op op; op.type = DPIF_OP_FLOW_DEL; - op.u.flow_del.key = key; - op.u.flow_del.key_len = key_len; - op.u.flow_del.ufid = ufid; - op.u.flow_del.pmd_id = pmd_id; - op.u.flow_del.stats = stats; - op.u.flow_del.terse = false; + op.flow_del.key = key; + op.flow_del.key_len = key_len; + op.flow_del.ufid = ufid; + op.flow_del.pmd_id = pmd_id; + op.flow_del.stats = stats; + op.flow_del.terse = false; opp = &op; dpif_operate(dpif, &opp, 1); @@ -1317,7 +1317,7 @@ dpif_execute(struct dpif *dpif, struct dpif_execute *execute) struct dpif_op op; op.type = DPIF_OP_EXECUTE; - op.u.execute = *execute; + op.execute = *execute; opp = &op; dpif_operate(dpif, &opp, 1); @@ -1345,7 +1345,7 @@ dpif_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) struct dpif_op *op = ops[chunk]; if (op->type == DPIF_OP_EXECUTE - && dpif_execute_needs_help(&op->u.execute)) { + && dpif_execute_needs_help(&op->execute)) { break; } } @@ -1363,7 +1363,7 @@ dpif_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) switch (op->type) { case DPIF_OP_FLOW_PUT: { - struct dpif_flow_put *put = &op->u.flow_put; + struct dpif_flow_put *put = &op->flow_put; COVERAGE_INC(dpif_flow_put); log_flow_put_message(dpif, &this_module, put, error); @@ -1374,7 +1374,7 @@ dpif_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) } case DPIF_OP_FLOW_GET: { - struct dpif_flow_get *get = &op->u.flow_get; + struct dpif_flow_get *get = &op->flow_get; COVERAGE_INC(dpif_flow_get); if (error) { @@ -1386,7 +1386,7 @@ dpif_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) } case DPIF_OP_FLOW_DEL: { - struct dpif_flow_del *del = &op->u.flow_del; + struct dpif_flow_del *del = &op->flow_del; COVERAGE_INC(dpif_flow_del); log_flow_del_message(dpif, &this_module, del, error); @@ -1398,7 +1398,7 @@ dpif_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) case DPIF_OP_EXECUTE: COVERAGE_INC(dpif_execute); - log_execute_message(dpif, &this_module, &op->u.execute, + log_execute_message(dpif, &this_module, &op->execute, false, error); break; } @@ -1411,7 +1411,7 @@ dpif_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops) struct dpif_op *op = ops[0]; COVERAGE_INC(dpif_execute); - op->error = dpif_execute_with_help(dpif, &op->u.execute); + op->error = dpif_execute_with_help(dpif, &op->execute); ops++; n_ops--; } diff --git a/lib/dpif.h b/lib/dpif.h index 94f89eca9..053465136 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -760,7 +760,7 @@ struct dpif_op { struct dpif_flow_del flow_del; struct dpif_execute execute; struct dpif_flow_get flow_get; - } u; + }; }; void dpif_operate(struct dpif *, struct dpif_op **ops, size_t n_ops); diff --git a/lib/json.c b/lib/json.c index 603fd1df8..99a68a3d9 100644 --- a/lib/json.c +++ b/lib/json.c @@ -59,7 +59,7 @@ struct json_token { double real; long long int integer; const char *string; - } u; + }; }; enum json_lex_state { @@ -170,7 +170,7 @@ struct json * json_string_create_nocopy(char *s) { struct json *json = json_create(JSON_STRING); - json->u.string = s; + json->string = s; return json; } @@ -184,9 +184,9 @@ struct json * json_array_create_empty(void) { struct json *json = json_create(JSON_ARRAY); - json->u.array.elems = NULL; - json->u.array.n = 0; - json->u.array.n_allocated = 0; + json->array.elems = NULL; + json->array.n = 0; + json->array.n_allocated = 0; return json; } @@ -215,9 +215,9 @@ struct json * json_array_create(struct json **elements, size_t n) { struct json *json = json_create(JSON_ARRAY); - json->u.array.elems = elements; - json->u.array.n = n; - json->u.array.n_allocated = n; + json->array.elems = elements; + json->array.n = n; + json->array.n_allocated = n; return json; } @@ -252,8 +252,8 @@ struct json * json_object_create(void) { struct json *json = json_create(JSON_OBJECT); - json->u.object = xmalloc(sizeof *json->u.object); - shash_init(json->u.object); + json->object = xmalloc(sizeof *json->object); + shash_init(json->object); return json; } @@ -261,7 +261,7 @@ struct json * json_integer_create(long long int integer) { struct json *json = json_create(JSON_INTEGER); - json->u.integer = integer; + json->integer = integer; return json; } @@ -269,20 +269,20 @@ struct json * json_real_create(double real) { struct json *json = json_create(JSON_REAL); - json->u.real = real; + json->real = real; return json; } void json_object_put(struct json *json, const char *name, struct json *value) { - json_destroy(shash_replace(json->u.object, name, value)); + json_destroy(shash_replace(json->object, name, value)); } void json_object_put_nocopy(struct json *json, char *name, struct json *value) { - json_destroy(shash_replace_nocopy(json->u.object, name, value)); + json_destroy(shash_replace_nocopy(json->object, name, value)); } void @@ -306,21 +306,21 @@ const char * json_string(const struct json *json) { ovs_assert(json->type == JSON_STRING); - return json->u.string; + return json->string; } struct json_array * json_array(const struct json *json) { ovs_assert(json->type == JSON_ARRAY); - return CONST_CAST(struct json_array *, &json->u.array); + return CONST_CAST(struct json_array *, &json->array); } struct shash * json_object(const struct json *json) { ovs_assert(json->type == JSON_OBJECT); - return CONST_CAST(struct shash *, json->u.object); + return CONST_CAST(struct shash *, json->object); } bool @@ -334,14 +334,14 @@ double json_real(const struct json *json) { ovs_assert(json->type == JSON_REAL || json->type == JSON_INTEGER); - return json->type == JSON_REAL ? json->u.real : json->u.integer; + return json->type == JSON_REAL ? json->real : json->integer; } int64_t json_integer(const struct json *json) { ovs_assert(json->type == JSON_INTEGER); - return json->u.integer; + return json->integer; } static void json_destroy_object(struct shash *object); @@ -354,15 +354,15 @@ json_destroy(struct json *json) if (json && !--json->count) { switch (json->type) { case JSON_OBJECT: - json_destroy_object(json->u.object); + json_destroy_object(json->object); break; case JSON_ARRAY: - json_destroy_array(&json->u.array); + json_destroy_array(&json->array); break; case JSON_STRING: - free(json->u.string); + free(json->string); break; case JSON_NULL: @@ -414,13 +414,13 @@ json_deep_clone(const struct json *json) { switch (json->type) { case JSON_OBJECT: - return json_clone_object(json->u.object); + return json_clone_object(json->object); case JSON_ARRAY: - return json_clone_array(&json->u.array); + return json_clone_array(&json->array); case JSON_STRING: - return json_string_create(json->u.string); + return json_string_create(json->string); case JSON_NULL: case JSON_FALSE: @@ -428,10 +428,10 @@ json_deep_clone(const struct json *json) return json_create(json->type); case JSON_INTEGER: - return json_integer_create(json->u.integer); + return json_integer_create(json->integer); case JSON_REAL: - return json_real_create(json->u.real); + return json_real_create(json->real); case JSON_N_TYPES: default: @@ -515,13 +515,13 @@ json_hash(const struct json *json, size_t basis) { switch (json->type) { case JSON_OBJECT: - return json_hash_object(json->u.object, basis); + return json_hash_object(json->object, basis); case JSON_ARRAY: - return json_hash_array(&json->u.array, basis); + return json_hash_array(&json->array, basis); case JSON_STRING: - return hash_string(json->u.string, basis); + return hash_string(json->string, basis); case JSON_NULL: case JSON_FALSE: @@ -529,10 +529,10 @@ json_hash(const struct json *json, size_t basis) return hash_int(json->type << 8, basis); case JSON_INTEGER: - return hash_int(json->u.integer, basis); + return hash_int(json->integer, basis); case JSON_REAL: - return hash_double(json->u.real, basis); + return hash_double(json->real, basis); case JSON_N_TYPES: default: @@ -590,13 +590,13 @@ json_equal(const struct json *a, const struct json *b) switch (a->type) { case JSON_OBJECT: - return json_equal_object(a->u.object, b->u.object); + return json_equal_object(a->object, b->object); case JSON_ARRAY: - return json_equal_array(&a->u.array, &b->u.array); + return json_equal_array(&a->array, &b->array); case JSON_STRING: - return !strcmp(a->u.string, b->u.string); + return !strcmp(a->string, b->string); case JSON_NULL: case JSON_FALSE: @@ -604,10 +604,10 @@ json_equal(const struct json *a, const struct json *b) return true; case JSON_INTEGER: - return a->u.integer == b->u.integer; + return a->integer == b->integer; case JSON_REAL: - return a->u.real == b->u.real; + return a->real == b->real; case JSON_N_TYPES: default: @@ -742,7 +742,7 @@ json_lex_number(struct json_parser *p) * We suppress negative zeros as a matter of policy. */ if (!significand) { token.type = T_INTEGER; - token.u.integer = 0; + token.integer = 0; json_parser_input(p, &token); return; } @@ -761,20 +761,20 @@ json_lex_number(struct json_parser *p) ? (unsigned long long int) LLONG_MAX + 1 : LLONG_MAX)) { token.type = T_INTEGER; - token.u.integer = negative ? -significand : significand; + token.integer = negative ? -significand : significand; json_parser_input(p, &token); return; } } token.type = T_REAL; - if (!str_to_double(ds_cstr(&p->buffer), &token.u.real)) { + if (!str_to_double(ds_cstr(&p->buffer), &token.real)) { json_error(p, "number outside valid range"); return; } /* Suppress negative zero. */ - if (token.u.real == 0) { - token.u.real = 0; + if (token.real == 0) { + token.real = 0; } json_parser_input(p, &token); } @@ -922,7 +922,7 @@ json_string_escape(const char *in, struct ds *out) { struct json json = { .type = JSON_STRING, - .u.string = CONST_CAST(char *, in), + .string = CONST_CAST(char *, in), }; json_to_ds(&json, 0, out); } @@ -933,7 +933,7 @@ json_parser_input_string(struct json_parser *p, const char *s) struct json_token token; token.type = T_STRING; - token.u.string = s; + token.string = s; json_parser_input(p, &token); } @@ -1298,15 +1298,15 @@ json_parse_value(struct json_parser *p, struct json_token *token, return; case T_INTEGER: - value = json_integer_create(token->u.integer); + value = json_integer_create(token->integer); break; case T_REAL: - value = json_real_create(token->u.real); + value = json_real_create(token->real); break; case T_STRING: - value = json_string_create(token->u.string); + value = json_string_create(token->string); break; case T_EOF: @@ -1379,7 +1379,7 @@ json_parser_input(struct json_parser *p, struct json_token *token) /* Fall through. */ case JSON_PARSE_OBJECT_NAME: if (token->type == T_STRING) { - p->member_name = xstrdup(token->u.string); + p->member_name = xstrdup(token->string); p->parse_state = JSON_PARSE_OBJECT_COLON; } else { json_error(p, "syntax error parsing object expecting string"); @@ -1535,23 +1535,23 @@ json_serialize(const struct json *json, struct json_serializer *s) break; case JSON_OBJECT: - json_serialize_object(json->u.object, s); + json_serialize_object(json->object, s); break; case JSON_ARRAY: - json_serialize_array(&json->u.array, s); + json_serialize_array(&json->array, s); break; case JSON_INTEGER: - ds_put_format(ds, "%lld", json->u.integer); + ds_put_format(ds, "%lld", json->integer); break; case JSON_REAL: - ds_put_format(ds, "%.*g", DBL_DIG, json->u.real); + ds_put_format(ds, "%.*g", DBL_DIG, json->real); break; case JSON_STRING: - json_serialize_string(json->u.string, ds); + json_serialize_string(json->string, ds); break; case JSON_N_TYPES: diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index f71026271..4c2c1ba84 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -695,7 +695,7 @@ jsonrpc_msg_from_json(struct json *json, struct jsonrpc_msg **msgp) } msg = xzalloc(sizeof *msg); - msg->method = method ? xstrdup(method->u.string) : NULL; + msg->method = method ? xstrdup(method->string) : NULL; msg->params = null_from_json_null(shash_find_and_delete(object, "params")); msg->result = null_from_json_null(shash_find_and_delete(object, "result")); msg->error = null_from_json_null(shash_find_and_delete(object, "error")); @@ -1129,7 +1129,7 @@ jsonrpc_session_recv(struct jsonrpc_session *s) jsonrpc_session_send(s, reply); } else if (msg->type == JSONRPC_REPLY && msg->id && msg->id->type == JSON_STRING - && !strcmp(msg->id->u.string, "echo")) { + && !strcmp(msg->id->string, "echo")) { /* It's a reply to our echo request. Suppress it. */ } else { return msg; diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index 13bc580db..fbc98dd05 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -84,7 +84,7 @@ struct dummy_packet_conn { union { struct dummy_packet_pconn pconn; struct dummy_packet_rconn rconn; - } u; + }; }; struct pkt_list_node { @@ -307,11 +307,11 @@ dummy_packet_conn_get_config(struct dummy_packet_conn *conn, struct smap *args) switch (conn->type) { case PASSIVE: - smap_add(args, "pstream", pstream_get_name(conn->u.pconn.pstream)); + smap_add(args, "pstream", pstream_get_name(conn->pconn.pstream)); break; case ACTIVE: - smap_add(args, "stream", stream_get_name(conn->u.rconn.rstream->stream)); + smap_add(args, "stream", stream_get_name(conn->rconn.rstream->stream)); break; case NONE: @@ -324,8 +324,8 @@ static void dummy_packet_conn_close(struct dummy_packet_conn *conn) { int i; - struct dummy_packet_pconn *pconn = &conn->u.pconn; - struct dummy_packet_rconn *rconn = &conn->u.rconn; + struct dummy_packet_pconn *pconn = &conn->pconn; + struct dummy_packet_rconn *rconn = &conn->rconn; switch (conn->type) { case PASSIVE: @@ -372,14 +372,14 @@ dummy_packet_conn_set_config(struct dummy_packet_conn *conn, switch (conn->type) { case PASSIVE: if (pstream && - !strcmp(pstream_get_name(conn->u.pconn.pstream), pstream)) { + !strcmp(pstream_get_name(conn->pconn.pstream), pstream)) { return; } dummy_packet_conn_close(conn); break; case ACTIVE: if (stream && - !strcmp(stream_get_name(conn->u.rconn.rstream->stream), stream)) { + !strcmp(stream_get_name(conn->rconn.rstream->stream), stream)) { return; } dummy_packet_conn_close(conn); @@ -392,7 +392,7 @@ dummy_packet_conn_set_config(struct dummy_packet_conn *conn, if (pstream) { int error; - error = pstream_open(pstream, &conn->u.pconn.pstream, DSCP_DEFAULT); + error = pstream_open(pstream, &conn->pconn.pstream, DSCP_DEFAULT); if (error) { VLOG_WARN("%s: open failed (%s)", pstream, ovs_strerror(error)); } else { @@ -411,11 +411,11 @@ dummy_packet_conn_set_config(struct dummy_packet_conn *conn, reconnect_enable(reconnect, time_msec()); reconnect_set_backoff(reconnect, 100, INT_MAX); reconnect_set_probe_interval(reconnect, 0); - conn->u.rconn.reconnect = reconnect; + conn->rconn.reconnect = reconnect; conn->type = ACTIVE; error = stream_open(stream, &active_stream, DSCP_DEFAULT); - conn->u.rconn.rstream = dummy_packet_stream_create(active_stream); + conn->rconn.rstream = dummy_packet_stream_create(active_stream); switch (error) { case 0: @@ -429,7 +429,7 @@ dummy_packet_conn_set_config(struct dummy_packet_conn *conn, default: reconnect_connect_failed(reconnect, time_msec(), error); stream_close(active_stream); - conn->u.rconn.rstream->stream = NULL; + conn->rconn.rstream->stream = NULL; break; } } @@ -440,7 +440,7 @@ dummy_pconn_run(struct netdev_dummy *dev) OVS_REQUIRES(dev->mutex) { struct stream *new_stream; - struct dummy_packet_pconn *pconn = &dev->conn.u.pconn; + struct dummy_packet_pconn *pconn = &dev->conn.pconn; int error; size_t i; @@ -483,7 +483,7 @@ static void dummy_rconn_run(struct netdev_dummy *dev) OVS_REQUIRES(dev->mutex) { - struct dummy_packet_rconn *rconn = &dev->conn.u.rconn; + struct dummy_packet_rconn *rconn = &dev->conn.rconn; switch (reconnect_run(rconn->reconnect, time_msec())) { case RECONNECT_CONNECT: @@ -559,15 +559,15 @@ dummy_packet_conn_wait(struct dummy_packet_conn *conn) int i; switch (conn->type) { case PASSIVE: - pstream_wait(conn->u.pconn.pstream); - for (i = 0; i < conn->u.pconn.n_streams; i++) { - struct dummy_packet_stream *s = conn->u.pconn.streams[i]; + pstream_wait(conn->pconn.pstream); + for (i = 0; i < conn->pconn.n_streams; i++) { + struct dummy_packet_stream *s = conn->pconn.streams[i]; dummy_packet_stream_wait(s); } break; case ACTIVE: - if (reconnect_is_connected(conn->u.rconn.reconnect)) { - dummy_packet_stream_wait(conn->u.rconn.rstream); + if (reconnect_is_connected(conn->rconn.reconnect)) { + dummy_packet_stream_wait(conn->rconn.rstream); } break; @@ -585,18 +585,18 @@ dummy_packet_conn_send(struct dummy_packet_conn *conn, switch (conn->type) { case PASSIVE: - for (i = 0; i < conn->u.pconn.n_streams; i++) { - struct dummy_packet_stream *s = conn->u.pconn.streams[i]; + for (i = 0; i < conn->pconn.n_streams; i++) { + struct dummy_packet_stream *s = conn->pconn.streams[i]; dummy_packet_stream_send(s, buffer, size); - pstream_wait(conn->u.pconn.pstream); + pstream_wait(conn->pconn.pstream); } break; case ACTIVE: - if (reconnect_is_connected(conn->u.rconn.reconnect)) { - dummy_packet_stream_send(conn->u.rconn.rstream, buffer, size); - dummy_packet_stream_wait(conn->u.rconn.rstream); + if (reconnect_is_connected(conn->rconn.reconnect)) { + dummy_packet_stream_send(conn->rconn.rstream, buffer, size); + dummy_packet_stream_wait(conn->rconn.rstream); } break; @@ -612,7 +612,7 @@ dummy_netdev_get_conn_state(struct dummy_packet_conn *conn) enum dummy_netdev_conn_state state; if (conn->type == ACTIVE) { - if (reconnect_is_connected(conn->u.rconn.reconnect)) { + if (reconnect_is_connected(conn->rconn.reconnect)) { state = CONN_STATE_CONNECTED; } else { state = CONN_STATE_NOT_CONNECTED; diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index da071156d..1e523f29c 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -262,16 +262,16 @@ unwrap_json(const struct json *json, const char *name, enum json_type value_type, const struct json **value) { if (json->type != JSON_ARRAY - || json->u.array.n != 2 - || json->u.array.elems[0]->type != JSON_STRING - || (name && strcmp(json->u.array.elems[0]->u.string, name)) - || json->u.array.elems[1]->type != value_type) + || json->array.n != 2 + || json->array.elems[0]->type != JSON_STRING + || (name && strcmp(json->array.elems[0]->string, name)) + || json->array.elems[1]->type != value_type) { *value = NULL; return ovsdb_syntax_error(json, NULL, "expected [\"%s\", <%s>]", name, json_type_to_string(value_type)); } - *value = json->u.array.elems[1]; + *value = json->array.elems[1]; return NULL; } @@ -279,11 +279,11 @@ static struct ovsdb_error * parse_json_pair(const struct json *json, const struct json **elem0, const struct json **elem1) { - if (json->type != JSON_ARRAY || json->u.array.n != 2) { + if (json->type != JSON_ARRAY || json->array.n != 2) { return ovsdb_syntax_error(json, NULL, "expected 2-element array"); } - *elem0 = json->u.array.elems[0]; - *elem1 = json->u.array.elems[1]; + *elem0 = json->array.elems[0]; + *elem1 = json->array.elems[1]; return NULL; } @@ -293,8 +293,8 @@ ovsdb_symbol_referenced(struct ovsdb_symbol *symbol, { ovs_assert(base->type == OVSDB_TYPE_UUID); - if (base->u.uuid.refTableName) { - switch (base->u.uuid.refType) { + if (base->uuid.refTableName) { + switch (base->uuid.refType) { case OVSDB_REF_STRONG: symbol->strong_ref = true; break; @@ -377,17 +377,17 @@ ovsdb_atom_from_json__(union ovsdb_atom *atom, case OVSDB_TYPE_INTEGER: if (json->type == JSON_INTEGER) { - atom->integer = json->u.integer; + atom->integer = json->integer; return NULL; } break; case OVSDB_TYPE_REAL: if (json->type == JSON_INTEGER) { - atom->real = json->u.integer; + atom->real = json->integer; return NULL; } else if (json->type == JSON_REAL) { - atom->real = json->u.real; + atom->real = json->real; return NULL; } break; @@ -404,7 +404,7 @@ ovsdb_atom_from_json__(union ovsdb_atom *atom, case OVSDB_TYPE_STRING: if (json->type == JSON_STRING) { - atom->string = xstrdup(json->u.string); + atom->string = xstrdup(json->string); return NULL; } break; @@ -720,7 +720,7 @@ ovsdb_atom_to_string(const union ovsdb_atom *atom, enum ovsdb_atomic_type type, struct json json; json.type = JSON_STRING; - json.u.string = atom->string; + json.string = atom->string; json_to_ds(&json, 0, out); } else { ds_put_cstr(out, atom->string); @@ -817,54 +817,54 @@ ovsdb_atom_check_constraints(const union ovsdb_atom *atom, OVS_NOT_REACHED(); case OVSDB_TYPE_INTEGER: - if (atom->integer >= base->u.integer.min - && atom->integer <= base->u.integer.max) { + if (atom->integer >= base->integer.min + && atom->integer <= base->integer.max) { return NULL; - } else if (base->u.integer.min != INT64_MIN) { - if (base->u.integer.max != INT64_MAX) { + } else if (base->integer.min != INT64_MIN) { + if (base->integer.max != INT64_MAX) { return ovsdb_error("constraint violation", "%"PRId64" is not in the valid range " "%"PRId64" to %"PRId64" (inclusive)", atom->integer, - base->u.integer.min, base->u.integer.max); + base->integer.min, base->integer.max); } else { return ovsdb_error("constraint violation", "%"PRId64" is less than minimum allowed " "value %"PRId64, - atom->integer, base->u.integer.min); + atom->integer, base->integer.min); } } else { return ovsdb_error("constraint violation", "%"PRId64" is greater than maximum allowed " "value %"PRId64, - atom->integer, base->u.integer.max); + atom->integer, base->integer.max); } OVS_NOT_REACHED(); case OVSDB_TYPE_REAL: - if (atom->real >= base->u.real.min && atom->real <= base->u.real.max) { + if (atom->real >= base->real.min && atom->real <= base->real.max) { return NULL; - } else if (base->u.real.min != -DBL_MAX) { - if (base->u.real.max != DBL_MAX) { + } else if (base->real.min != -DBL_MAX) { + if (base->real.max != DBL_MAX) { return ovsdb_error("constraint violation", "%.*g is not in the valid range " "%.*g to %.*g (inclusive)", DBL_DIG, atom->real, - DBL_DIG, base->u.real.min, - DBL_DIG, base->u.real.max); + DBL_DIG, base->real.min, + DBL_DIG, base->real.max); } else { return ovsdb_error("constraint violation", "%.*g is less than minimum allowed " "value %.*g", DBL_DIG, atom->real, - DBL_DIG, base->u.real.min); + DBL_DIG, base->real.min); } } else { return ovsdb_error("constraint violation", "%.*g is greater than maximum allowed " "value %.*g", DBL_DIG, atom->real, - DBL_DIG, base->u.real.max); + DBL_DIG, base->real.max); } OVS_NOT_REACHED(); @@ -872,7 +872,7 @@ ovsdb_atom_check_constraints(const union ovsdb_atom *atom, return NULL; case OVSDB_TYPE_STRING: - return check_string_constraints(atom->string, &base->u.string); + return check_string_constraints(atom->string, &base->string); case OVSDB_TYPE_UUID: return NULL; @@ -1218,9 +1218,9 @@ ovsdb_datum_from_json__(struct ovsdb_datum *datum, if (ovsdb_type_is_map(type) || (json->type == JSON_ARRAY - && json->u.array.n > 0 - && json->u.array.elems[0]->type == JSON_STRING - && !strcmp(json->u.array.elems[0]->u.string, "set"))) { + && json->array.n > 0 + && json->array.elems[0]->type == JSON_STRING + && !strcmp(json->array.elems[0]->string, "set"))) { bool is_map = ovsdb_type_is_map(type); const char *class = is_map ? "map" : "set"; const struct json *inner; @@ -1232,7 +1232,7 @@ ovsdb_datum_from_json__(struct ovsdb_datum *datum, return error; } - n = inner->u.array.n; + n = inner->array.n; if (n < type->n_min || n > type->n_max) { return ovsdb_syntax_error(json, NULL, "%s must have %u to " "%u members but %"PRIuSIZE" are present", @@ -1243,7 +1243,7 @@ ovsdb_datum_from_json__(struct ovsdb_datum *datum, datum->keys = xmalloc(n * sizeof *datum->keys); datum->values = is_map ? xmalloc(n * sizeof *datum->values) : NULL; for (i = 0; i < n; i++) { - const struct json *element = inner->u.array.elems[i]; + const struct json *element = inner->array.elems[i]; const struct json *key = NULL; const struct json *value = NULL; @@ -1365,7 +1365,7 @@ ovsdb_base_to_json(const union ovsdb_atom *atom, { if (!use_row_names || base->type != OVSDB_TYPE_UUID - || !base->u.uuid.refTableName) { + || !base->uuid.refTableName) { return ovsdb_atom_to_json(atom, base->type); } else { return json_array_create_2( diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 9b99375da..c6ff78e25 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -995,7 +995,7 @@ add_row_references(const struct ovsdb_base_type *type, struct uuid **dstsp, size_t *n_dstsp, size_t *allocated_dstsp) { - if (type->type != OVSDB_TYPE_UUID || !type->u.uuid.refTableName) { + if (type->type != OVSDB_TYPE_UUID || !type->uuid.refTableName) { return; } @@ -1123,15 +1123,15 @@ ovsdb_idl_db_get_mode(struct ovsdb_idl_db *db, static void add_ref_table(struct ovsdb_idl_db *db, const struct ovsdb_base_type *base) { - if (base->type == OVSDB_TYPE_UUID && base->u.uuid.refTableName) { + if (base->type == OVSDB_TYPE_UUID && base->uuid.refTableName) { struct ovsdb_idl_table *table; - table = shash_find_data(&db->table_by_name, base->u.uuid.refTableName); + table = shash_find_data(&db->table_by_name, base->uuid.refTableName); if (table) { table->need_table = true; } else { VLOG_WARN("%s IDL class missing referenced table %s", - db->class_->database, base->u.uuid.refTableName); + db->class_->database, base->uuid.refTableName); } } } @@ -1993,9 +1993,9 @@ ovsdb_idl_db_parse_update_rpc(struct ovsdb_idl_db *db, bool is_update2 = !strcmp(msg->method, "update2"); if ((is_update || is_update2) && msg->params->type == JSON_ARRAY - && msg->params->u.array.n == 2 - && json_equal(msg->params->u.array.elems[0], db->monitor_id)) { - ovsdb_idl_db_parse_update(db, msg->params->u.array.elems[1], + && msg->params->array.n == 2 + && json_equal(msg->params->array.elems[0], db->monitor_id)) { + ovsdb_idl_db_parse_update(db, msg->params->array.elems[1], is_update2); return true; } @@ -2011,8 +2011,8 @@ ovsdb_idl_handle_monitor_canceled(struct ovsdb_idl *idl, if (msg->type != JSONRPC_NOTIFY || strcmp(msg->method, "monitor_canceled") || msg->params->type != JSON_ARRAY - || msg->params->u.array.n != 1 - || !json_equal(msg->params->u.array.elems[0], db->monitor_id)) { + || msg->params->array.n != 1 + || !json_equal(msg->params->array.elems[0], db->monitor_id)) { return false; } @@ -3549,11 +3549,11 @@ substitute_uuids(struct json *json, const struct ovsdb_idl_txn *txn) struct uuid uuid; size_t i; - if (json->u.array.n == 2 - && json->u.array.elems[0]->type == JSON_STRING - && json->u.array.elems[1]->type == JSON_STRING - && !strcmp(json->u.array.elems[0]->u.string, "uuid") - && uuid_from_string(&uuid, json->u.array.elems[1]->u.string)) { + if (json->array.n == 2 + && json->array.elems[0]->type == JSON_STRING + && json->array.elems[1]->type == JSON_STRING + && !strcmp(json->array.elems[0]->string, "uuid") + && uuid_from_string(&uuid, json->array.elems[1]->string)) { const struct ovsdb_idl_row *row; row = ovsdb_idl_txn_get_row(txn, &uuid); @@ -3566,8 +3566,8 @@ substitute_uuids(struct json *json, const struct ovsdb_idl_txn *txn) } } - for (i = 0; i < json->u.array.n; i++) { - json->u.array.elems[i] = substitute_uuids(json->u.array.elems[i], + for (i = 0; i < json->array.n; i++) { + json->array.elems[i] = substitute_uuids(json->array.elems[i], txn); } } else if (json->type == JSON_OBJECT) { @@ -3981,7 +3981,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) insert = xmalloc(sizeof *insert); insert->dummy = row->uuid; - insert->op_index = operations->u.array.n - 1; + insert->op_index = operations->array.n - 1; uuid_zero(&insert->real); hmap_insert(&txn->inserted_rows, &insert->hmap_node, uuid_hash(&insert->dummy)); @@ -4051,7 +4051,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn) /* Add increment. */ if (txn->inc_table && (any_updates || txn->inc_force)) { any_updates = true; - txn->inc_index = operations->u.array.n - 1; + txn->inc_index = operations->array.n - 1; struct json *op = json_object_create(); json_object_put_string(op, "op", "mutate"); @@ -4544,10 +4544,10 @@ ovsdb_idl_txn_process_inc_reply(struct ovsdb_idl_txn *txn, if (!check_json_type(count, JSON_INTEGER, "\"mutate\" reply \"count\"")) { return false; } - if (count->u.integer != 1) { + if (count->integer != 1) { VLOG_WARN_RL(&syntax_rl, "\"mutate\" reply \"count\" is %lld instead of 1", - count->u.integer); + count->integer); return false; } @@ -4556,13 +4556,13 @@ ovsdb_idl_txn_process_inc_reply(struct ovsdb_idl_txn *txn, if (!check_json_type(rows, JSON_ARRAY, "\"select\" reply \"rows\"")) { return false; } - if (rows->u.array.n != 1) { + if (rows->array.n != 1) { VLOG_WARN_RL(&syntax_rl, "\"select\" reply \"rows\" has %"PRIuSIZE" elements " "instead of 1", - rows->u.array.n); + rows->array.n); return false; } - row = rows->u.array.elems[0]; + row = rows->array.elems[0]; if (!check_json_type(row, JSON_OBJECT, "\"select\" reply row")) { return false; } @@ -4571,7 +4571,7 @@ ovsdb_idl_txn_process_inc_reply(struct ovsdb_idl_txn *txn, "\"select\" reply inc column")) { return false; } - txn->inc_new_value = column->u.integer; + txn->inc_new_value = column->integer; return true; } @@ -4643,7 +4643,7 @@ ovsdb_idl_db_txn_process_reply(struct ovsdb_idl_db *db, status = TXN_ERROR; ovsdb_idl_txn_set_error_json(txn, msg->result); } else { - struct json_array *ops = &msg->result->u.array; + struct json_array *ops = &msg->result->array; int hard_errors = 0; int soft_errors = 0; int lock_errors = 0; @@ -4662,14 +4662,14 @@ ovsdb_idl_db_txn_process_reply(struct ovsdb_idl_db *db, error = shash_find_data(json_object(op), "error"); if (error) { if (error->type == JSON_STRING) { - if (!strcmp(error->u.string, "timed out")) { + if (!strcmp(error->string, "timed out")) { soft_errors++; - } else if (!strcmp(error->u.string, "not owner")) { + } else if (!strcmp(error->string, "not owner")) { lock_errors++; - } else if (!strcmp(error->u.string, "not allowed")) { + } else if (!strcmp(error->string, "not allowed")) { hard_errors++; ovsdb_idl_txn_set_error_json(txn, op); - } else if (strcmp(error->u.string, "aborted")) { + } else if (strcmp(error->string, "aborted")) { hard_errors++; ovsdb_idl_txn_set_error_json(txn, op); VLOG_WARN_RL(&other_rl, diff --git a/lib/ovsdb-parser.c b/lib/ovsdb-parser.c index 42937b649..38119c195 100644 --- a/lib/ovsdb-parser.c +++ b/lib/ovsdb-parser.c @@ -83,7 +83,7 @@ ovsdb_parser_member(struct ovsdb_parser *parser, const char *name, if (((int) value->type >= 0 && value->type < JSON_N_TYPES && types & (1u << value->type)) || (types & OP_ID && value->type == JSON_STRING - && ovsdb_parser_is_id(value->u.string))) + && ovsdb_parser_is_id(value->string))) { sset_add(&parser->used, name); return value; diff --git a/lib/ovsdb-types.c b/lib/ovsdb-types.c index 50a32a722..24ccdd1cc 100644 --- a/lib/ovsdb-types.c +++ b/lib/ovsdb-types.c @@ -125,26 +125,26 @@ ovsdb_base_type_init(struct ovsdb_base_type *base, enum ovsdb_atomic_type type) break; case OVSDB_TYPE_INTEGER: - base->u.integer.min = INT64_MIN; - base->u.integer.max = INT64_MAX; + base->integer.min = INT64_MIN; + base->integer.max = INT64_MAX; break; case OVSDB_TYPE_REAL: - base->u.real.min = -DBL_MAX; - base->u.real.max = DBL_MAX; + base->real.min = -DBL_MAX; + base->real.max = DBL_MAX; break; case OVSDB_TYPE_BOOLEAN: break; case OVSDB_TYPE_STRING: - base->u.string.minLen = 0; - base->u.string.maxLen = UINT_MAX; + base->string.minLen = 0; + base->string.maxLen = UINT_MAX; break; case OVSDB_TYPE_UUID: - base->u.uuid.refTableName = NULL; - base->u.uuid.refTable = NULL; + base->uuid.refTableName = NULL; + base->uuid.refTable = NULL; break; case OVSDB_N_TYPES: @@ -204,8 +204,8 @@ ovsdb_base_type_clone(struct ovsdb_base_type *dst, break; case OVSDB_TYPE_UUID: - if (dst->u.uuid.refTableName) { - dst->u.uuid.refTableName = xstrdup(dst->u.uuid.refTableName); + if (dst->uuid.refTableName) { + dst->uuid.refTableName = xstrdup(dst->uuid.refTableName); } break; @@ -236,7 +236,7 @@ ovsdb_base_type_destroy(struct ovsdb_base_type *base) break; case OVSDB_TYPE_UUID: - free(base->u.uuid.refTableName); + free(base->uuid.refTableName); break; case OVSDB_N_TYPES: @@ -256,16 +256,16 @@ ovsdb_base_type_is_valid(const struct ovsdb_base_type *base) return true; case OVSDB_TYPE_INTEGER: - return base->u.integer.min <= base->u.integer.max; + return base->integer.min <= base->integer.max; case OVSDB_TYPE_REAL: - return base->u.real.min <= base->u.real.max; + return base->real.min <= base->real.max; case OVSDB_TYPE_BOOLEAN: return true; case OVSDB_TYPE_STRING: - return base->u.string.minLen <= base->u.string.maxLen; + return base->string.minLen <= base->string.maxLen; case OVSDB_TYPE_UUID: return true; @@ -288,21 +288,21 @@ ovsdb_base_type_has_constraints(const struct ovsdb_base_type *base) OVS_NOT_REACHED(); case OVSDB_TYPE_INTEGER: - return (base->u.integer.min != INT64_MIN - || base->u.integer.max != INT64_MAX); + return (base->integer.min != INT64_MIN + || base->integer.max != INT64_MAX); case OVSDB_TYPE_REAL: - return (base->u.real.min != -DBL_MAX - || base->u.real.max != DBL_MAX); + return (base->real.min != -DBL_MAX + || base->real.max != DBL_MAX); case OVSDB_TYPE_BOOLEAN: return false; case OVSDB_TYPE_STRING: - return base->u.string.minLen != 0 || base->u.string.maxLen != UINT_MAX; + return base->string.minLen != 0 || base->string.maxLen != UINT_MAX; case OVSDB_TYPE_UUID: - return base->u.uuid.refTableName != NULL; + return base->uuid.refTableName != NULL; case OVSDB_N_TYPES: OVS_NOT_REACHED(); @@ -328,12 +328,12 @@ parse_optional_uint(struct ovsdb_parser *parser, const char *member, json = ovsdb_parser_member(parser, member, OP_INTEGER | OP_OPTIONAL); if (json) { - if (json->u.integer < 0 || json->u.integer > UINT_MAX) { + if (json->integer < 0 || json->integer > UINT_MAX) { return ovsdb_syntax_error(json, NULL, "%s out of valid range 0 to %u", member, UINT_MAX); } - *uint = json->u.integer; + *uint = json->integer; } return NULL; } @@ -387,9 +387,9 @@ ovsdb_base_type_from_json(struct ovsdb_base_type *base, OP_INTEGER | OP_OPTIONAL); max = ovsdb_parser_member(&parser, "maxInteger", OP_INTEGER | OP_OPTIONAL); - base->u.integer.min = min ? min->u.integer : INT64_MIN; - base->u.integer.max = max ? max->u.integer : INT64_MAX; - if (base->u.integer.min > base->u.integer.max) { + base->integer.min = min ? min->integer : INT64_MIN; + base->integer.max = max ? max->integer : INT64_MAX; + if (base->integer.min > base->integer.max) { error = ovsdb_syntax_error(json, NULL, "minInteger exceeds maxInteger"); } @@ -398,21 +398,21 @@ ovsdb_base_type_from_json(struct ovsdb_base_type *base, min = ovsdb_parser_member(&parser, "minReal", OP_NUMBER | OP_OPTIONAL); max = ovsdb_parser_member(&parser, "maxReal", OP_NUMBER | OP_OPTIONAL); - base->u.real.min = min ? json_real(min) : -DBL_MAX; - base->u.real.max = max ? json_real(max) : DBL_MAX; - if (base->u.real.min > base->u.real.max) { + base->real.min = min ? json_real(min) : -DBL_MAX; + base->real.max = max ? json_real(max) : DBL_MAX; + if (base->real.min > base->real.max) { error = ovsdb_syntax_error(json, NULL, "minReal exceeds maxReal"); } } else if (base->type == OVSDB_TYPE_STRING) { if (!error) { error = parse_optional_uint(&parser, "minLength", - &base->u.string.minLen); + &base->string.minLen); } if (!error) { error = parse_optional_uint(&parser, "maxLength", - &base->u.string.maxLen); + &base->string.maxLen); } - if (!error && base->u.string.minLen > base->u.string.maxLen) { + if (!error && base->string.minLen > base->string.maxLen) { error = ovsdb_syntax_error(json, NULL, "minLength exceeds maxLength"); } @@ -424,9 +424,9 @@ ovsdb_base_type_from_json(struct ovsdb_base_type *base, if (refTable) { const struct json *refType; - base->u.uuid.refTableName = xstrdup(refTable->u.string); + base->uuid.refTableName = xstrdup(refTable->string); - /* We can't set base->u.uuid.refTable here because we don't have + /* We can't set base->uuid.refTable here because we don't have * enough context (we might not even be running in ovsdb-server). * ovsdb_create() will set refTable later. */ @@ -435,16 +435,16 @@ ovsdb_base_type_from_json(struct ovsdb_base_type *base, if (refType) { const char *refType_s = json_string(refType); if (!strcmp(refType_s, "strong")) { - base->u.uuid.refType = OVSDB_REF_STRONG; + base->uuid.refType = OVSDB_REF_STRONG; } else if (!strcmp(refType_s, "weak")) { - base->u.uuid.refType = OVSDB_REF_WEAK; + base->uuid.refType = OVSDB_REF_WEAK; } else { error = ovsdb_syntax_error(json, NULL, "refType must be " "\"strong\" or \"weak\" (not " "\"%s\")", refType_s); } } else { - base->u.uuid.refType = OVSDB_REF_STRONG; + base->uuid.refType = OVSDB_REF_STRONG; } } } @@ -486,24 +486,24 @@ ovsdb_base_type_to_json(const struct ovsdb_base_type *base) OVS_NOT_REACHED(); case OVSDB_TYPE_INTEGER: - if (base->u.integer.min != INT64_MIN) { + if (base->integer.min != INT64_MIN) { json_object_put(json, "minInteger", - json_integer_create(base->u.integer.min)); + json_integer_create(base->integer.min)); } - if (base->u.integer.max != INT64_MAX) { + if (base->integer.max != INT64_MAX) { json_object_put(json, "maxInteger", - json_integer_create(base->u.integer.max)); + json_integer_create(base->integer.max)); } break; case OVSDB_TYPE_REAL: - if (base->u.real.min != -DBL_MAX) { + if (base->real.min != -DBL_MAX) { json_object_put(json, "minReal", - json_real_create(base->u.real.min)); + json_real_create(base->real.min)); } - if (base->u.real.max != DBL_MAX) { + if (base->real.max != DBL_MAX) { json_object_put(json, "maxReal", - json_real_create(base->u.real.max)); + json_real_create(base->real.max)); } break; @@ -511,21 +511,21 @@ ovsdb_base_type_to_json(const struct ovsdb_base_type *base) break; case OVSDB_TYPE_STRING: - if (base->u.string.minLen != 0) { + if (base->string.minLen != 0) { json_object_put(json, "minLength", - json_integer_create(base->u.string.minLen)); + json_integer_create(base->string.minLen)); } - if (base->u.string.maxLen != UINT_MAX) { + if (base->string.maxLen != UINT_MAX) { json_object_put(json, "maxLength", - json_integer_create(base->u.string.maxLen)); + json_integer_create(base->string.maxLen)); } break; case OVSDB_TYPE_UUID: - if (base->u.uuid.refTableName) { + if (base->uuid.refTableName) { json_object_put_string(json, "refTable", - base->u.uuid.refTableName); - if (base->u.uuid.refType == OVSDB_REF_WEAK) { + base->uuid.refTableName); + if (base->uuid.refType == OVSDB_REF_WEAK) { json_object_put_string(json, "refType", "weak"); } } @@ -575,8 +575,8 @@ n_from_json(const struct json *json, unsigned int *n) if (!json) { return NULL; } else if (json->type == JSON_INTEGER - && json->u.integer >= 0 && json->u.integer < UINT_MAX) { - *n = json->u.integer; + && json->integer >= 0 && json->integer < UINT_MAX) { + *n = json->integer; return NULL; } else { return ovsdb_syntax_error(json, NULL, "bad min or max value"); @@ -657,7 +657,7 @@ ovsdb_type_from_json(struct ovsdb_type *type, const struct json *json) } if (max && max->type == JSON_STRING - && !strcmp(max->u.string, "unlimited")) { + && !strcmp(max->string, "unlimited")) { type->n_max = UINT_MAX; } else { error = n_from_json(max, &type->n_max); diff --git a/lib/ovsdb-types.h b/lib/ovsdb-types.h index 222d0ec15..368c41617 100644 --- a/lib/ovsdb-types.h +++ b/lib/ovsdb-types.h @@ -83,19 +83,19 @@ struct ovsdb_base_type { struct ovsdb_table *refTable; /* Referenced table, if available. */ enum ovsdb_ref_type refType; /* Reference type. */ } uuid; - } u; + }; }; #define OVSDB_BASE_VOID_INIT { .type = OVSDB_TYPE_VOID } #define OVSDB_BASE_INTEGER_INIT { .type = OVSDB_TYPE_INTEGER, \ - .u.integer = { INT64_MIN, INT64_MAX } } + .integer = { INT64_MIN, INT64_MAX } } #define OVSDB_BASE_REAL_INIT { .type = OVSDB_TYPE_REAL, \ - .u.real = { -DBL_MAX, DBL_MAX } } + .real = { -DBL_MAX, DBL_MAX } } #define OVSDB_BASE_BOOLEAN_INIT { .type = OVSDB_TYPE_BOOLEAN } #define OVSDB_BASE_STRING_INIT { .type = OVSDB_TYPE_STRING, \ - .u.string = { 0, UINT_MAX } } + .string = { 0, UINT_MAX } } #define OVSDB_BASE_UUID_INIT { .type = OVSDB_TYPE_UUID, \ - .u.uuid = { NULL, NULL, 0 } } + .uuid = { NULL, NULL, 0 } } void ovsdb_base_type_init(struct ovsdb_base_type *, enum ovsdb_atomic_type); void ovsdb_base_type_clone(struct ovsdb_base_type *, @@ -180,21 +180,21 @@ ovsdb_atomic_type_is_valid(enum ovsdb_atomic_type atomic_type) static inline bool ovsdb_base_type_is_ref(const struct ovsdb_base_type *base) { - return base->type == OVSDB_TYPE_UUID && base->u.uuid.refTableName; + return base->type == OVSDB_TYPE_UUID && base->uuid.refTableName; } static inline bool ovsdb_base_type_is_strong_ref(const struct ovsdb_base_type *base) { return (ovsdb_base_type_is_ref(base) - && base->u.uuid.refType == OVSDB_REF_STRONG); + && base->uuid.refType == OVSDB_REF_STRONG); } static inline bool ovsdb_base_type_is_weak_ref(const struct ovsdb_base_type *base) { return (ovsdb_base_type_is_ref(base) - && base->u.uuid.refType == OVSDB_REF_WEAK); + && base->uuid.refType == OVSDB_REF_WEAK); } static inline bool ovsdb_type_is_scalar(const struct ovsdb_type *type) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index d26f201f4..d80a10d31 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1553,15 +1553,15 @@ handle_upcalls(struct udpif *udpif, struct upcall *upcalls, op = &ops[n_ops++]; op->ukey = NULL; op->dop.type = DPIF_OP_EXECUTE; - op->dop.u.execute.packet = CONST_CAST(struct dp_packet *, packet); - op->dop.u.execute.flow = upcall->flow; + op->dop.execute.packet = CONST_CAST(struct dp_packet *, packet); + op->dop.execute.flow = upcall->flow; odp_key_to_dp_packet(upcall->key, upcall->key_len, - op->dop.u.execute.packet); - op->dop.u.execute.actions = upcall->odp_actions.data; - op->dop.u.execute.actions_len = upcall->odp_actions.size; - op->dop.u.execute.needs_help = (upcall->xout.slow & SLOW_ACTION) != 0; - op->dop.u.execute.probe = false; - op->dop.u.execute.mtu = upcall->mru; + op->dop.execute.packet); + op->dop.execute.actions = upcall->odp_actions.data; + op->dop.execute.actions_len = upcall->odp_actions.size; + op->dop.execute.needs_help = (upcall->xout.slow & SLOW_ACTION) != 0; + op->dop.execute.probe = false; + op->dop.execute.mtu = upcall->mru; } } @@ -2265,12 +2265,12 @@ delete_op_init__(struct udpif *udpif, struct ukey_op *op, { op->ukey = NULL; op->dop.type = DPIF_OP_FLOW_DEL; - op->dop.u.flow_del.key = flow->key; - op->dop.u.flow_del.key_len = flow->key_len; - op->dop.u.flow_del.ufid = flow->ufid_present ? &flow->ufid : NULL; - op->dop.u.flow_del.pmd_id = flow->pmd_id; - op->dop.u.flow_del.stats = &op->stats; - op->dop.u.flow_del.terse = udpif_use_ufid(udpif); + op->dop.flow_del.key = flow->key; + op->dop.flow_del.key_len = flow->key_len; + op->dop.flow_del.ufid = flow->ufid_present ? &flow->ufid : NULL; + op->dop.flow_del.pmd_id = flow->pmd_id; + op->dop.flow_del.stats = &op->stats; + op->dop.flow_del.terse = udpif_use_ufid(udpif); } static void @@ -2278,12 +2278,12 @@ delete_op_init(struct udpif *udpif, struct ukey_op *op, struct udpif_key *ukey) { op->ukey = ukey; op->dop.type = DPIF_OP_FLOW_DEL; - op->dop.u.flow_del.key = ukey->key; - op->dop.u.flow_del.key_len = ukey->key_len; - op->dop.u.flow_del.ufid = ukey->ufid_present ? &ukey->ufid : NULL; - op->dop.u.flow_del.pmd_id = ukey->pmd_id; - op->dop.u.flow_del.stats = &op->stats; - op->dop.u.flow_del.terse = udpif_use_ufid(udpif); + op->dop.flow_del.key = ukey->key; + op->dop.flow_del.key_len = ukey->key_len; + op->dop.flow_del.ufid = ukey->ufid_present ? &ukey->ufid : NULL; + op->dop.flow_del.pmd_id = ukey->pmd_id; + op->dop.flow_del.stats = &op->stats; + op->dop.flow_del.terse = udpif_use_ufid(udpif); } static void @@ -2292,16 +2292,16 @@ put_op_init(struct ukey_op *op, struct udpif_key *ukey, { op->ukey = ukey; op->dop.type = DPIF_OP_FLOW_PUT; - op->dop.u.flow_put.flags = flags; - op->dop.u.flow_put.key = ukey->key; - op->dop.u.flow_put.key_len = ukey->key_len; - op->dop.u.flow_put.mask = ukey->mask; - op->dop.u.flow_put.mask_len = ukey->mask_len; - op->dop.u.flow_put.ufid = ukey->ufid_present ? &ukey->ufid : NULL; - op->dop.u.flow_put.pmd_id = ukey->pmd_id; - op->dop.u.flow_put.stats = NULL; - ukey_get_actions(ukey, &op->dop.u.flow_put.actions, - &op->dop.u.flow_put.actions_len); + op->dop.flow_put.flags = flags; + op->dop.flow_put.key = ukey->key; + op->dop.flow_put.key_len = ukey->key_len; + op->dop.flow_put.mask = ukey->mask; + op->dop.flow_put.mask_len = ukey->mask_len; + op->dop.flow_put.ufid = ukey->ufid_present ? &ukey->ufid : NULL; + op->dop.flow_put.pmd_id = ukey->pmd_id; + op->dop.flow_put.stats = NULL; + ukey_get_actions(ukey, &op->dop.flow_put.actions, + &op->dop.flow_put.actions_len); } /* Executes datapath operations 'ops' and attributes stats retrieved from the @@ -2322,7 +2322,7 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) struct ukey_op *op = &ops[i]; struct dpif_flow_stats *push, *stats, push_buf; - stats = op->dop.u.flow_del.stats; + stats = op->dop.flow_del.stats; push = &push_buf; if (op->dop.type != DPIF_OP_FLOW_DEL) { @@ -2353,8 +2353,8 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) } if (push->n_packets || netflow_exists()) { - const struct nlattr *key = op->dop.u.flow_del.key; - size_t key_len = op->dop.u.flow_del.key_len; + const struct nlattr *key = op->dop.flow_del.key; + size_t key_len = op->dop.flow_del.key_len; struct netflow *netflow; struct reval_context ctx = { .netflow = &netflow, diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index b9d53dfdd..829ccd866 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -152,7 +152,7 @@ struct learned_cookie { /* In 'dead_cookies' list when removed from hmap. */ struct ovs_list list_node; - } u; + }; /* Key. */ ovs_be64 cookie OVS_GUARDED_BY(ofproto_mutex); @@ -3099,14 +3099,14 @@ learned_cookies_update_one__(struct ofproto *ofproto, uint32_t hash = hash_learned_cookie(learn->cookie, learn->table_id); struct learned_cookie *c; - HMAP_FOR_EACH_WITH_HASH (c, u.hmap_node, hash, &ofproto->learned_cookies) { + HMAP_FOR_EACH_WITH_HASH (c, hmap_node, hash, &ofproto->learned_cookies) { if (c->cookie == learn->cookie && c->table_id == learn->table_id) { c->n += delta; ovs_assert(c->n >= 0); if (!c->n) { - hmap_remove(&ofproto->learned_cookies, &c->u.hmap_node); - ovs_list_push_back(dead_cookies, &c->u.list_node); + hmap_remove(&ofproto->learned_cookies, &c->hmap_node); + ovs_list_push_back(dead_cookies, &c->list_node); } return; @@ -3115,7 +3115,7 @@ learned_cookies_update_one__(struct ofproto *ofproto, ovs_assert(delta > 0); c = xmalloc(sizeof *c); - hmap_insert(&ofproto->learned_cookies, &c->u.hmap_node, hash); + hmap_insert(&ofproto->learned_cookies, &c->hmap_node, hash); c->cookie = learn->cookie; c->table_id = learn->table_id; c->n = delta; @@ -3183,7 +3183,7 @@ learned_cookies_flush(struct ofproto *ofproto, struct ovs_list *dead_cookies) struct minimatch match; minimatch_init_catchall(&match); - LIST_FOR_EACH_POP (c, u.list_node, dead_cookies) { + LIST_FOR_EACH_POP (c, list_node, dead_cookies) { struct rule_criteria criteria; struct rule_collection rules; rule_criteria_init(&criteria, c->table_id, &match, 0, OVS_VERSION_MAX, diff --git a/ovsdb/column.c b/ovsdb/column.c index 8838df3eb..9dfc8714f 100644 --- a/ovsdb/column.c +++ b/ovsdb/column.c @@ -165,15 +165,15 @@ ovsdb_column_set_from_json(const struct json *json, } /* XXX this is O(n**2) */ - for (i = 0; i < json->u.array.n; i++) { + for (i = 0; i < json->array.n; i++) { const struct ovsdb_column *column; const char *s; - if (json->u.array.elems[i]->type != JSON_STRING) { + if (json->array.elems[i]->type != JSON_STRING) { goto error; } - s = json->u.array.elems[i]->u.string; + s = json->array.elems[i]->string; column = shash_find_data(&schema->columns, s); if (!column) { error = ovsdb_syntax_error(json, NULL, "%s is not a valid " diff --git a/ovsdb/condition.c b/ovsdb/condition.c index 6da3b08ad..f2213ca11 100644 --- a/ovsdb/condition.c +++ b/ovsdb/condition.c @@ -81,9 +81,9 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts, } if (json->type != JSON_ARRAY - || json->u.array.n != 3 - || json->u.array.elems[0]->type != JSON_STRING - || json->u.array.elems[1]->type != JSON_STRING) { + || json->array.n != 3 + || json->array.elems[0]->type != JSON_STRING + || json->array.elems[1]->type != JSON_STRING) { return ovsdb_syntax_error(json, NULL, "Parse error in condition."); } array = json_array(json); diff --git a/ovsdb/execution.c b/ovsdb/execution.c index 38303c7db..c55a0b771 100644 --- a/ovsdb/execution.c +++ b/ovsdb/execution.c @@ -121,9 +121,9 @@ ovsdb_execute_compose(struct ovsdb *db, const struct ovsdb_session *session, *durable = false; if (params->type != JSON_ARRAY - || !params->u.array.n - || params->u.array.elems[0]->type != JSON_STRING - || strcmp(params->u.array.elems[0]->u.string, db->schema->name)) { + || !params->array.n + || params->array.elems[0]->type != JSON_STRING + || strcmp(params->array.elems[0]->string, db->schema->name)) { if (params->type != JSON_ARRAY) { error = ovsdb_syntax_error(params, NULL, "array expected"); } else { @@ -147,10 +147,10 @@ ovsdb_execute_compose(struct ovsdb *db, const struct ovsdb_session *session, results = NULL; results = json_array_create_empty(); - n_operations = params->u.array.n - 1; + n_operations = params->array.n - 1; error = NULL; for (i = 1; i <= n_operations; i++) { - struct json *operation = params->u.array.elems[i]; + struct json *operation = params->array.elems[i]; struct ovsdb_error *parse_error; struct ovsdb_parser parser; struct json *result; @@ -735,11 +735,11 @@ ovsdb_execute_wait(struct ovsdb_execution *x, struct ovsdb_parser *parser, if (!error) { /* Parse "rows" into 'expected'. */ ovsdb_row_hash_init(&expected, &columns); - for (i = 0; i < rows->u.array.n; i++) { + for (i = 0; i < rows->array.n; i++) { struct ovsdb_row *row; row = ovsdb_row_create(table); - error = ovsdb_row_from_json(row, rows->u.array.elems[i], x->symtab, + error = ovsdb_row_from_json(row, rows->array.elems[i], x->symtab, NULL); if (error) { ovsdb_row_destroy(row); diff --git a/ovsdb/file.c b/ovsdb/file.c index f523f3798..8d16b097b 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -135,7 +135,7 @@ ovsdb_file_txn_table_from_json(struct ovsdb_txn *txn, return ovsdb_syntax_error(json, NULL, "object expected"); } - SHASH_FOR_EACH (node, json->u.object) { + SHASH_FOR_EACH (node, json->object) { const char *uuid_string = node->name; struct json *txn_row_json = node->data; struct ovsdb_error *error; @@ -177,7 +177,7 @@ ovsdb_file_txn_from_json(struct ovsdb *db, const struct json *json, } txn = ovsdb_txn_create(db); - SHASH_FOR_EACH (node, json->u.object) { + SHASH_FOR_EACH (node, json->object) { const char *table_name = node->name; struct json *node_json = node->data; struct ovsdb_table *table; diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index 84ba6ad21..6c58f4102 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -772,7 +772,7 @@ ovsdb_jsonrpc_lookup_db(const struct ovsdb_jsonrpc_session *s, goto error; } - db_name = params->elems[0]->u.string; + db_name = params->elems[0]->string; db = shash_find_data(&s->up.server->dbs, db_name); if (!db) { error = ovsdb_syntax_error( @@ -1054,7 +1054,7 @@ execute_cancel(struct ovsdb_jsonrpc_session *s, struct jsonrpc_msg *request) struct ovsdb_jsonrpc_trigger *t; struct json *id; - id = request->params->u.array.elems[0]; + id = request->params->array.elems[0]; t = ovsdb_jsonrpc_trigger_find(s, id, json_hash(id, 0)); if (t) { ovsdb_jsonrpc_trigger_complete(t); @@ -1303,16 +1303,16 @@ ovsdb_jsonrpc_parse_monitor_request( "array of column names expected"); } - for (i = 0; i < columns->u.array.n; i++) { + for (i = 0; i < columns->array.n; i++) { const struct ovsdb_column *column; const char *s; - if (columns->u.array.elems[i]->type != JSON_STRING) { + if (columns->array.elems[i]->type != JSON_STRING) { return ovsdb_syntax_error(columns, NULL, "array of column names expected"); } - s = columns->u.array.elems[i]->u.string; + s = columns->array.elems[i]->string; column = shash_find_data(&table->schema->columns, s); if (!column) { return ovsdb_syntax_error(columns, NULL, "%s is not a valid " @@ -1367,8 +1367,8 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db, error = ovsdb_syntax_error(params, NULL, "invalid parameters"); goto error; } - monitor_id = params->u.array.elems[1]; - monitor_requests = params->u.array.elems[2]; + monitor_id = params->array.elems[1]; + monitor_requests = params->array.elems[2]; if (monitor_requests->type != JSON_OBJECT) { error = ovsdb_syntax_error(monitor_requests, NULL, "monitor-requests must be object"); @@ -1409,7 +1409,7 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db, /* Parse columns. */ mr_value = node->data; if (mr_value->type == JSON_ARRAY) { - const struct json_array *array = &mr_value->u.array; + const struct json_array *array = &mr_value->array; for (i = 0; i < array->n; i++) { error = ovsdb_jsonrpc_parse_monitor_request(m->dbmon, @@ -1503,14 +1503,14 @@ ovsdb_jsonrpc_monitor_cond_change(struct ovsdb_jsonrpc_session *s, goto error; } - m = ovsdb_jsonrpc_monitor_find(s, params->u.array.elems[0]); + m = ovsdb_jsonrpc_monitor_find(s, params->array.elems[0]); if (!m) { - error = ovsdb_syntax_error(params->u.array.elems[0], NULL, + error = ovsdb_syntax_error(params->array.elems[0], NULL, "unknown monitor session"); goto error; } - const struct json *new_monitor_id = params->u.array.elems[1]; + const struct json *new_monitor_id = params->array.elems[1]; bool changing_id = !json_equal(m->monitor_id, new_monitor_id); if (changing_id && ovsdb_jsonrpc_monitor_find(s, new_monitor_id)) { error = ovsdb_syntax_error(new_monitor_id, NULL, @@ -1518,7 +1518,7 @@ ovsdb_jsonrpc_monitor_cond_change(struct ovsdb_jsonrpc_session *s, goto error; } - monitor_cond_change_reqs = params->u.array.elems[2]; + monitor_cond_change_reqs = params->array.elems[2]; if (monitor_cond_change_reqs->type != JSON_OBJECT) { error = ovsdb_syntax_error(NULL, NULL, @@ -1546,7 +1546,7 @@ ovsdb_jsonrpc_monitor_cond_change(struct ovsdb_jsonrpc_session *s, mr_value = node->data; if (mr_value->type == JSON_ARRAY) { - const struct json_array *array = &mr_value->u.array; + const struct json_array *array = &mr_value->array; for (i = 0; i < array->n; i++) { error = ovsdb_jsonrpc_parse_monitor_cond_change_request( diff --git a/ovsdb/log.c b/ovsdb/log.c index 1c9376815..c82a79c9f 100644 --- a/ovsdb/log.c +++ b/ovsdb/log.c @@ -494,7 +494,7 @@ ovsdb_log_read(struct ovsdb_log *file, struct json **jsonp) "offset %lld are not valid JSON (%s)", file->display_name, data_length, (long long int) data_offset, - json->u.string); + json->string); goto error; } if (json->type != JSON_OBJECT) { diff --git a/ovsdb/mutation.c b/ovsdb/mutation.c index e5d192e15..cd20bdb7c 100644 --- a/ovsdb/mutation.c +++ b/ovsdb/mutation.c @@ -85,9 +85,9 @@ ovsdb_mutation_from_json(const struct ovsdb_table_schema *ts, const char *column_name; if (json->type != JSON_ARRAY - || json->u.array.n != 3 - || json->u.array.elems[0]->type != JSON_STRING - || json->u.array.elems[1]->type != JSON_STRING) { + || json->array.n != 3 + || json->array.elems[0]->type != JSON_STRING + || json->array.elems[1]->type != JSON_STRING) { return ovsdb_syntax_error(json, NULL, "Parse error in mutation."); } array = json_array(json); diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index 68ec7b2d1..cdb021f39 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -488,7 +488,7 @@ parse_json(const char *s) { struct json *json = json_from_string(s); if (json->type == JSON_STRING) { - ovs_fatal(0, "\"%s\": %s", s, json->u.string); + ovs_fatal(0, "\"%s\": %s", s, json->string); } return json; } @@ -577,13 +577,13 @@ fetch_dbs(struct jsonrpc *rpc, struct svec *dbs) ovs_fatal(0, "list_dbs response is not array"); } - for (i = 0; i < reply->result->u.array.n; i++) { - const struct json *name = reply->result->u.array.elems[i]; + for (i = 0; i < reply->result->array.n; i++) { + const struct json *name = reply->result->array.elems[i]; if (name->type != JSON_STRING) { ovs_fatal(0, "list_dbs response %"PRIuSIZE" is not string", i); } - svec_add(dbs, name->u.string); + svec_add(dbs, name->string); } jsonrpc_msg_destroy(reply); svec_sort(dbs); @@ -650,14 +650,14 @@ parse_database_info_reply(const struct jsonrpc_msg *reply, const char *server, { const struct json *result = reply->result; if (result->type != JSON_ARRAY - || result->u.array.n != 1 - || result->u.array.elems[0]->type != JSON_OBJECT) { + || result->array.n != 1 + || result->array.elems[0]->type != JSON_OBJECT) { VLOG_WARN("%s: unexpected reply to _Server request for %s", server, database); return NULL; } - const struct json *op_result = result->u.array.elems[0]; + const struct json *op_result = result->array.elems[0]; const struct json *rows = shash_find_data(json_object(op_result), "rows"); if (!rows || rows->type != JSON_ARRAY) { VLOG_WARN("%s: missing \"rows\" member in _Server reply for %s", @@ -665,8 +665,8 @@ parse_database_info_reply(const struct jsonrpc_msg *reply, const char *server, return NULL; } - for (size_t i = 0; i < rows->u.array.n; i++) { - const struct json *row = rows->u.array.elems[i]; + for (size_t i = 0; i < rows->array.n; i++) { + const struct json *row = rows->array.elems[i]; if (row->type != JSON_OBJECT) { VLOG_WARN("%s: bad row in _Server reply for %s", server, database); @@ -855,11 +855,11 @@ do_transact__(int argc, char *argv[], struct json *transaction) { struct jsonrpc_msg *request, *reply; if (transaction->type != JSON_ARRAY - || !transaction->u.array.n - || transaction->u.array.elems[0]->type != JSON_STRING) { + || !transaction->array.n + || transaction->array.elems[0]->type != JSON_STRING) { ovs_fatal(0, "not a valid OVSDB query"); } - const char *db_name = json_string(transaction->u.array.elems[0]); + const char *db_name = json_string(transaction->array.elems[0]); struct jsonrpc *rpc; char *database = CONST_CAST(char *, db_name); @@ -902,21 +902,21 @@ do_query(struct jsonrpc *rpc OVS_UNUSED, const char *database OVS_UNUSED, struct json *abort_op = json_object_create(); json_object_put_string(abort_op, "op", "abort"); json_array_add(transaction, abort_op); - size_t abort_idx = transaction->u.array.n - 2; + size_t abort_idx = transaction->array.n - 2; /* Run query. */ struct json *result = do_transact__(argc, argv, transaction); /* If the "abort" operation ended the transaction, remove its result. */ if (result->type == JSON_ARRAY - && result->u.array.n == abort_idx + 1 - && result->u.array.elems[abort_idx]->type == JSON_OBJECT) { - struct json *op_result = result->u.array.elems[abort_idx]; + && result->array.n == abort_idx + 1 + && result->array.elems[abort_idx]->type == JSON_OBJECT) { + struct json *op_result = result->array.elems[abort_idx]; struct json *error = shash_find_data(json_object(op_result), "error"); if (error && error->type == JSON_STRING && !strcmp(json_string(error), "aborted")) { - result->u.array.n--; + result->array.n--; json_destroy(op_result); } } @@ -1178,7 +1178,7 @@ parse_monitor_columns(char *arg, const char *server, const char *database, } } - if (columns_json->u.array.n == 0) { + if (columns_json->array.n == 0) { const struct shash_node **nodes; size_t i, n; @@ -1456,9 +1456,9 @@ do_monitor__(struct jsonrpc *rpc, const char *database, && !strcmp(msg->method, "update")) { struct json *params = msg->params; if (params->type == JSON_ARRAY - && params->u.array.n == 2 - && params->u.array.elems[0]->type == JSON_NULL) { - monitor_print(params->u.array.elems[1], mts, n_mts, false); + && params->array.n == 2 + && params->array.elems[0]->type == JSON_NULL) { + monitor_print(params->array.elems[1], mts, n_mts, false); fflush(stdout); } } else if (msg->type == JSONRPC_NOTIFY @@ -1466,9 +1466,9 @@ do_monitor__(struct jsonrpc *rpc, const char *database, && !strcmp(msg->method, "update2")) { struct json *params = msg->params; if (params->type == JSON_ARRAY - && params->u.array.n == 2 - && params->u.array.elems[0]->type == JSON_NULL) { - monitor2_print(params->u.array.elems[1], mts, n_mts); + && params->array.n == 2 + && params->array.elems[0]->type == JSON_NULL) { + monitor2_print(params->array.elems[1], mts, n_mts); fflush(stdout); } } else if (msg->type == JSONRPC_NOTIFY @@ -1806,13 +1806,13 @@ do_dump(struct jsonrpc *rpc, const char *database, /* Print database contents. */ if (reply->result->type != JSON_ARRAY - || reply->result->u.array.n != n_tables) { + || reply->result->array.n != n_tables) { ovs_fatal(0, "reply is not array of %"PRIuSIZE" elements: %s", n_tables, json_to_string(reply->result, 0)); } for (i = 0; i < n_tables; i++) { const struct ovsdb_table_schema *ts = tables[i]->data; - const struct json *op_result = reply->result->u.array.elems[i]; + const struct json *op_result = reply->result->array.elems[i]; struct json *rows; if (op_result->type != JSON_OBJECT @@ -1824,9 +1824,9 @@ do_dump(struct jsonrpc *rpc, const char *database, } if (argc > 1) { - dump_table(tables[i]->name, &custom_columns, &rows->u.array); + dump_table(tables[i]->name, &custom_columns, &rows->array); } else { - dump_table(tables[i]->name, &ts->columns, &rows->u.array); + dump_table(tables[i]->name, &ts->columns, &rows->array); } } @@ -1920,7 +1920,7 @@ do_backup(struct jsonrpc *rpc, const char *database, /* Print database transaction record. */ if (reply->result->type != JSON_ARRAY - || reply->result->u.array.n != shash_count(&schema->tables)) { + || reply->result->array.n != shash_count(&schema->tables)) { ovs_fatal(0, "reply is not array of %"PRIuSIZE" elements: %s", shash_count(&schema->tables), json_to_string(reply->result, 0)); @@ -1931,7 +1931,7 @@ do_backup(struct jsonrpc *rpc, const char *database, SHASH_FOR_EACH (node, &schema->tables) { const char *table_name = node->name; const struct ovsdb_table_schema *table = node->data; - const struct json *op_result = reply->result->u.array.elems[i++]; + const struct json *op_result = reply->result->array.elems[i++]; struct json *rows; if (op_result->type != JSON_OBJECT @@ -1942,13 +1942,13 @@ do_backup(struct jsonrpc *rpc, const char *database, table->name, json_to_string(op_result, 0)); } - if (!rows->u.array.n) { + if (!rows->array.n) { continue; } struct json *output_rows = json_object_create(); - for (size_t j = 0; j < rows->u.array.n; j++) { - struct json *row = rows->u.array.elems[j]; + for (size_t j = 0; j < rows->array.n; j++) { + struct json *row = rows->array.elems[j]; if (row->type != JSON_OBJECT) { ovs_fatal(0, "%s table reply row is not an object: %s", table_name, json_to_string(row, 0)); diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 1ea2115c0..80715dfea 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -387,6 +387,7 @@ bool %(s)s_is_updated(const struct %(s)s *, enum %(s)s_column_id); #endif''') print("\n#endif /* %(prefix)sIDL_HEADER */" % {'prefix': prefix.upper()}) + def printEnum(type, members): if len(members) == 0: return diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 4bae22fc7..68f7acae9 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -943,9 +943,9 @@ query_db_remotes(const char *name, const struct shash *all_dbs, } } } else if (column->type.key.type == OVSDB_TYPE_UUID - && column->type.key.u.uuid.refTable + && column->type.key.uuid.refTable && column->type.value.type == OVSDB_TYPE_VOID) { - const struct ovsdb_table *ref_table = column->type.key.u.uuid.refTable; + const struct ovsdb_table *ref_table = column->type.key.uuid.refTable; HMAP_FOR_EACH (row, hmap_node, &table->rows) { const struct ovsdb_datum *datum; size_t i; @@ -1050,12 +1050,12 @@ update_remote_rows(const struct shash *all_dbs, const struct db *db_, if (db != db_ || column->type.key.type != OVSDB_TYPE_UUID - || !column->type.key.u.uuid.refTable + || !column->type.key.uuid.refTable || column->type.value.type != OVSDB_TYPE_VOID) { return; } - ref_table = column->type.key.u.uuid.refTable; + ref_table = column->type.key.uuid.refTable; HMAP_FOR_EACH (row, hmap_node, &table->rows) { const struct ovsdb_datum *datum; @@ -1903,8 +1903,8 @@ sset_from_json(struct sset *sset, const struct json *array) sset_clear(sset); ovs_assert(array->type == JSON_ARRAY); - for (i = 0; i < array->u.array.n; i++) { - const struct json *elem = array->u.array.elems[i]; + for (i = 0; i < array->array.n; i++) { + const struct json *elem = array->array.elems[i]; sset_add(sset, json_string(elem)); } } diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index c2ad2310c..95a777241 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -212,7 +212,7 @@ parse_json(const char *s) { struct json *json = json_from_string(s); if (json->type == JSON_STRING) { - ovs_fatal(0, "\"%s\": %s", s, json->u.string); + ovs_fatal(0, "\"%s\": %s", s, json->string); } return json; } diff --git a/ovsdb/ovsdb-util.c b/ovsdb/ovsdb-util.c index 1eca4fe33..c4075cdae 100644 --- a/ovsdb/ovsdb-util.c +++ b/ovsdb/ovsdb-util.c @@ -135,7 +135,7 @@ ovsdb_util_read_map_string_uuid_column(const struct ovsdb_row *row, return NULL; } - const struct ovsdb_table *ref_table = column->type.value.u.uuid.refTable; + const struct ovsdb_table *ref_table = column->type.value.uuid.refTable; if (!ref_table) { return NULL; } diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c index 3c51e1c19..da8db82a9 100644 --- a/ovsdb/ovsdb.c +++ b/ovsdb/ovsdb.c @@ -118,16 +118,16 @@ ovsdb_schema_check_ref_table(struct ovsdb_column *column, { struct ovsdb_table_schema *refTable; - if (base->type != OVSDB_TYPE_UUID || !base->u.uuid.refTableName) { + if (base->type != OVSDB_TYPE_UUID || !base->uuid.refTableName) { return NULL; } - refTable = shash_find_data(tables, base->u.uuid.refTableName); + refTable = shash_find_data(tables, base->uuid.refTableName); if (!refTable) { return ovsdb_syntax_error(NULL, NULL, "column %s %s refers to undefined table %s", column->name, base_name, - base->u.uuid.refTableName); + base->uuid.refTableName); } if (ovsdb_base_type_is_strong_ref(base) && !refTable->is_root) { @@ -388,11 +388,11 @@ static void ovsdb_set_ref_table(const struct shash *tables, struct ovsdb_base_type *base) { - if (base->type == OVSDB_TYPE_UUID && base->u.uuid.refTableName) { + if (base->type == OVSDB_TYPE_UUID && base->uuid.refTableName) { struct ovsdb_table *table; - table = shash_find_data(tables, base->u.uuid.refTableName); - base->u.uuid.refTable = table; + table = shash_find_data(tables, base->uuid.refTableName); + base->uuid.refTable = table; } } diff --git a/ovsdb/replication.c b/ovsdb/replication.c index bb18da8ef..2b9ae2f83 100644 --- a/ovsdb/replication.c +++ b/ovsdb/replication.c @@ -147,8 +147,8 @@ replication_add_local_db(const char *database, struct ovsdb *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]; + for (size_t i = 0; i < result->array.n; i++) { + const struct json *name = result->array.elems[i]; if (name->type == JSON_STRING) { /* Send one schema request for each remote DB. */ const char *db_name = json_string(name); @@ -203,13 +203,13 @@ replication_run(void) if (msg->type == JSONRPC_NOTIFY && state != RPL_S_ERR && !strcmp(msg->method, "update")) { if (msg->params->type == JSON_ARRAY - && msg->params->u.array.n == 2 - && msg->params->u.array.elems[0]->type == JSON_STRING) { - char *db_name = msg->params->u.array.elems[0]->u.string; + && msg->params->array.n == 2 + && msg->params->array.elems[0]->type == JSON_STRING) { + char *db_name = msg->params->array.elems[0]->string; struct ovsdb *db = find_db(db_name); if (db) { struct ovsdb_error *error; - error = process_notification(msg->params->u.array.elems[1], + error = process_notification(msg->params->array.elems[1], db); if (error) { ovsdb_error_assert(error); diff --git a/ovsdb/storage.c b/ovsdb/storage.c index 446cae086..b810bff04 100644 --- a/ovsdb/storage.c +++ b/ovsdb/storage.c @@ -246,12 +246,12 @@ ovsdb_storage_read(struct ovsdb_storage *storage, raft_next_entry(storage->raft, txnid, &is_snapshot)); if (!json) { return NULL; - } else if (json->type != JSON_ARRAY || json->u.array.n != 2) { + } else if (json->type != JSON_ARRAY || json->array.n != 2) { json_destroy(json); return ovsdb_error(NULL, "invalid commit format"); } - struct json **e = json->u.array.elems; + struct json **e = json->array.elems; schema_json = e[0]->type != JSON_NULL ? e[0] : NULL; txn_json = e[1]->type != JSON_NULL ? e[1] : NULL; } else if (storage->log) { diff --git a/ovsdb/table.c b/ovsdb/table.c index 7ec55d61f..6cd2d886d 100644 --- a/ovsdb/table.c +++ b/ovsdb/table.c @@ -152,7 +152,7 @@ ovsdb_table_schema_from_json(const struct json *json, const char *name, return ovsdb_syntax_error(json, NULL, "maxRows must be at least 1"); } - n_max_rows = max_rows->u.integer; + n_max_rows = max_rows->integer; } else { n_max_rows = UINT_MAX; } @@ -187,12 +187,12 @@ ovsdb_table_schema_from_json(const struct json *json, const char *name, if (indexes) { size_t i; - ts->indexes = xmalloc(indexes->u.array.n * sizeof *ts->indexes); - for (i = 0; i < indexes->u.array.n; i++) { + ts->indexes = xmalloc(indexes->array.n * sizeof *ts->indexes); + for (i = 0; i < indexes->array.n; i++) { struct ovsdb_column_set *index = &ts->indexes[i]; size_t j; - error = ovsdb_column_set_from_json(indexes->u.array.elems[i], + error = ovsdb_column_set_from_json(indexes->array.elems[i], ts, index); if (error) { goto error; diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c index 256916fff..9801aca2b 100644 --- a/ovsdb/transaction.c +++ b/ovsdb/transaction.c @@ -225,7 +225,7 @@ ovsdb_txn_adjust_atom_refs(struct ovsdb_txn *txn, const struct ovsdb_row *r, return NULL; } - table = base->u.uuid.refTable; + table = base->uuid.refTable; for (i = 0; i < n; i++) { const struct uuid *uuid = &atoms[i].uuid; struct ovsdb_txn_row *txn_row; @@ -322,7 +322,7 @@ delete_row_refs(struct ovsdb_txn *txn, const struct ovsdb_row *row, return NULL; } - table = base->u.uuid.refTable; + table = base->uuid.refTable; for (i = 0; i < n; i++) { const struct uuid *uuid = &atoms[i].uuid; struct ovsdb_txn_row *txn_row; @@ -549,7 +549,7 @@ assess_weak_refs(struct ovsdb_txn *txn, struct ovsdb_txn_row *txn_row) for (i = 0; i < datum->n; ) { const struct ovsdb_row *row; - row = ovsdb_table_get_row(column->type.key.u.uuid.refTable, + row = ovsdb_table_get_row(column->type.key.uuid.refTable, &datum->keys[i].uuid); if (row) { add_weak_ref(txn_row->new, row); @@ -567,7 +567,7 @@ assess_weak_refs(struct ovsdb_txn *txn, struct ovsdb_txn_row *txn_row) for (i = 0; i < datum->n; ) { const struct ovsdb_row *row; - row = ovsdb_table_get_row(column->type.value.u.uuid.refTable, + row = ovsdb_table_get_row(column->type.value.uuid.refTable, &datum->values[i].uuid); if (row) { add_weak_ref(txn_row->new, row); diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c index a2f88568e..3f62dc96f 100644 --- a/ovsdb/trigger.c +++ b/ovsdb/trigger.c @@ -230,14 +230,14 @@ ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now) /* Validate parameters. */ const struct json *params = t->request->params; - if (params->type != JSON_ARRAY || params->u.array.n != 2) { + if (params->type != JSON_ARRAY || params->array.n != 2) { trigger_convert_error(t, ovsdb_syntax_error(params, NULL, "array expected")); return false; } /* Parse new schema and make a converted copy. */ - const struct json *new_schema_json = params->u.array.elems[1]; + const struct json *new_schema_json = params->array.elems[1]; struct ovsdb_schema *new_schema; struct ovsdb_error *error = ovsdb_schema_from_json(new_schema_json, &new_schema); diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py index 7523b2092..54f577405 100644 --- a/python/ovs/db/types.py +++ b/python/ovs/db/types.py @@ -419,7 +419,7 @@ class BaseType(object): high = "INT64_MAX" else: high = "INT64_C(%d)" % self.max - init.append(".u.integer = { .min = %s, .max = %s }," % (low, high)) + init.append(".integer = { .min = %s, .max = %s }," % (low, high)) elif self.type == RealType: if self.min is None: low = "-DBL_MAX" @@ -429,7 +429,7 @@ class BaseType(object): high = "DBL_MAX" else: high = self.max - init.append(".u.real = { .min = %s, .max = %s }," % (low, high)) + init.append(".real = { .min = %s, .max = %s }," % (low, high)) elif self.type == StringType: if self.min is None: low = 0 @@ -439,11 +439,11 @@ class BaseType(object): high = "UINT_MAX" else: high = self.max_length - init.append(".u.string = { .minLen = %s, .maxLen = %s }," % ( + init.append(".string = { .minLen = %s, .maxLen = %s }," % ( low, high)) elif self.type == UuidType: if self.ref_table_name is not None: - init.append(".u.uuid = { .refTableName = \"%s\", " + init.append(".uuid = { .refTableName = \"%s\", " ".refType = OVSDB_REF_%s }," % ( escapeCString(self.ref_table_name), self.ref_type.upper())) diff --git a/tests/test-json.c b/tests/test-json.c index 281921057..a7ee595e0 100644 --- a/tests/test-json.c +++ b/tests/test-json.c @@ -37,7 +37,7 @@ print_and_free_json(struct json *json) { bool ok; if (json->type == JSON_STRING) { - printf("error: %s\n", json->u.string); + printf("error: %s\n", json->string); ok = false; } else { char *s = json_to_string(json, JSSF_SORT | (pretty ? JSSF_PRETTY : 0)); diff --git a/tests/test-jsonrpc.c b/tests/test-jsonrpc.c index 14c3ef175..49d2b91bd 100644 --- a/tests/test-jsonrpc.c +++ b/tests/test-jsonrpc.c @@ -124,7 +124,7 @@ parse_json(const char *s) { struct json *json = json_from_string(s); if (json->type == JSON_STRING) { - ovs_fatal(0, "\"%s\": %s", s, json->u.string); + ovs_fatal(0, "\"%s\": %s", s, json->string); } return json; } diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index 246a4260b..c557c7c64 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -258,7 +258,7 @@ parse_json(const char *s) { struct json *json = json_from_string(s); if (json->type == JSON_STRING) { - ovs_fatal(0, "\"%s\": %s", s, json->u.string); + ovs_fatal(0, "\"%s\": %s", s, json->string); } return json; } @@ -266,9 +266,9 @@ parse_json(const char *s) static struct json * unbox_json(struct json *json) { - if (json->type == JSON_ARRAY && json->u.array.n == 1) { - struct json *inner = json->u.array.elems[0]; - json->u.array.elems[0] = NULL; + if (json->type == JSON_ARRAY && json->array.n == 1) { + struct json *inner = json->array.elems[0]; + json->array.elems[0] = NULL; json_destroy(json); return inner; } else { @@ -732,11 +732,11 @@ do_sort_atoms(struct ovs_cmdl_context *ctx) } /* Convert JSON atoms to internal representation. */ - n_atoms = json->u.array.n; + n_atoms = json->array.n; atoms = xmalloc(n_atoms * sizeof *atoms); for (i = 0; i < n_atoms; i++) { check_ovsdb_error(ovsdb_atom_from_json(&atoms[i], &base, - json->u.array.elems[i], NULL)); + json->array.elems[i], NULL)); } json_destroy(json); @@ -867,13 +867,13 @@ do_compare_rows(struct ovs_cmdl_context *ctx) rows[i] = ovsdb_row_create(table); json = parse_json(ctx->argv[i + 2]); - if (json->type != JSON_ARRAY || json->u.array.n != 2 - || json->u.array.elems[0]->type != JSON_STRING) { + if (json->type != JSON_ARRAY || json->array.n != 2 + || json->array.elems[0]->type != JSON_STRING) { ovs_fatal(0, "\"%s\" does not have expected form " "[\"name\", {data}]", ctx->argv[i]); } - names[i] = xstrdup(json->u.array.elems[0]->u.string); - check_ovsdb_error(ovsdb_row_from_json(rows[i], json->u.array.elems[1], + names[i] = xstrdup(json->array.elems[0]->string); + check_ovsdb_error(ovsdb_row_from_json(rows[i], json->array.elems[1], NULL, NULL)); json_destroy(json); } @@ -965,10 +965,10 @@ do_evaluate_condition__(struct ovs_cmdl_context *ctx, int mode) if (json->type != JSON_ARRAY) { ovs_fatal(0, "CONDITION argument is not JSON array"); } - n_conditions = json->u.array.n; + n_conditions = json->array.n; conditions = xmalloc(n_conditions * sizeof *conditions); for (i = 0; i < n_conditions; i++) { - check_ovsdb_error(ovsdb_condition_from_json(ts, json->u.array.elems[i], + check_ovsdb_error(ovsdb_condition_from_json(ts, json->array.elems[i], NULL, &conditions[i])); } json_destroy(json); @@ -978,11 +978,11 @@ do_evaluate_condition__(struct ovs_cmdl_context *ctx, int mode) if (json->type != JSON_ARRAY) { ovs_fatal(0, "ROW argument is not JSON array"); } - n_rows = json->u.array.n; + n_rows = json->array.n; rows = xmalloc(n_rows * sizeof *rows); for (i = 0; i < n_rows; i++) { rows[i] = ovsdb_row_create(table); - check_ovsdb_error(ovsdb_row_from_json(rows[i], json->u.array.elems[i], + check_ovsdb_error(ovsdb_row_from_json(rows[i], json->array.elems[i], NULL, NULL)); } json_destroy(json); @@ -1052,11 +1052,11 @@ do_compare_conditions(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "CONDITION argument is not JSON array"); } - n_conditions = json->u.array.n; + n_conditions = json->array.n; conditions = xmalloc(n_conditions * sizeof *conditions); for (i = 0; i < n_conditions; i++) { - check_ovsdb_error(ovsdb_condition_from_json(ts, json->u.array.elems[i], + check_ovsdb_error(ovsdb_condition_from_json(ts, json->array.elems[i], NULL, &conditions[i])); } json_destroy(json); @@ -1132,11 +1132,11 @@ do_execute_mutations(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "MUTATION argument is not JSON array"); } - n_sets = json->u.array.n; + n_sets = json->array.n; sets = xmalloc(n_sets * sizeof *sets); for (i = 0; i < n_sets; i++) { check_ovsdb_error(ovsdb_mutation_set_from_json(ts, - json->u.array.elems[i], + json->array.elems[i], NULL, &sets[i])); } json_destroy(json); @@ -1146,11 +1146,11 @@ do_execute_mutations(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "ROW argument is not JSON array"); } - n_rows = json->u.array.n; + n_rows = json->array.n; rows = xmalloc(n_rows * sizeof *rows); for (i = 0; i < n_rows; i++) { rows[i] = ovsdb_row_create(table); - check_ovsdb_error(ovsdb_row_from_json(rows[i], json->u.array.elems[i], + check_ovsdb_error(ovsdb_row_from_json(rows[i], json->array.elems[i], NULL, NULL)); } json_destroy(json); @@ -1256,13 +1256,13 @@ do_query(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "ROW argument is not JSON array"); } - cbdata.n_rows = json->u.array.n; + cbdata.n_rows = json->array.n; cbdata.row_uuids = xmalloc(cbdata.n_rows * sizeof *cbdata.row_uuids); cbdata.counts = xmalloc(cbdata.n_rows * sizeof *cbdata.counts); for (i = 0; i < cbdata.n_rows; i++) { struct ovsdb_row *row = ovsdb_row_create(table); uuid_generate(ovsdb_row_get_uuid_rw(row)); - check_ovsdb_error(ovsdb_row_from_json(row, json->u.array.elems[i], + check_ovsdb_error(ovsdb_row_from_json(row, json->array.elems[i], NULL, NULL)); if (ovsdb_table_get_row(table, ovsdb_row_get_uuid(row))) { ovs_fatal(0, "duplicate UUID "UUID_FMT" in table", @@ -1278,11 +1278,11 @@ do_query(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "CONDITION argument is not JSON array"); } - for (i = 0; i < json->u.array.n; i++) { + for (i = 0; i < json->array.n; i++) { struct ovsdb_condition cnd; size_t j; - check_ovsdb_error(ovsdb_condition_from_json(ts, json->u.array.elems[i], + check_ovsdb_error(ovsdb_condition_from_json(ts, json->array.elems[i], NULL, &cnd)); memset(cbdata.counts, 0, cbdata.n_rows * sizeof *cbdata.counts); @@ -1356,7 +1356,7 @@ do_query_distinct(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "ROW argument is not JSON array"); } - n_rows = json->u.array.n; + n_rows = json->array.n; rows = xmalloc(n_rows * sizeof *rows); classes = xmalloc(n_rows * sizeof *classes); n_classes = 0; @@ -1367,7 +1367,7 @@ do_query_distinct(struct ovs_cmdl_context *ctx) /* Parse row. */ row = ovsdb_row_create(table); uuid_generate(ovsdb_row_get_uuid_rw(row)); - check_ovsdb_error(ovsdb_row_from_json(row, json->u.array.elems[i], + check_ovsdb_error(ovsdb_row_from_json(row, json->array.elems[i], NULL, NULL)); /* Initialize row and find equivalence class. */ @@ -1400,12 +1400,12 @@ do_query_distinct(struct ovs_cmdl_context *ctx) if (json->type != JSON_ARRAY) { ovs_fatal(0, "CONDITION argument is not JSON array"); } - for (i = 0; i < json->u.array.n; i++) { + for (i = 0; i < json->array.n; i++) { struct ovsdb_row_set results; struct ovsdb_condition cnd; size_t j; - check_ovsdb_error(ovsdb_condition_from_json(ts, json->u.array.elems[i], + check_ovsdb_error(ovsdb_condition_from_json(ts, json->array.elems[i], NULL, &cnd)); for (j = 0; j < n_classes; j++) { @@ -1797,10 +1797,10 @@ do_transact(struct ovs_cmdl_context *ctx) "with at least 1 element", i); } - n_args = command->u.array.n; + n_args = command->array.n; args = xmalloc((n_args + 1) * sizeof *args); for (j = 0; j < n_args; j++) { - struct json *s = command->u.array.elems[j]; + struct json *s = command->array.elems[j]; if (s->type != JSON_STRING) { ovs_fatal(0, "transaction %d argument %d must be JSON string", i, j); @@ -2041,7 +2041,7 @@ parse_uuids(const struct json *json, struct ovsdb_symbol_table *symtab, { struct uuid uuid; - if (json->type == JSON_STRING && uuid_from_string(&uuid, json->u.string)) { + if (json->type == JSON_STRING && uuid_from_string(&uuid, json->string)) { char *name = xasprintf("#%"PRIuSIZE"#", *n); fprintf(stderr, "%s = "UUID_FMT"\n", name, UUID_ARGS(&uuid)); ovsdb_symbol_table_put(symtab, name, &uuid, false); @@ -2050,8 +2050,8 @@ parse_uuids(const struct json *json, struct ovsdb_symbol_table *symtab, } else if (json->type == JSON_ARRAY) { size_t i; - for (i = 0; i < json->u.array.n; i++) { - parse_uuids(json->u.array.elems[i], symtab, n); + for (i = 0; i < json->array.n; i++) { + parse_uuids(json->array.elems[i], symtab, n); } } else if (json->type == JSON_OBJECT) { const struct shash_node *node; @@ -2068,16 +2068,16 @@ substitute_uuids(struct json *json, const struct ovsdb_symbol_table *symtab) if (json->type == JSON_STRING) { const struct ovsdb_symbol *symbol; - symbol = ovsdb_symbol_table_get(symtab, json->u.string); + symbol = ovsdb_symbol_table_get(symtab, json->string); if (symbol) { - free(json->u.string); - json->u.string = xasprintf(UUID_FMT, UUID_ARGS(&symbol->uuid)); + free(json->string); + json->string = xasprintf(UUID_FMT, UUID_ARGS(&symbol->uuid)); } } else if (json->type == JSON_ARRAY) { size_t i; - for (i = 0; i < json->u.array.n; i++) { - substitute_uuids(json->u.array.elems[i], symtab); + for (i = 0; i < json->array.n; i++) { + substitute_uuids(json->array.elems[i], symtab); } } else if (json->type == JSON_OBJECT) { const struct shash_node *node; @@ -2326,25 +2326,25 @@ update_conditions(struct ovsdb_idl *idl, char *commands) } struct ovsdb_idl_condition cond = OVSDB_IDL_CONDITION_INIT(&cond); - for (i = 0; i < json->u.array.n; i++) { - const struct json *clause = json->u.array.elems[i]; + for (i = 0; i < json->array.n; i++) { + const struct json *clause = json->array.elems[i]; if (clause->type == JSON_TRUE) { ovsdb_idl_condition_add_clause_true(&cond); - } else if (clause->type != JSON_ARRAY || clause->u.array.n != 3 - || clause->u.array.elems[0]->type != JSON_STRING - || clause->u.array.elems[1]->type != JSON_STRING) { + } else if (clause->type != JSON_ARRAY || clause->array.n != 3 + || clause->array.elems[0]->type != JSON_STRING + || clause->array.elems[1]->type != JSON_STRING) { ovs_fatal(0, "Error parsing condition"); } else { enum ovsdb_function function; - const char *function_s = json_string(clause->u.array.elems[1]); + const char *function_s = json_string(clause->array.elems[1]); struct ovsdb_error *error = ovsdb_function_from_string( function_s, &function); if (error) { ovs_fatal(0, "unknown clause function %s", function_s); } - const char *column = json_string(clause->u.array.elems[0]); - const struct json *arg = clause->u.array.elems[2]; + const char *column = json_string(clause->array.elems[0]); + const struct json *arg = clause->array.elems[2]; if (!strcmp(table_name, "simple")) { parse_simple_json_clause(&cond, function, column, arg); } else if (!strcmp(table_name, "link1")) {