mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
db-ctl-base: Don't die in pre_parse_column_key_value() on error.
Return the error message to the caller instead of reporting it and dying so that the caller can handle the error without terminating the process if needed. Also, we no longer return the column as it was not used by any of existing callers. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
committed by
Ben Pfaff
parent
c835e58951
commit
7ecbc7f618
@@ -647,25 +647,30 @@ parse_column_key_value(const char *arg,
|
||||
return error;
|
||||
}
|
||||
|
||||
static const struct ovsdb_idl_column *
|
||||
pre_parse_column_key_value(struct ctl_context *ctx,
|
||||
const char *arg,
|
||||
static char * OVS_WARN_UNUSED_RESULT
|
||||
pre_parse_column_key_value(struct ctl_context *ctx, const char *arg,
|
||||
const struct ovsdb_idl_table_class *table)
|
||||
{
|
||||
const struct ovsdb_idl_column *column;
|
||||
const char *p;
|
||||
char *column_name;
|
||||
char *column_name = NULL;
|
||||
char *error;
|
||||
|
||||
p = arg;
|
||||
die_if_error(ovsdb_token_parse(&p, &column_name));
|
||||
error = ovsdb_token_parse(&p, &column_name);
|
||||
if (error) {
|
||||
goto out;
|
||||
}
|
||||
if (column_name[0] == '\0') {
|
||||
ctl_fatal("%s: missing column name", arg);
|
||||
error = xasprintf("%s: missing column name", arg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
die_if_error(pre_get_column(ctx, table, column_name, &column));
|
||||
error = pre_get_column(ctx, table, column_name, &column);
|
||||
out:
|
||||
free(column_name);
|
||||
|
||||
return column;
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Checks if the 'column' is mutable. Returns NULL if it is mutable, or a
|
||||
@@ -882,7 +887,7 @@ pre_cmd_get(struct ctl_context *ctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
pre_parse_column_key_value(ctx, ctx->argv[i], table);
|
||||
die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1196,7 +1201,7 @@ pre_cmd_find(struct ctl_context *ctx)
|
||||
die_if_error(pre_get_table(ctx, table_name, &table));
|
||||
pre_list_columns(ctx, table, column_names);
|
||||
for (i = 2; i < ctx->argc; i++) {
|
||||
pre_parse_column_key_value(ctx, ctx->argv[i], table);
|
||||
die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1318,7 +1323,7 @@ pre_cmd_set(struct ctl_context *ctx)
|
||||
|
||||
die_if_error(pre_get_table(ctx, table_name, &table));
|
||||
for (i = 3; i < ctx->argc; i++) {
|
||||
pre_parse_column_key_value(ctx, ctx->argv[i], table);
|
||||
die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1666,7 +1671,7 @@ pre_cmd_wait_until(struct ctl_context *ctx)
|
||||
die_if_error(pre_get_table(ctx, table_name, &table));
|
||||
|
||||
for (i = 3; i < ctx->argc; i++) {
|
||||
pre_parse_column_key_value(ctx, ctx->argv[i], table);
|
||||
die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user