From patchwork Mon Jul 2 10:49:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937786 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3tw1FfSz9s29 for ; Mon, 2 Jul 2018 20:50:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id ADFEBC96; Mon, 2 Jul 2018 10:50:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5193EC8D for ; Mon, 2 Jul 2018 10:50:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C366B334 for ; Mon, 2 Jul 2018 10:50:24 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id p1-v6so15061869wrs.9 for ; Mon, 02 Jul 2018 03:50:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=0ZeYdJHy06DCTYhldUr7hJEotniEWRLEP/7J3/15oiM=; b=dx1oEH++CNvbzK2e8EJfl0gwEZMUhkrgIdW1HziROEBAaAZoGSSywV1AmE03186G5C VVZkD3Ky3g42caUhkb5q36HL9u1+mQb7K/QkY7VeiasA6eenhxxUs8H/SYS/ReD5l8d/ cuPhx24KlWv2e8W7SWTwW1EIwnB4NU52K81LF0F2NuB3o5fb4Yy0ca1gFsjVuGvKuy1s y0gG6iSyOl+9S2nAbKpVV9rpcH7jfEE57hGkqNHVc2ays6nm6uClAH9L/GecQLdibk+j vX3drqKbq4sbrhpsG0vyb2bOms6QUchoGXOGiwanOWoHk/S3J+Ud4IVQ+13gcqJ3FtnR z0sg== X-Gm-Message-State: APt69E2EdJkSCQVbjU7vrbKS8v3/B6yUA4UFsrOem06mkW7KVB6Av+K5 8igJi9+dG/rC0UMyYU8mHMdt6Uk9Nlk= X-Google-Smtp-Source: AAOMgpclhbtFFZYKywV8wIQA/oDzLmAVFz+w4ALIMHBg0xYblQ9Fgzs/rl1Anw8Gdcua0we+QYObOQ== X-Received: by 2002:adf:afd3:: with SMTP id y19-v6mr20789484wrd.176.1530528623167; Mon, 02 Jul 2018 03:50:23 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id h4-v6sm24201212wre.89.2018.07.02.03.50.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:22 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:49:57 +0200 Message-Id: <20180702105019.10345-2-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 01/23] db-ctl-base: Don't die in parse_column_names() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 0e26f09cc..d589df487 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -918,7 +918,8 @@ cmd_get(struct ctl_context *ctx) } } -static void +/* Returns NULL on success or malloc()'ed error message on failure. */ +static char * OVS_WARN_UNUSED_RESULT parse_column_names(const char *column_names, const struct ovsdb_idl_table_class *table, const struct ovsdb_idl_column ***columnsp, @@ -951,7 +952,12 @@ parse_column_names(const char *column_names, if (!strcasecmp(column_name, "_uuid")) { column = NULL; } else { - die_if_error(get_column(table, column_name, &column)); + char *error = get_column(table, column_name, &column); + if (error) { + free(columns); + free(s); + return error; + } } if (n_columns >= allocated_columns) { columns = x2nrealloc(columns, &allocated_columns, @@ -962,11 +968,12 @@ parse_column_names(const char *column_names, free(s); if (!n_columns) { - ctl_fatal("must specify at least one column name"); + return xstrdup("must specify at least one column name"); } } *columnsp = columns; *n_columnsp = n_columns; + return NULL; } static void @@ -978,7 +985,7 @@ pre_list_columns(struct ctl_context *ctx, size_t n_columns; size_t i; - parse_column_names(column_names, table, &columns, &n_columns); + die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); for (i = 0; i < n_columns; i++) { if (columns[i]) { ovsdb_idl_add_column(ctx->idl, columns[i]); @@ -1067,7 +1074,7 @@ cmd_list(struct ctl_context *ctx) int i; table = get_table(table_name); - parse_column_names(column_names, table, &columns, &n_columns); + die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); out = ctx->table = list_make_table(columns, n_columns); if (ctx->argc > 2) { for (i = 2; i < ctx->argc; i++) { @@ -1140,7 +1147,7 @@ cmd_find(struct ctl_context *ctx) size_t n_columns; table = get_table(table_name); - parse_column_names(column_names, table, &columns, &n_columns); + die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); out = ctx->table = list_make_table(columns, n_columns); for (row = ovsdb_idl_first_row(ctx->idl, table); row; row = ovsdb_idl_next_row(row)) { From patchwork Mon Jul 2 10:49:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937787 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3vR11tSz9s29 for ; Mon, 2 Jul 2018 20:50:59 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7A052C9B; Mon, 2 Jul 2018 10:50:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7CC06C9A for ; Mon, 2 Jul 2018 10:50:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 97256334 for ; Mon, 2 Jul 2018 10:50:26 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id w16-v6so7858024wmc.2 for ; Mon, 02 Jul 2018 03:50:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=pct8JR2tWzIcw7OmvxMt4ea/avSlHwgqoHePlXRhfuI=; b=biaZ84j80uWz+jjeWHWeS1xjT/lrGjRwqp08+gcxntLk/g+tRvS2y5MbamHEEZTS9z QeN/EkJnAzBcpMLBf7ii9rZ3hga3QTMR5RxdqifmaO3TJjzIMrzAcLb3tIJQiYyIXa8P VnlluAO+7T/XfKP66nkunluZfP6Rb3Jk6+v8NDzlj8W0UwE4u0yWKeOcLut6W9o16aY7 WhucHbuVCri6MRmHP2opiAeE8hvHszagDRMvd1Tyzv2ZQTipyZgeI78IF1yWg1T7mAIq SK//2u+buqO0WrQPMKIsWLZii8xFXjB6A6rZGluRm83SjSHlgHrDZkywSY59WOxZIvO1 7a2g== X-Gm-Message-State: APt69E2zPxbi9Y2iaYUc8A3FL+CJsaFq5RPuz0bQQt8fGVKkH9onaLXH nozZfID77CRCXr5besbzFONEsh9iq6g= X-Google-Smtp-Source: AAOMgpf//knsCK8RYOBZVZdZabhnPtMMYRFR5PUnAjVlRu2JpBbeTb0nFKxZE5RMCMcvVSDkYci6Rw== X-Received: by 2002:a1c:b1d7:: with SMTP id a206-v6mr8189747wmf.61.1530528624898; Mon, 02 Jul 2018 03:50:24 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id q17-v6sm15361320wro.30.2018.07.02.03.50.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:24 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:49:58 +0200 Message-Id: <20180702105019.10345-3-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 02/23] db-ctl-base: Don't die in get_table() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index d589df487..22af30667 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -72,7 +72,7 @@ static const struct ovsdb_idl_table_class *idl_classes; static size_t n_classes; static struct shash all_commands = SHASH_INITIALIZER(&all_commands); -static const struct ovsdb_idl_table_class *get_table(const char *table_name); +static char *get_table(const char *, const struct ovsdb_idl_table_class **); static void set_column(const struct ovsdb_idl_table_class *, const struct ovsdb_idl_row *, const char *, struct ovsdb_symbol_table *); @@ -455,7 +455,8 @@ pre_get_column(struct ctl_context *ctx, static const struct ovsdb_idl_table_class * pre_get_table(struct ctl_context *ctx, const char *table_name) { - const struct ovsdb_idl_table_class *table = get_table(table_name); + const struct ovsdb_idl_table_class *table; + die_if_error(get_table(table_name, &table)); ovsdb_idl_add_table(ctx->idl, table); const struct ctl_table_class *ctl = &ctl_classes[table - idl_classes]; @@ -842,7 +843,7 @@ cmd_get(struct ctl_context *ctx) ctl_fatal("--if-exists and --id may not be specified together"); } - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); row = ctl_get_row(ctx, table, record_id, must_exist); if (!row) { return; @@ -1073,7 +1074,7 @@ cmd_list(struct ctl_context *ctx) size_t n_columns; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); out = ctx->table = list_make_table(columns, n_columns); if (ctx->argc > 2) { @@ -1092,13 +1093,15 @@ cmd_list(struct ctl_context *ctx) free(columns); } -/* Finds and returns the "struct ovsdb_idl_table_class *" with 'table_name' by - * searching the tables in these schema. */ -static const struct ovsdb_idl_table_class * -get_table(const char *table_name) +/* Finds the "struct ovsdb_idl_table_class *" with 'table_name' by searching + * the tables in these schema. Returns NULL and sets 'tablep' on success, or a + * malloc()'ed error message on failure. */ +static char * OVS_WARN_UNUSED_RESULT +get_table(const char *table_name, const struct ovsdb_idl_table_class **tablep) { const struct ovsdb_idl_table_class *best_match = NULL; unsigned int best_score = 0; + char *error = NULL; for (const struct ovsdb_idl_table_class *table = idl_classes; table < &idl_classes[n_classes]; table++) { @@ -1111,13 +1114,13 @@ get_table(const char *table_name) } } if (best_match) { - return best_match; + *tablep = best_match; } else if (best_score) { - ctl_fatal("multiple table names match \"%s\"", table_name); + error = xasprintf("multiple table names match \"%s\"", table_name); } else { - ctl_fatal("unknown table \"%s\"", table_name); + error = xasprintf("unknown table \"%s\"", table_name); } - return NULL; + return error; } static void @@ -1146,7 +1149,7 @@ cmd_find(struct ctl_context *ctx) struct table *out; size_t n_columns; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); out = ctx->table = list_make_table(columns, n_columns); for (row = ovsdb_idl_first_row(ctx->idl, table); row; @@ -1243,7 +1246,7 @@ cmd_set(struct ctl_context *ctx) const struct ovsdb_idl_row *row; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); row = ctl_get_row(ctx, table, record_id, must_exist); if (!row) { return; @@ -1282,7 +1285,7 @@ cmd_add(struct ctl_context *ctx) struct ovsdb_datum old; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); die_if_error(get_column(table, column_name, &column)); row = ctl_get_row(ctx, table, record_id, must_exist); if (!row) { @@ -1343,7 +1346,7 @@ cmd_remove(struct ctl_context *ctx) struct ovsdb_datum old; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); die_if_error(get_column(table, column_name, &column)); row = ctl_get_row(ctx, table, record_id, must_exist); if (!row) { @@ -1415,7 +1418,7 @@ cmd_clear(struct ctl_context *ctx) const struct ovsdb_idl_row *row; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); row = ctl_get_row(ctx, table, record_id, must_exist); if (!row) { return; @@ -1450,7 +1453,7 @@ pre_create(struct ctl_context *ctx) const char *table_name = ctx->argv[1]; const struct ovsdb_idl_table_class *table; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); if (!id && !table->is_root) { VLOG_WARN("applying \"create\" command to table %s without --id " "option will have no effect", table->name); @@ -1462,11 +1465,12 @@ cmd_create(struct ctl_context *ctx) { const char *id = shash_find_data(&ctx->options, "--id"); const char *table_name = ctx->argv[1]; - const struct ovsdb_idl_table_class *table = get_table(table_name); + const struct ovsdb_idl_table_class *table; const struct ovsdb_idl_row *row; const struct uuid *uuid; int i; + die_if_error(get_table(table_name, &table)); if (id) { struct ovsdb_symbol *symbol = create_symbol(ctx->symtab, id, NULL); if (table->is_root) { @@ -1530,7 +1534,7 @@ cmd_destroy(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); if (delete_all && ctx->argc > 2) { ctl_fatal("--all and records argument should not be specified together"); @@ -1586,7 +1590,7 @@ cmd_wait_until(struct ctl_context *ctx) const struct ovsdb_idl_row *row; int i; - table = get_table(table_name); + die_if_error(get_table(table_name, &table)); row = ctl_get_row(ctx, table, record_id, false); if (!row) { @@ -2315,5 +2319,8 @@ void ctl_set_column(const char *table_name, const struct ovsdb_idl_row *row, const char *arg, struct ovsdb_symbol_table *symtab) { - set_column(get_table(table_name), row, arg, symtab); + const struct ovsdb_idl_table_class *table; + + die_if_error(get_table(table_name, &table)); + set_column(table, row, arg, symtab); } From patchwork Mon Jul 2 10:49:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937788 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3vz6NGqz9s29 for ; Mon, 2 Jul 2018 20:51:27 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3F176CB0; Mon, 2 Jul 2018 10:50:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 43956CAB for ; Mon, 2 Jul 2018 10:50:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CA504691 for ; Mon, 2 Jul 2018 10:50:33 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id i139-v6so8494044wmf.4 for ; Mon, 02 Jul 2018 03:50:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=cGHlppugSqRi//GD9SjU2i0Y/eNVHNmPCvpjFCGYNRU=; b=EljibAz9fxHAs4KgFG3yaaQvx0mB/4ZrwGfU8wBsvvTpn9lIC3DLeMPCAirn8kg08R Zg4eVu5hPlpUqXEYtIIzkp+9r6b3LtwkSIo3x7ScWz8Es4j/3nl34EK4ol7hW1yC2L4B 9p+328Kzaxa4QVQA6QSShGBXpnqcL0kMjTc5WLsRkQ2lMwXhNO+i9gBHe6Y6rKpXFZzD CE0ymdgrwnU3bzpcDOompPmqZoXi/fxIHdo5hhAWWdzUhVfN4ThXgnIlfO+xKNMDJ8bq vBYqRowCM9LgbfDsJYlWtvv71dtYW+Ykr78KeJsx06I5+Mzb48gi7OIWPiHjsuHJlv/A hmKQ== X-Gm-Message-State: APt69E1w7LkAMy80WmJ0kejHlCAvOfIVFGlKgmsZeoGrcc7vOx75C6rs XdacEEqw8B9+u/U0ICTy9CQJxs9HvjU= X-Google-Smtp-Source: AAOMgpcGjQECerNtb+H6Lxuz/Bzd4qPubjcFVv6/8TFpuTrVQYipv6Fe4hfwVsEMEiwnWEHEpVM7yA== X-Received: by 2002:a1c:f46:: with SMTP id 67-v6mr5232679wmp.122.1530528632097; Mon, 02 Jul 2018 03:50:32 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id a203-v6sm7106512wme.46.2018.07.02.03.50.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:31 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:49:59 +0200 Message-Id: <20180702105019.10345-4-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 03/23] db-ctl-base: Don't die in is_condition_satisfied() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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, rename the function as it is no longer a typical predicate, so that the users don't assume that the result is passed in return value. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 65 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 22af30667..a826dfb94 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -706,10 +706,14 @@ evaluate_relop(const struct ovsdb_datum *a, const struct ovsdb_datum *b, } } -static bool -is_condition_satisfied(const struct ovsdb_idl_table_class *table, - const struct ovsdb_idl_row *row, const char *arg, - struct ovsdb_symbol_table *symtab) +/* Checks if given row satisfies the specified condition. Returns the result of + * evaluating the condition in 'satisfied' flag and NULL as a return value on + * success. On failure returns a malloc()'ed error message and 'satisfied' + * value is not modified. */ +static char * OVS_WARN_UNUSED_RESULT +check_condition(const struct ovsdb_idl_table_class *table, + const struct ovsdb_idl_row *row, const char *arg, + struct ovsdb_symbol_table *symtab, bool *satisfied) { static const char *operators[] = { #define RELOP(ENUM, STRING) STRING, @@ -719,18 +723,24 @@ is_condition_satisfied(const struct ovsdb_idl_table_class *table, const struct ovsdb_idl_column *column; const struct ovsdb_datum *have_datum; - char *key_string, *value_string; + char *key_string = NULL; + char *value_string = NULL; struct ovsdb_type type; int operator; bool retval; char *error; + ovs_assert(satisfied); + error = parse_column_key_value(arg, table, &column, &key_string, &operator, operators, ARRAY_SIZE(operators), &value_string); - die_if_error(error); + if (error) { + goto out; + } if (!value_string) { - ctl_fatal("%s: missing value", arg); + error = xasprintf("%s: missing value", arg); + goto out; } type = column->type; @@ -743,16 +753,23 @@ is_condition_satisfied(const struct ovsdb_idl_table_class *table, unsigned int idx; if (column->type.value.type == OVSDB_TYPE_VOID) { - ctl_fatal("cannot specify key to check for non-map column %s", - column->name); + error = xasprintf("cannot specify key to check for non-map column " + "%s", column->name); + goto out; } - die_if_error(ovsdb_atom_from_string(&want_key, NULL, &column->type.key, - key_string, symtab)); + error = ovsdb_atom_from_string(&want_key, NULL, &column->type.key, + key_string, symtab); + if (error) { + goto out; + } type.key = type.value; type.value.type = OVSDB_TYPE_VOID; - die_if_error(ovsdb_datum_from_string(&b, &type, value_string, symtab)); + error = ovsdb_datum_from_string(&b, &type, value_string, symtab); + if (error) { + goto out; + } idx = ovsdb_datum_find_key(have_datum, &want_key, column->type.key.type); @@ -779,16 +796,21 @@ is_condition_satisfied(const struct ovsdb_idl_table_class *table, } else { struct ovsdb_datum want_datum; - die_if_error(ovsdb_datum_from_string(&want_datum, &column->type, - value_string, symtab)); + error = ovsdb_datum_from_string(&want_datum, &column->type, + value_string, symtab); + if (error) { + goto out; + } retval = evaluate_relop(have_datum, &want_datum, &type, operator); ovsdb_datum_destroy(&want_datum, &column->type); } + *satisfied = retval; +out: free(key_string); free(value_string); - return retval; + return error; } static void @@ -1157,8 +1179,11 @@ cmd_find(struct ctl_context *ctx) int i; for (i = 2; i < ctx->argc; i++) { - if (!is_condition_satisfied(table, row, ctx->argv[i], - ctx->symtab)) { + bool satisfied; + + die_if_error(check_condition(table, row, ctx->argv[i], ctx->symtab, + &satisfied)); + if (!satisfied) { goto next_row; } } @@ -1599,7 +1624,11 @@ cmd_wait_until(struct ctl_context *ctx) } for (i = 3; i < ctx->argc; i++) { - if (!is_condition_satisfied(table, row, ctx->argv[i], ctx->symtab)) { + bool satisfied; + + die_if_error(check_condition(table, row, ctx->argv[i], ctx->symtab, + &satisfied)); + if (!satisfied) { ctx->try_again = true; return; } From patchwork Mon Jul 2 10:50:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3wZ2qgzz9s2R for ; Mon, 2 Jul 2018 20:51:58 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EF093CAE; Mon, 2 Jul 2018 10:50:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 00B34CAD for ; Mon, 2 Jul 2018 10:50:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 887F5334 for ; Mon, 2 Jul 2018 10:50:35 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id b188-v6so8550522wme.3 for ; Mon, 02 Jul 2018 03:50:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=71PAZxKd7UdiuJQOV5CkNkevLAskxV7ZFzb9GIX+YmE=; b=Znme742Gov87yZnk/l9Dlp/Hv2Lu8/cAwfHTG68QGseP4rwCl7ggRjnrkFdzlg2Roi nuWk4Vt2xFb02+tYk+8uUTd+67eCACNCcVTO8SJrqeE9y1+/84QNSjEoABI2DK/1nc0q 6JB10TtX8pEenWloFMG8Wo+EFKOSvIvhPvAkUYFSPDqiDDutFb6y5AlY3YMrBMal7NvT AgP3F+6OU4ISyUt3dFZP/LD2DMyVrQ6Tz2Ng3A86cMCzn8Jnb0ucNvqW8GQ9IVKaX29+ Vn4xVR3TS2EOu5gI6LpBfYJW+KfXFR3dGy9TpQARYXTakERwTDuNQrFvviXwdbwm4rDB qyBQ== X-Gm-Message-State: APt69E2hg+3x9MQ4HlkOLK4c2AF00phLGjpuan3VuKx76v7jr4XKW1OC uoPqBY6VGUcb5d4xIY9gf4e9dYWWIbA= X-Google-Smtp-Source: AAOMgpdelHJMxZbu2i1GFRsKRN4gTmVvx63VRthngfLXOwjf8STNXG4exwoyQufABCTzhTX9vAWQYg== X-Received: by 2002:a1c:2807:: with SMTP id o7-v6mr7364290wmo.11.1530528633860; Mon, 02 Jul 2018 03:50:33 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id j131-v6sm8189134wmb.25.2018.07.02.03.50.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:33 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:00 +0200 Message-Id: <20180702105019.10345-5-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 04/23] db-ctl-base: Don't die in check_mutable() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index a826dfb94..7bcc08fe3 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -634,14 +634,17 @@ pre_parse_column_key_value(struct ctl_context *ctx, return column; } -static void +/* Checks if the 'column' is mutable. Returns NULL if it is mutable, or a + * malloc()'ed error message otherwise. */ +static char * OVS_WARN_UNUSED_RESULT check_mutable(const struct ovsdb_idl_row *row, const struct ovsdb_idl_column *column) { if (!ovsdb_idl_is_mutable(row, column)) { - ctl_fatal("cannot modify read-only column %s in table %s", - column->name, row->table->class_->name); + return xasprintf("cannot modify read-only column %s in table %s", + column->name, row->table->class_->name); } + return NULL; } #define RELOPS \ @@ -1210,7 +1213,7 @@ set_column(const struct ovsdb_idl_table_class *table, if (!value_string) { ctl_fatal("%s: missing value", arg); } - check_mutable(row, column); + die_if_error(check_mutable(row, column)); if (key_string) { union ovsdb_atom key, value; @@ -1316,7 +1319,7 @@ cmd_add(struct ctl_context *ctx) if (!row) { return; } - check_mutable(row, column); + die_if_error(check_mutable(row, column)); type = &column->type; ovsdb_datum_clone(&old, ovsdb_idl_read(row, column), &column->type); @@ -1377,7 +1380,7 @@ cmd_remove(struct ctl_context *ctx) if (!row) { return; } - check_mutable(row, column); + die_if_error(check_mutable(row, column)); type = &column->type; ovsdb_datum_clone(&old, ovsdb_idl_read(row, column), &column->type); @@ -1455,7 +1458,7 @@ cmd_clear(struct ctl_context *ctx) struct ovsdb_datum datum; die_if_error(get_column(table, ctx->argv[i], &column)); - check_mutable(row, column); + die_if_error(check_mutable(row, column)); type = &column->type; if (type->n_min > 0) { From patchwork Mon Jul 2 10:50:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3xL0qztz9s29 for ; Mon, 2 Jul 2018 20:52:38 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F010BCC6; Mon, 2 Jul 2018 10:50:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7DBF5CBE for ; Mon, 2 Jul 2018 10:50:37 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id BCFE1689 for ; Mon, 2 Jul 2018 10:50:36 +0000 (UTC) Received: by mail-wr0-f177.google.com with SMTP id t6-v6so2733008wrn.7 for ; Mon, 02 Jul 2018 03:50:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=f5cC0SLocBD97/jLNOwkZwhWBWYaPiELt/1wAzDx3ws=; b=MOmDbijdaMmWnLZSJbg0JMplF0QW4YlKfkFnyEM1ra3BapwcqZb/jXxhGGvgQOzB18 Yw/w25y4b5apH7DJxtwWnEbp4MumSpZACqSMP3eUxUzZXVY/fO7ZmMIDsYBeDPqr0FWW NIj4G6zFKIBZBFmYEIqrpZCS5incsBYJehEUpbTeAIrAj1lMrOgM0M0V1Ar3WcANzW59 iaJqfdD9nngomGJ62E3qWQ7SHvhIVtAf7WGnFfO/8EBdGuItUwl0D+qEyOo2Va76461+ 4Q47V926fASej9H56dnPWMrq2hxCjlOGdbUK0X/l/Wg2Gm7zd5bZdH/zIimmtK++oE+t caGg== X-Gm-Message-State: APt69E24fZRv0G1iFU/E2NllJI3BnVP1ii1I7dhPO9rW9tBuL8REPLws h47YvFvyWuxfQ3bHSZO4Ddogf9ueYp8= X-Google-Smtp-Source: AAOMgpeWHQH6hXl030ptgV7cVm9o0NDHzHAeNRlaa0meZBTiDWqD5yCmykIBqsKSGuWSUWjYZLQMaw== X-Received: by 2002:adf:8062:: with SMTP id 89-v6mr18080127wrk.221.1530528635166; Mon, 02 Jul 2018 03:50:35 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id m10-v6sm17504632wrq.56.2018.07.02.03.50.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:34 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:01 +0200 Message-Id: <20180702105019.10345-6-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 05/23] db-ctl-base: Don't die in set_column() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 61 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 7bcc08fe3..429612c2c 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -73,9 +73,9 @@ static size_t n_classes; static struct shash all_commands = SHASH_INITIALIZER(&all_commands); static char *get_table(const char *, const struct ovsdb_idl_table_class **); -static void set_column(const struct ovsdb_idl_table_class *, - const struct ovsdb_idl_row *, const char *, - struct ovsdb_symbol_table *); +static char *set_column(const struct ovsdb_idl_table_class *, + const struct ovsdb_idl_row *, const char *, + struct ovsdb_symbol_table *); static struct option * @@ -1197,37 +1197,52 @@ cmd_find(struct ctl_context *ctx) free(columns); } -/* Sets the column of 'row' in 'table'. */ -static void +/* Sets the column of 'row' in 'table'. Returns NULL on success or a + * malloc()'ed error message on failure. */ +static char * OVS_WARN_UNUSED_RESULT set_column(const struct ovsdb_idl_table_class *table, const struct ovsdb_idl_row *row, const char *arg, struct ovsdb_symbol_table *symtab) { const struct ovsdb_idl_column *column; - char *key_string, *value_string; + char *key_string = NULL; + char *value_string = NULL; char *error; error = parse_column_key_value(arg, table, &column, &key_string, NULL, NULL, 0, &value_string); - die_if_error(error); + if (error) { + goto out; + } if (!value_string) { - ctl_fatal("%s: missing value", arg); + error = xasprintf("%s: missing value", arg); + goto out; + } + error = check_mutable(row, column); + if (error) { + goto out; } - die_if_error(check_mutable(row, column)); if (key_string) { union ovsdb_atom key, value; struct ovsdb_datum datum; if (column->type.value.type == OVSDB_TYPE_VOID) { - ctl_fatal("cannot specify key to set for non-map column %s", - column->name); + error = xasprintf("cannot specify key to set for non-map column " + "%s", column->name); + goto out; } - die_if_error(ovsdb_atom_from_string(&key, NULL, &column->type.key, - key_string, symtab)); - die_if_error(ovsdb_atom_from_string(&value, NULL, &column->type.value, - value_string, symtab)); + error = ovsdb_atom_from_string(&key, NULL, &column->type.key, + key_string, symtab); + if (error) { + goto out; + } + error = ovsdb_atom_from_string(&value, NULL, &column->type.value, + value_string, symtab); + if (error) { + goto out; + } ovsdb_datum_init_empty(&datum); ovsdb_datum_add_unsafe(&datum, &key, &value, &column->type, NULL); @@ -1242,13 +1257,19 @@ set_column(const struct ovsdb_idl_table_class *table, } else { struct ovsdb_datum datum; - die_if_error(ovsdb_datum_from_string(&datum, &column->type, - value_string, symtab)); + error = ovsdb_datum_from_string(&datum, &column->type, + value_string, symtab); + if (error) { + goto out; + } ovsdb_idl_txn_write(row, column, &datum); } +out: free(key_string); free(value_string); + + return error; } static void @@ -1281,7 +1302,7 @@ cmd_set(struct ctl_context *ctx) } for (i = 3; i < ctx->argc; i++) { - set_column(table, row, ctx->argv[i], ctx->symtab); + die_if_error(set_column(table, row, ctx->argv[i], ctx->symtab)); } invalidate_cache(ctx); @@ -1514,7 +1535,7 @@ cmd_create(struct ctl_context *ctx) row = ovsdb_idl_txn_insert(ctx->txn, table, uuid); for (i = 2; i < ctx->argc; i++) { - set_column(table, row, ctx->argv[i], ctx->symtab); + die_if_error(set_column(table, row, ctx->argv[i], ctx->symtab)); } ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(&row->uuid)); } @@ -2354,5 +2375,5 @@ void ctl_set_column(const char *table_name, const struct ovsdb_idl_table_class *table; die_if_error(get_table(table_name, &table)); - set_column(table, row, arg, symtab); + die_if_error(set_column(table, row, arg, symtab)); } From patchwork Mon Jul 2 10:50:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3xw0vXnz9s3q for ; Mon, 2 Jul 2018 20:53:08 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AFC17CBF; Mon, 2 Jul 2018 10:50:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 038C7CC7 for ; Mon, 2 Jul 2018 10:50:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 75AC7689 for ; Mon, 2 Jul 2018 10:50:38 +0000 (UTC) Received: by mail-wr0-f179.google.com with SMTP id s11-v6so5806684wra.13 for ; Mon, 02 Jul 2018 03:50:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=wqpotnmXwBZg3NvxIppySHS70ioymu6A00uDR08djzc=; b=TG5sxNWhgbY4zdFVxHC/crolnXUoAM6KhUW50Evm2ecx8lWsku9YIV0DERcETmlatX KwAoWW7l4IHp4K5w99ZuQN/B50gIrUt1y9ryHSwgK6fbJGEjNw9air+XK4AdcVh+BJY8 SlXeAgHRxLvCctLmXDOHOpNOB0ONyJk61cLbiLdW6nD2BTdtBizZZJvBJsPhmphZzVZR dkLMe/sEsPbr1YhXwMllt1GPGY1dvOD7YPAZg1euB5W25HOCQjdtr7OQboZhRUJG44Qx B/puaLsNp1K0tofA7hflg1UwyH74MWQ9RzjUOsmXy0XKruFgyyZkcH1tHfpgwAd//4Hh VQ+A== X-Gm-Message-State: APt69E2XnKqNuspCs33+6ddPi+y/V9JenS5a24i01oCWgqoKq9vPjLm6 hLiTdIp+y8T8hHvIHvqhTes0YhW/LGQ= X-Google-Smtp-Source: AAOMgpcS07wQ+IQ8Wpeb07ovVJhZBP+CHbhdlJEPgqZ8hRmgRpxJK/jSR7XvAahvNDtTdsAc2TOTnA== X-Received: by 2002:adf:ce04:: with SMTP id p4-v6mr114313wrn.275.1530528636901; Mon, 02 Jul 2018 03:50:36 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id g75-v6sm9041025wmd.38.2018.07.02.03.50.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:36 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:02 +0200 Message-Id: <20180702105019.10345-7-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 06/23] db-ctl-base: Don't die in create_symbol() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 429612c2c..e8f66811a 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -222,13 +222,18 @@ score_partial_match(const char *name, const char *s) return *s == '\0' ? score : 0; } -static struct ovsdb_symbol * -create_symbol(struct ovsdb_symbol_table *symtab, const char *id, bool *newp) +/* Returns NULL and sets 'symbolp' and 'newp' if symbol was created + * successfully. Otherwise returns a malloc()'ed error message on failure. */ +static char * OVS_WARN_UNUSED_RESULT +create_symbol(struct ovsdb_symbol_table *symtab, const char *id, + struct ovsdb_symbol **symbolp, bool *newp) { struct ovsdb_symbol *symbol; + ovs_assert(symbolp); + if (id[0] != '@') { - ctl_fatal("row id \"%s\" does not begin with \"@\"", id); + return xasprintf("row id \"%s\" does not begin with \"@\"", id); } if (newp) { @@ -237,11 +242,12 @@ create_symbol(struct ovsdb_symbol_table *symtab, const char *id, bool *newp) symbol = ovsdb_symbol_table_insert(symtab, id); if (symbol->created) { - ctl_fatal("row id \"%s\" may only be specified on one --id option", - id); + return xasprintf("row id \"%s\" may only be specified on one --id " + "option", id); } symbol->created = true; - return symbol; + *symbolp = symbol; + return NULL; } static bool @@ -878,7 +884,7 @@ cmd_get(struct ctl_context *ctx) struct ovsdb_symbol *symbol; bool new; - symbol = create_symbol(ctx->symtab, id, &new); + die_if_error(create_symbol(ctx->symtab, id, &symbol, &new)); if (!new) { ctl_fatal("row id \"%s\" specified on \"get\" command was used " "before it was defined", id); @@ -1521,7 +1527,9 @@ cmd_create(struct ctl_context *ctx) die_if_error(get_table(table_name, &table)); if (id) { - struct ovsdb_symbol *symbol = create_symbol(ctx->symtab, id, NULL); + struct ovsdb_symbol *symbol; + + die_if_error(create_symbol(ctx->symtab, id, &symbol, NULL)); if (table->is_root) { /* This table is in the root set, meaning that rows created in it * won't disappear even if they are unreferenced, so disable From patchwork Mon Jul 2 10:50:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3yS5jC7z9s29 for ; Mon, 2 Jul 2018 20:53:36 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 84964CC2; Mon, 2 Jul 2018 10:50:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 541A3CBB for ; Mon, 2 Jul 2018 10:50:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CA23C334 for ; Mon, 2 Jul 2018 10:50:39 +0000 (UTC) Received: by mail-wr0-f172.google.com with SMTP id f18-v6so1335855wre.10 for ; Mon, 02 Jul 2018 03:50:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=a5dKBz4KU2bR4tovph3ro62nNneH7xab2fDlTgndOmU=; b=ak7zMnfCVF2g3M4naJxSe2PXWqaWYd79m52TdifXyHr9Rz55zoj73g2psINwd0ZQM9 4rtFW54JcT5Ua4GpZjtoB6SWGTqmG8dgCrtoV7O4FpgMTEiGTA1JIuhzt9+yhikScDa1 hRmWLLfjhtTW4uoS2jsVd1J1MoscrtU2ts5NKygx9mSe+WCxSokmYrCQblmuZqtij7Vm 36E/D0LjDxvIh8OBRubvT5oXb1hAqisPJeSecp0w9auQnqIjilVj2S9cBWaQnaF8W3ZI hGC2Uu7mOEb55dVdqT8dpKT1YlSGX+4AT3ZPUuyDH0sv28EjP9U4UH3bt6k39gjycgEf JBiQ== X-Gm-Message-State: APt69E0brvL7gN1Lmr3w25ft0uB7Zf/6MygefIL4fZGlvtelfTXAHibk /doff1pjUbJr4ZgJKyT+Xqq6ITiRIUY= X-Google-Smtp-Source: AAOMgpe+QofOtCJvfLamR50PpmdUY2Ctsxxw5+EHy4pzfLSKZM8OWJVAsjhkMp07ma1byAjBJzo0xw== X-Received: by 2002:adf:8e10:: with SMTP id n16-v6mr19721279wrb.100.1530528638252; Mon, 02 Jul 2018 03:50:38 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id z20-v6sm2239257wmz.19.2018.07.02.03.50.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:37 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:03 +0200 Message-Id: <20180702105019.10345-8-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 07/23] db-ctl-base: Don't die in get_row_by_id() on multiple matches. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signal that multiple rows match the record identifier via a new output parameter instead of reporting the problem and dying, so that the caller can handle the error without terminating the process if needed. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index e8f66811a..34daaef68 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -277,8 +277,11 @@ record_id_equals(const union ovsdb_atom *name, enum ovsdb_atomic_type type, static const struct ovsdb_idl_row * get_row_by_id(struct ctl_context *ctx, const struct ovsdb_idl_table_class *table, - const struct ctl_row_id *id, const char *record_id) + const struct ctl_row_id *id, const char *record_id, + bool *multiple_matches) { + ovs_assert(multiple_matches); + *multiple_matches = false; if (!id->name_column) { return NULL; @@ -336,8 +339,8 @@ get_row_by_id(struct ctl_context *ctx, /* If the name equals 'record_id', take it. */ if (record_id_equals(name, name_type, record_id)) { if (referrer) { - ctl_fatal("multiple rows in %s match \"%s\"", - id_table->name, record_id); + *multiple_matches = true; + return NULL; } referrer = row; } @@ -386,8 +389,18 @@ ctl_get_row(struct ctl_context *ctx, const struct ctl_table_class *ctl_class = &ctl_classes[table - idl_classes]; for (int i = 0; i < ARRAY_SIZE(ctl_class->row_ids); i++) { - row = get_row_by_id(ctx, table, &ctl_class->row_ids[i], - record_id); + const struct ctl_row_id *id = &ctl_class->row_ids[i]; + bool multiple_matches; + + row = get_row_by_id(ctx, table, id, record_id, &multiple_matches); + if (multiple_matches) { + const struct ovsdb_idl_class *class = + ovsdb_idl_get_class(ctx->idl); + const struct ovsdb_idl_table_class *table_class = + ovsdb_idl_table_class_from_column(class, id->name_column); + ctl_fatal("multiple rows in %s match \"%s\"", + table_class->name, record_id); + } if (row) { break; } From patchwork Mon Jul 2 10:50:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3z30M7lz9s29 for ; Mon, 2 Jul 2018 20:54:07 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 492A2CD4; Mon, 2 Jul 2018 10:50:49 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id BC713CC9 for ; Mon, 2 Jul 2018 10:50:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0BCA2334 for ; Mon, 2 Jul 2018 10:50:46 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id n17-v6so8229913wmh.2 for ; Mon, 02 Jul 2018 03:50:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=dk32jj5wy3TVf39eDrAR/2e+7v9Wuj7maRytJkTdUoA=; b=Gry+QAQKJ98GnO/aF7BnXg3/i2UbI95pEwpqnY7mqrZJvM+o/pjPOVmRXy+5bX+utF E8SdlvGbHkvHctahp38rkZkgOBVj5fL0fxIdLAxTugm3nMa7YRch0O9B8HRJnuTpsRwx XR+CiWkZUkfM81wA3SpuupPNrp7RTKVJkKg5qzxp9PfUYJu7Pez4o9UJfNTyyE2w8UqY h1gk/g/J2N6CHzAK/lL8b3seDJ6x9zrcZPIyovjSK90RcUEm0Ss6/DTvOxts5MKjoxyj odOt7GH/og0tHpfI6cEZirCQdrSIBFWtxzH9Y/CjtORWZOkyMN2s7mtcPLhq7Dz8VN5e wTZA== X-Gm-Message-State: APt69E29t4D637Y3sppN7RbAMCgDmJZO24O3adLx0LYonwgbVXE3OYTj WToyCLK+DqngsZ5YUngwBGWJCMouFt8= X-Google-Smtp-Source: AAOMgpcz9Oyd1nOOqvs5nmSGqpl4ObB4cuGqnlXIDfQ9r/NxyWGn+45noZWJpC1hps5aspb0uuQpQA== X-Received: by 2002:a1c:5982:: with SMTP id n124-v6mr7624445wmb.9.1530528645405; Mon, 02 Jul 2018 03:50:45 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id a124-v6sm7141562wmf.7.2018.07.02.03.50.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:44 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:04 +0200 Message-Id: <20180702105019.10345-9-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 08/23] db-ctl-base: Don't die in ctl_get_row() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 49 +++++++++++++++++++++++++++-------------------- lib/db-ctl-base.h | 7 +++---- ovn/utilities/ovn-sbctl.c | 11 ++++++++--- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 34daaef68..431db91c3 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -366,14 +366,16 @@ get_row_by_id(struct ctl_context *ctx, return final; } -const struct ovsdb_idl_row * +char * OVS_WARN_UNUSED_RESULT ctl_get_row(struct ctl_context *ctx, const struct ovsdb_idl_table_class *table, const char *record_id, - bool must_exist) + bool must_exist, const struct ovsdb_idl_row **rowp) { const struct ovsdb_idl_row *row = NULL; struct uuid uuid; + ovs_assert(rowp); + if (uuid_from_string(&uuid, record_id)) { row = ovsdb_idl_get_row_for_uuid(ctx->idl, table, &uuid); } @@ -398,8 +400,8 @@ ctl_get_row(struct ctl_context *ctx, ovsdb_idl_get_class(ctx->idl); const struct ovsdb_idl_table_class *table_class = ovsdb_idl_table_class_from_column(class, id->name_column); - ctl_fatal("multiple rows in %s match \"%s\"", - table_class->name, record_id); + return xasprintf("multiple rows in %s match \"%s\"", + table_class->name, record_id); } if (row) { break; @@ -415,19 +417,21 @@ ctl_get_row(struct ctl_context *ctx, if (!row) { row = r; } else { - ctl_fatal("%s contains 2 or more rows whose UUIDs begin " - "with %s: at least "UUID_FMT" and "UUID_FMT, - table->name, record_id, - UUID_ARGS(&row->uuid), - UUID_ARGS(&r->uuid)); + return xasprintf("%s contains 2 or more rows whose UUIDs " + "begin with %s: at least "UUID_FMT" " + "and "UUID_FMT, table->name, record_id, + UUID_ARGS(&row->uuid), + UUID_ARGS(&r->uuid)); } } } } if (must_exist && !row) { - ctl_fatal("no row \"%s\" in table %s", record_id, table->name); + return xasprintf("no row \"%s\" in table %s", record_id, table->name); } - return row; + + *rowp = row; + return NULL; } static char * @@ -888,7 +892,7 @@ cmd_get(struct ctl_context *ctx) } die_if_error(get_table(table_name, &table)); - row = ctl_get_row(ctx, table, record_id, must_exist); + die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); if (!row) { return; } @@ -1123,8 +1127,11 @@ cmd_list(struct ctl_context *ctx) out = ctx->table = list_make_table(columns, n_columns); if (ctx->argc > 2) { for (i = 2; i < ctx->argc; i++) { - list_record(ctl_get_row(ctx, table, ctx->argv[i], must_exist), - columns, n_columns, out); + const struct ovsdb_idl_row *row; + + die_if_error(ctl_get_row(ctx, table, ctx->argv[i], must_exist, + &row)); + list_record(row, columns, n_columns, out); } } else { const struct ovsdb_idl_row *row; @@ -1315,7 +1322,7 @@ cmd_set(struct ctl_context *ctx) int i; die_if_error(get_table(table_name, &table)); - row = ctl_get_row(ctx, table, record_id, must_exist); + die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); if (!row) { return; } @@ -1355,7 +1362,7 @@ cmd_add(struct ctl_context *ctx) die_if_error(get_table(table_name, &table)); die_if_error(get_column(table, column_name, &column)); - row = ctl_get_row(ctx, table, record_id, must_exist); + die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); if (!row) { return; } @@ -1416,7 +1423,7 @@ cmd_remove(struct ctl_context *ctx) die_if_error(get_table(table_name, &table)); die_if_error(get_column(table, column_name, &column)); - row = ctl_get_row(ctx, table, record_id, must_exist); + die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); if (!row) { return; } @@ -1487,7 +1494,7 @@ cmd_clear(struct ctl_context *ctx) int i; die_if_error(get_table(table_name, &table)); - row = ctl_get_row(ctx, table, record_id, must_exist); + die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); if (!row) { return; } @@ -1628,7 +1635,8 @@ cmd_destroy(struct ctl_context *ctx) for (i = 2; i < ctx->argc; i++) { const struct ovsdb_idl_row *row; - row = ctl_get_row(ctx, table, ctx->argv[i], must_exist); + die_if_error(ctl_get_row(ctx, table, ctx->argv[i], must_exist, + &row)); if (row) { ovsdb_idl_txn_delete(row); } @@ -1661,8 +1669,7 @@ cmd_wait_until(struct ctl_context *ctx) int i; die_if_error(get_table(table_name, &table)); - - row = ctl_get_row(ctx, table, record_id, false); + die_if_error(ctl_get_row(ctx, table, record_id, false, &row)); if (!row) { ctx->try_again = true; return; diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index 6aa3fe62d..5599666f2 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -272,10 +272,9 @@ struct ctl_table_class { struct ctl_row_id row_ids[4]; }; -const struct ovsdb_idl_row *ctl_get_row(struct ctl_context *, - const struct ovsdb_idl_table_class *, - const char *record_id, - bool must_exist); +char *ctl_get_row(struct ctl_context *, const struct ovsdb_idl_table_class *, + const char *record_id, bool must_exist, + const struct ovsdb_idl_row **); void ctl_set_column(const char *table_name, const struct ovsdb_idl_row *, const char *arg, diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index 085f7c5c0..0e2c67c08 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -842,9 +842,14 @@ cmd_lflow_list(struct ctl_context *ctx) { const struct sbrec_datapath_binding *datapath = NULL; if (ctx->argc > 1) { - datapath = (const struct sbrec_datapath_binding *) - ctl_get_row(ctx, &sbrec_table_datapath_binding, - ctx->argv[1], false); + const struct ovsdb_idl_row *row; + char *error = ctl_get_row(ctx, &sbrec_table_datapath_binding, + ctx->argv[1], false, &row); + if (error) { + ctl_fatal("%s", error); + } + + datapath = (const struct sbrec_datapath_binding *)row; if (datapath) { ctx->argc--; ctx->argv++; From patchwork Mon Jul 2 10:50:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K3zb5GSgz9s29 for ; Mon, 2 Jul 2018 20:54:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 05A63CCA; Mon, 2 Jul 2018 10:50:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D4AAFCD4 for ; Mon, 2 Jul 2018 10:50:48 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5A684334 for ; Mon, 2 Jul 2018 10:50:48 +0000 (UTC) Received: by mail-wr0-f179.google.com with SMTP id a12-v6so15060245wro.1 for ; Mon, 02 Jul 2018 03:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=F+LiAGX7f7Ni3y46EiQKuz/Zjp7ikYydT8DWQzBqbj4=; b=IlOP3OMixYqs6Idm/7jRfwXFKHw8NOe3/JIiEW07L3vEQ+SZXH34Pem/Rfejlde8EA HtOYRAaSvPZUeqS/T/g0p/FQZ40TtyHnjIFOFehT39jKK4Kz45U4wZXxaNChTNWKph2I Iy+PB56NOgppq6qaAPh7JXTxrthkemOcYmnbmYJFQx7zpL4MPoZ9LIQ5oSGsrZdfN458 goV0jrFhB6BIIgmFhGZ+X1slGnEdxuCRdZ4kwhdCe1jJGOycWH4LPYq8k7jfI9amxt8s ZqN6hSTr5e6AQFqbqbnvgpu63UyM7yNmnoM77HTZ4CC/1mwixc19QlyxzKYOAju42lCU xHKw== X-Gm-Message-State: APt69E2C5aiA8558PLTTZ3cw9vqoeMGOBIiDzSvH6ZLr6mNGo59HxUBE 4dPqHXsK7aFaN3EKsvpoAL95oqx9oJk= X-Google-Smtp-Source: AAOMgpePFMXdn7yOf8N0rSlBI2Y3vK/3Kt1ReE2Q+HC8QMTpBUWXoMqJucmw13GN+5KUdooWsyAVyw== X-Received: by 2002:adf:a6e2:: with SMTP id t89-v6mr9282240wrc.231.1530528646831; Mon, 02 Jul 2018 03:50:46 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id 185-v6sm17711506wmw.23.2018.07.02.03.50.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:46 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:05 +0200 Message-Id: <20180702105019.10345-10-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 09/23] db-ctl-base: Don't die in pre_get_column() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 431db91c3..e7785f7fb 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -465,14 +465,18 @@ get_column(const struct ovsdb_idl_table_class *table, const char *column_name, } } -static void +static char * OVS_WARN_UNUSED_RESULT pre_get_column(struct ctl_context *ctx, const struct ovsdb_idl_table_class *table, const char *column_name, const struct ovsdb_idl_column **columnp) { - die_if_error(get_column(table, column_name, columnp)); + char *error = get_column(table, column_name, columnp); + if (error) { + return error; + } ovsdb_idl_add_column(ctx->idl, *columnp); + return NULL; } static const struct ovsdb_idl_table_class * @@ -651,7 +655,7 @@ pre_parse_column_key_value(struct ctl_context *ctx, ctl_fatal("%s: missing column name", arg); } - pre_get_column(ctx, table, column_name, &column); + die_if_error(pre_get_column(ctx, table, column_name, &column)); free(column_name); return column; @@ -1343,7 +1347,7 @@ pre_cmd_add(struct ctl_context *ctx) const struct ovsdb_idl_column *column; table = pre_get_table(ctx, table_name); - pre_get_column(ctx, table, column_name, &column); + die_if_error(pre_get_column(ctx, table, column_name, &column)); } static void @@ -1404,7 +1408,7 @@ pre_cmd_remove(struct ctl_context *ctx) const struct ovsdb_idl_column *column; table = pre_get_table(ctx, table_name); - pre_get_column(ctx, table, column_name, &column); + die_if_error(pre_get_column(ctx, table, column_name, &column)); } static void @@ -1479,7 +1483,7 @@ pre_cmd_clear(struct ctl_context *ctx) for (i = 3; i < ctx->argc; i++) { const struct ovsdb_idl_column *column; - pre_get_column(ctx, table, ctx->argv[i], &column); + die_if_error(pre_get_column(ctx, table, ctx->argv[i], &column)); } } From patchwork Mon Jul 2 10:50:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K40Q56hBz9s29 for ; Mon, 2 Jul 2018 20:55:18 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E96ABCE8; Mon, 2 Jul 2018 10:50:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C5D3CCE4 for ; Mon, 2 Jul 2018 10:50:50 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 30B59334 for ; Mon, 2 Jul 2018 10:50:50 +0000 (UTC) Received: by mail-wr0-f174.google.com with SMTP id s11-v6so5807250wra.13 for ; Mon, 02 Jul 2018 03:50:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=mJ/1TtrReJs5mG679pqvinBeWxUtcOsciiLV0FHEaro=; b=iXMbt4W2u/gSo/mG1/FqC1DRS2gfXvinirS3D1/NAAdDqsENrQzX7m17NSQRZbJTWG S12Pwsu3/qytkjGeopZeh7LBFPirjrpNS5JSNuUOSzfomNx3ddo10VWT0LYyei84/NI2 Pj5Z2wozdu9aExszGL5I509NehRkrUagWGZ41Sa2YhNdGD5DHAvZr5sx6GTa0uC57rwP 6Oq3Oau3iYf6cizOddNK/khgTJMfDHhGcXjZBjYtq4OetnpPOb87bbilCxJTc2zQrUdD eU8hBHl0vV365TnM+t7DtNrfORdWtUQeNpx9+k0DUuwadeU3SNHJs8k/U2cvL9dL5v6K 9Rvg== X-Gm-Message-State: APt69E3l5LdI7CEPAWzRZahu0xeC9DUyHPsFI7SHXHVXPOh9gx+xEeBv H746Ys+GxpU7OtJn2o8LLBUBddcF9eA= X-Google-Smtp-Source: AAOMgpdh/BFIjIC1Bn/DWkQlfxEqbFEZSmAxhDN6+lCHIlt2vao15ycZw02t/QQZkrLjSo3abEyj8g== X-Received: by 2002:adf:c321:: with SMTP id n30-v6mr6570304wrf.235.1530528648624; Mon, 02 Jul 2018 03:50:48 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id b190-v6sm9686162wma.24.2018.07.02.03.50.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:48 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:06 +0200 Message-Id: <20180702105019.10345-11-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 10/23] db-ctl-base: Don't die in pre_get_table() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index e7785f7fb..90df25bda 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -479,11 +479,15 @@ pre_get_column(struct ctl_context *ctx, return NULL; } -static const struct ovsdb_idl_table_class * -pre_get_table(struct ctl_context *ctx, const char *table_name) +static char * OVS_WARN_UNUSED_RESULT +pre_get_table(struct ctl_context *ctx, const char *table_name, + const struct ovsdb_idl_table_class **tablep) { const struct ovsdb_idl_table_class *table; - die_if_error(get_table(table_name, &table)); + char *error = get_table(table_name, &table); + if (error) { + return error; + } ovsdb_idl_add_table(ctx->idl, table); const struct ctl_table_class *ctl = &ctl_classes[table - idl_classes]; @@ -497,7 +501,10 @@ pre_get_table(struct ctl_context *ctx, const char *table_name) } } - return table; + if (tablep) { + *tablep = table; + } + return NULL; } static char * @@ -868,7 +875,7 @@ pre_cmd_get(struct ctl_context *ctx) "possibly erroneous"); } - table = pre_get_table(ctx, table_name); + die_if_error(pre_get_table(ctx, table_name, &table)); for (i = 3; i < ctx->argc; i++) { if (!strcasecmp(ctx->argv[i], "_uuid") || !strcasecmp(ctx->argv[i], "-uuid")) { @@ -1054,7 +1061,7 @@ pre_cmd_list(struct ctl_context *ctx) const char *table_name = ctx->argv[1]; const struct ovsdb_idl_table_class *table; - table = pre_get_table(ctx, table_name); + die_if_error(pre_get_table(ctx, table_name, &table)); pre_list_columns(ctx, table, column_names); } @@ -1186,7 +1193,7 @@ pre_cmd_find(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - table = pre_get_table(ctx, table_name); + 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); @@ -1309,7 +1316,7 @@ pre_cmd_set(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - table = pre_get_table(ctx, table_name); + 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); } @@ -1346,7 +1353,7 @@ pre_cmd_add(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; const struct ovsdb_idl_column *column; - table = pre_get_table(ctx, table_name); + die_if_error(pre_get_table(ctx, table_name, &table)); die_if_error(pre_get_column(ctx, table, column_name, &column)); } @@ -1407,7 +1414,7 @@ pre_cmd_remove(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; const struct ovsdb_idl_column *column; - table = pre_get_table(ctx, table_name); + die_if_error(pre_get_table(ctx, table_name, &table)); die_if_error(pre_get_column(ctx, table, column_name, &column)); } @@ -1479,7 +1486,7 @@ pre_cmd_clear(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - table = pre_get_table(ctx, table_name); + die_if_error(pre_get_table(ctx, table_name, &table)); for (i = 3; i < ctx->argc; i++) { const struct ovsdb_idl_column *column; @@ -1603,7 +1610,7 @@ pre_cmd_destroy(struct ctl_context *ctx) { const char *table_name = ctx->argv[1]; - pre_get_table(ctx, table_name); + die_if_error(pre_get_table(ctx, table_name, NULL)); } static void @@ -1656,7 +1663,7 @@ pre_cmd_wait_until(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - table = pre_get_table(ctx, table_name); + 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); From patchwork Mon Jul 2 10:50:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K41208Hlz9s29 for ; Mon, 2 Jul 2018 20:55:49 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9ED02CE4; Mon, 2 Jul 2018 10:50:53 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 58C14CE4 for ; Mon, 2 Jul 2018 10:50:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C7255334 for ; Mon, 2 Jul 2018 10:50:51 +0000 (UTC) Received: by mail-wr0-f171.google.com with SMTP id q10-v6so324069wrd.4 for ; Mon, 02 Jul 2018 03:50:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=pi0+BYjBO5LNtf2HMtPMJTcKBYLwkWnz/svvqiyuy7s=; b=TJy85jrmOFK8sWYAwdLy4x8NzaIJFlSFB5lOcj9sI5EMNB1TcPUTTypEdK+NPL8CLq aE8rerDuy4dZFT7+p3cg8W+jQjVd5Y9mznLJoEp/6UQ6FKhRg9zfmnCHTLFruiU+zVME CDAl0czHat//HO05Ertm9X/H+6grnLMTfyU2Ij+CbUq19vYAbbECvjbRqw3oQl5DcSvE K7AIgSPMA5DebkpmhPLInZMrXvPuv8dAfzi0V/4Sl/St3XzE2wZqqe407tNv+eLN3Eul i2KYihU/L2Cb/rKQ9gmFkN6T6jobYhEZ/VaM+QsOoEIDhqeu8Uj0ztrAyOHdR2MtYEbo UIlA== X-Gm-Message-State: APt69E2RB1Sddedl9UkEhPiyVNn9QIN9JxIH3i+UbFJZO4WECqy85hXO qO5Nvcl2Jk2V49s2Mt8tglTJ29/aiFg= X-Google-Smtp-Source: AAOMgpfu6v4x7H11Vzmn1lTpD12F7HdMbHevhxLTA8ak0ZAMPcH8/HccTc0w+q8aaXowiaRK0d/e4A== X-Received: by 2002:adf:b05c:: with SMTP id g28-v6mr19038275wra.128.1530528650218; Mon, 02 Jul 2018 03:50:50 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id r14-v6sm22448875wrl.4.2018.07.02.03.50.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:49 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:07 +0200 Message-Id: <20180702105019.10345-12-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 11/23] db-ctl-base: Don't die in pre_parse_column_key_value() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- lib/db-ctl-base.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 90df25bda..a5c8b089b 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -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)); } } From patchwork Mon Jul 2 10:50:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K41f0mvbz9s3q for ; Mon, 2 Jul 2018 20:56:22 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6749CCBE; Mon, 2 Jul 2018 10:50:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D78F2CEA for ; Mon, 2 Jul 2018 10:50:53 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3B552691 for ; Mon, 2 Jul 2018 10:50:53 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id v16-v6so8534185wmv.5 for ; Mon, 02 Jul 2018 03:50:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rfloff8mfvRL6tc6XO1XDNvo7vS5zLfyFLfAF3vPvu0=; b=l59UONtQ+DVYv+UMcLum7E514VLsz022VeV8/O1I5PSMCjI+BcZzMPtssI/+EDEOKX +z0GAP8TUvPMBN278a+S5rqYIlbJvpVxWulfdxxmg2X8G+hrlAvd1eAFusLE3b7PKvyl ikOJzYGp51R+Q9x+RtluMNowr0WCgJ5lIpBNa3Fte6FKtUpnV3pJfXpeYVJBF4c0c7WB YuXqv0+Yict9ay9iz6uxpxAsWsjFBsQYZrUzixmDXHJjBrs4g1eMtEpG3MuckgKc49Pe nPYnflsJASbtT2kzMKA4XanECU7RMXUbeNBzdicL5qeg1UlIp4PkIgcFsKbiZQprjK37 M5lQ== X-Gm-Message-State: APt69E2WBXdnoACwaEOYZLvbYFSbD/HRWuI/on9KOOkQblceAEfGUMrS +VWxIL/J1DFHnEZRLXjdvuAUpuK9lpM= X-Google-Smtp-Source: AAOMgpfVmf2WfwqWaEcMM+SqR/aAeXGSpX66vNga5GdJJ25x8C9PvHAkeyWfU8FSGYbOoZ/MdEP9zg== X-Received: by 2002:a1c:d7c3:: with SMTP id o186-v6mr7599977wmg.67.1530528651748; Mon, 02 Jul 2018 03:50:51 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id z193-v6sm3248519wmc.14.2018.07.02.03.50.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:51 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:08 +0200 Message-Id: <20180702105019.10345-13-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 12/23] db-ctl-base: Don't die in pre_list_columns() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index a5c8b089b..d0590194b 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1041,7 +1041,7 @@ parse_column_names(const char *column_names, return NULL; } -static void +static char * OVS_WARN_UNUSED_RESULT pre_list_columns(struct ctl_context *ctx, const struct ovsdb_idl_table_class *table, const char *column_names) @@ -1049,14 +1049,19 @@ pre_list_columns(struct ctl_context *ctx, const struct ovsdb_idl_column **columns; size_t n_columns; size_t i; + char *error; - die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); + error = parse_column_names(column_names, table, &columns, &n_columns); + if (error) { + return error; + } for (i = 0; i < n_columns; i++) { if (columns[i]) { ovsdb_idl_add_column(ctx->idl, columns[i]); } } free(columns); + return NULL; } static void @@ -1067,7 +1072,7 @@ pre_cmd_list(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; die_if_error(pre_get_table(ctx, table_name, &table)); - pre_list_columns(ctx, table, column_names); + die_if_error(pre_list_columns(ctx, table, column_names)); } static struct table * @@ -1199,7 +1204,7 @@ pre_cmd_find(struct ctl_context *ctx) int i; die_if_error(pre_get_table(ctx, table_name, &table)); - pre_list_columns(ctx, table, column_names); + die_if_error(pre_list_columns(ctx, table, column_names)); for (i = 2; i < ctx->argc; i++) { die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table)); } From patchwork Mon Jul 2 10:50:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K42D0J4lz9s29 for ; Mon, 2 Jul 2018 20:56:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 27C1ACE6; Mon, 2 Jul 2018 10:50:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AC772CAD for ; Mon, 2 Jul 2018 10:50:55 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1FCD7334 for ; Mon, 2 Jul 2018 10:50:55 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id p11-v6so8184589wmc.4 for ; Mon, 02 Jul 2018 03:50:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=EoE51L56EAuugZ7sT1lN1qwV0pXccUgJXIVWagU1Yoc=; b=qO6MiKQ2binZ2nsmItf4Jndt8UZcgXZH4+kZJzVy7HNtv7uOYcED9T3gLPMY9Xp1qj 3fWCQESX5L3B99jCUPufkvByF0OISlx3rgtvaW8Aoa8JiZ6/lGTOuWN5uHgOybnbQ/Hi L3xZBBCh5brZo4U+PmScQrd+j711MEkdfdB24FvFQTCW6QyRlcQfkgeyo5zr7CmXiZDi 2qt8Dnpl2BfrBvR/6kbwNg3vwWxVMyu2oCVsZhMs/hUKAai5r8JS7ScsYLeroRuMPaPq 3+QGKbXuDyGo2Jp5fNvDvwkgCiCrPcLf5XqRLRTZ93B5tmKBiwjeJX16tL8aOzhQHjk+ 0l5g== X-Gm-Message-State: APt69E0tdY4s4eZtjcm9FK8wVfgS/2EQEnZBA7zi5VcP96+dLRgACYfV oM/6tzBhyfQjtDsInWAyVpptlaWasmI= X-Google-Smtp-Source: AAOMgpfKEao7GJIfhDry35B8rWRO/97OOMfc9FXuANG2l6hWg+WrXxxKhMPkCX6uMvtsfA3klfsGBA== X-Received: by 2002:a1c:588d:: with SMTP id m135-v6mr785892wmb.118.1530528653492; Mon, 02 Jul 2018 03:50:53 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id e13-v6sm8492787wrd.9.2018.07.02.03.50.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:52 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:09 +0200 Message-Id: <20180702105019.10345-14-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 13/23] db-ctl-base: Don't die in ctl_set_column() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 19 ++++++++++++++----- lib/db-ctl-base.h | 5 ++--- ovn/utilities/ovn-nbctl.c | 7 +++++-- utilities/ovs-vsctl.c | 7 +++++-- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index d0590194b..033011c15 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -2417,12 +2417,21 @@ ctl_context_done(struct ctl_context *ctx, invalidate_cache(ctx); } -void ctl_set_column(const char *table_name, - const struct ovsdb_idl_row *row, const char *arg, - struct ovsdb_symbol_table *symtab) +char * OVS_WARN_UNUSED_RESULT +ctl_set_column(const char *table_name, const struct ovsdb_idl_row *row, + const char *arg, struct ovsdb_symbol_table *symtab) { const struct ovsdb_idl_table_class *table; + char *error; - die_if_error(get_table(table_name, &table)); - die_if_error(set_column(table, row, arg, symtab)); + error = get_table(table_name, &table); + if (error) { + return error; + } + error = set_column(table, row, arg, symtab); + if (error) { + return error; + } + + return NULL; } diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index 5599666f2..8c6ac19a3 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -276,8 +276,7 @@ char *ctl_get_row(struct ctl_context *, const struct ovsdb_idl_table_class *, const char *record_id, bool must_exist, const struct ovsdb_idl_row **); -void ctl_set_column(const char *table_name, - const struct ovsdb_idl_row *, const char *arg, - struct ovsdb_symbol_table *); +char *ctl_set_column(const char *table_name, const struct ovsdb_idl_row *, + const char *arg, struct ovsdb_symbol_table *); #endif /* db-ctl-base.h */ diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 622f8a6a6..798f6bef4 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3279,8 +3279,11 @@ nbctl_lrp_add(struct ctl_context *ctx) nbrec_logical_router_port_set_networks(lrp, networks, n_networks); for (int i = 0; i < n_settings; i++) { - ctl_set_column("Logical_Router_Port", &lrp->header_, settings[i], - ctx->symtab); + char *error = ctl_set_column("Logical_Router_Port", &lrp->header_, + settings[i], ctx->symtab); + if (error) { + ctl_fatal("%s", error); + } } /* Insert the logical port into the logical router. */ diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index d3614cfbc..6a9637a20 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -1591,8 +1591,11 @@ add_port(struct ctl_context *ctx, } for (i = 0; i < n_settings; i++) { - ctl_set_column("Port", &port->header_, settings[i], - ctx->symtab); + char *error = ctl_set_column("Port", &port->header_, settings[i], + ctx->symtab); + if (error) { + ctl_fatal("%s", error); + } } bridge_insert_port((bridge->parent ? bridge->parent->br_cfg From patchwork Mon Jul 2 10:50:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937806 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K42j6ys6z9s29 for ; Mon, 2 Jul 2018 20:57:17 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CBFA9CFC; Mon, 2 Jul 2018 10:50:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 350C2CF5 for ; Mon, 2 Jul 2018 10:50:58 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6859D689 for ; Mon, 2 Jul 2018 10:50:57 +0000 (UTC) Received: by mail-wr0-f171.google.com with SMTP id q10-v6so324383wrd.4 for ; Mon, 02 Jul 2018 03:50:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=AoI5d3bsWk4SyVCmEn5Y9nnxReiB2/MmGusB8XpH/FA=; b=nz46+6AsoL+550/lau+krshdK+KHYgjKUXXniIVuY3O48zT+DZF3GLTvlBnUtx/Erg rWoKdD9KwQAIeeEGk716BL6j7nD2O7M31BX+CbJZ5TJhYLMWDZdJ9x2ueF7d8NCQHctQ Kx6MtKUvggP+iDYb7k/L6FWrrOBPCSKg2Zt9ocRdpUZtFeA5gHywExedJZ1koO8X/nWQ HwOiQR39aatKZKWZoxMG0Ae4RxsgwDPIlN9dfyDSMVB7NiLRWzs7IE2nEDjt0tnnPuQf 5XjrYFvu1qB6d0hu/syqzdUqS36kxyqIzrJNdnq/UhGqm3tMrKgJLBGJbL65va8ljaaA /kHg== X-Gm-Message-State: APt69E36oBqLbilToewEFhkqVdp+iRd5lTAUbOMgrFVXqLITUv9CF5f4 RzaqS4xusceCM3C+OfeLHAbd/t9uJdg= X-Google-Smtp-Source: AAOMgpeygaa2V0niYX2yYyF7kBo++ABajsTAgPpejucv7+1DJ7+UP59+vYM1UIO0fSoc925MOh9V4A== X-Received: by 2002:adf:f210:: with SMTP id p16-v6mr6914954wro.184.1530528655537; Mon, 02 Jul 2018 03:50:55 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id 14-v6sm7126281wmo.37.2018.07.02.03.50.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:54 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:10 +0200 Message-Id: <20180702105019.10345-15-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 14/23] db-ctl-base: Extend ctl_context with an error message. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Prepare for the command handlers (pre_cmd_*() cmd_*() functions) to report errors by storing them in the context. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 22 ++++++++++++++++++++++ lib/db-ctl-base.h | 3 +++ ovn/utilities/ovn-nbctl.c | 9 +++++++++ ovn/utilities/ovn-sbctl.c | 9 +++++++++ utilities/ovs-vsctl.c | 9 +++++++++ vtep/vtep-ctl.c | 9 +++++++++ 6 files changed, 61 insertions(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 033011c15..14cdff6eb 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -2191,6 +2191,25 @@ ctl_might_write_to_db(const struct ctl_command *commands, size_t n) return false; } +/* Report an error while running in the command context. Caller should return + * to its caller immediately after reporting the error. */ +void +ctl_error(struct ctl_context *ctx, const char *format, ...) +{ + va_list args; + + ovs_assert(ctx); + + if (ctx->error) { + VLOG_ERR("Discarding unhandled error: %s", ctx->error); + free(ctx->error); + } + + va_start(args, format); + ctx->error = xvasprintf(format, args); + va_end(args); +} + void ctl_fatal(const char *format, ...) { @@ -2376,6 +2395,7 @@ ctl_context_init_command(struct ctl_context *ctx, ds_swap(&ctx->output, &command->output); ctx->table = command->table; ctx->try_again = false; + ctx->error = NULL; } /* Initializes the entire 'ctx'. */ @@ -2401,6 +2421,8 @@ ctl_context_done_command(struct ctl_context *ctx, { ds_swap(&ctx->output, &command->output); command->table = ctx->table; + free(ctx->error); + ctx->error = NULL; } /* Finishes up with 'ctx'. diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index 8c6ac19a3..5d325d8e7 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -59,6 +59,8 @@ void ctl_init__(const struct ovsdb_idl_class *, const struct ctl_table_class *, const struct cmd_show_table *cmd_show_tables, void (*ctl_exit_func)(int status)); char *ctl_default_db(void); +void ctl_error(struct ctl_context *, const char *, ...) +OVS_PRINTF_FORMAT(2, 3); OVS_NO_RETURN void ctl_fatal(const char *, ...) OVS_PRINTF_FORMAT(1, 2); /* *ctl command syntax structure, to be defined by each command implementation. @@ -225,6 +227,7 @@ struct ctl_context { struct shash options; /* Modifiable state. */ + char *error; struct ds output; struct table *table; struct ovsdb_idl *idl; diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 798f6bef4..63d41660b 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -3788,6 +3788,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, ctl_context_init(&ctx, c, idl, NULL, NULL, NULL); (c->syntax->prerequisites)(&ctx); + if (ctx.error) { + ctl_fatal("%s", ctx.error); + } ctl_context_done(&ctx, c); ovs_assert(!c->output.string); @@ -3837,6 +3840,9 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->syntax->run) { (c->syntax->run)(&ctx); } + if (ctx.error) { + ctl_fatal("%s", error); + } ctl_context_done_command(&ctx, c); if (ctx.try_again) { @@ -3875,6 +3881,9 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->syntax->postprocess) { ctl_context_init(&ctx, c, idl, txn, symtab, NULL); (c->syntax->postprocess)(&ctx); + if (ctx.error) { + ctl_fatal("%s", ctx.error); + } ctl_context_done(&ctx, c); } } diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index 0e2c67c08..441b2dac6 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -1238,6 +1238,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, sbctl_context_init(&sbctl_ctx, c, idl, NULL, NULL); (c->syntax->prerequisites)(&sbctl_ctx.base); + if (sbctl_ctx.base.error) { + ctl_fatal("%s", sbctl_ctx.base.error); + } sbctl_context_done(&sbctl_ctx, c); ovs_assert(!c->output.string); @@ -1281,6 +1284,9 @@ do_sbctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->syntax->run) { (c->syntax->run)(&sbctl_ctx.base); } + if (sbctl_ctx.base.error) { + ctl_fatal("%s", sbctl_ctx.base.error); + } sbctl_context_done_command(&sbctl_ctx, c); if (sbctl_ctx.base.try_again) { @@ -1316,6 +1322,9 @@ do_sbctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->syntax->postprocess) { sbctl_context_init(&sbctl_ctx, c, idl, txn, symtab); (c->syntax->postprocess)(&sbctl_ctx.base); + if (sbctl_ctx.base.error) { + ctl_fatal("%s", sbctl_ctx.base.error); + } sbctl_context_done(&sbctl_ctx, c); } } diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 6a9637a20..e845634c2 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -2527,6 +2527,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, vsctl_context_init(&vsctl_ctx, c, idl, NULL, NULL, NULL); (c->syntax->prerequisites)(&vsctl_ctx.base); + if (vsctl_ctx.base.error) { + ctl_fatal("%s", vsctl_ctx.base.error); + } vsctl_context_done(&vsctl_ctx, c); ovs_assert(!c->output.string); @@ -2621,6 +2624,9 @@ do_vsctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->syntax->run) { (c->syntax->run)(&vsctl_ctx.base); } + if (vsctl_ctx.base.error) { + ctl_fatal("%s", vsctl_ctx.base.error); + } vsctl_context_done_command(&vsctl_ctx, c); if (vsctl_ctx.base.try_again) { @@ -2659,6 +2665,9 @@ do_vsctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->syntax->postprocess) { vsctl_context_init(&vsctl_ctx, c, idl, txn, ovs, symtab); (c->syntax->postprocess)(&vsctl_ctx.base); + if (vsctl_ctx.base.error) { + ctl_fatal("%s", vsctl_ctx.base.error); + } vsctl_context_done(&vsctl_ctx, c); } } diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 678323fae..e0d5121a3 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -2260,6 +2260,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, vtep_ctl_context_init(&vtepctl_ctx, c, idl, NULL, NULL, NULL); (c->syntax->prerequisites)(&vtepctl_ctx.base); + if (vtepctl_ctx.base.error) { + ctl_fatal("%s", vtepctl_ctx.base.error); + } vtep_ctl_context_done(&vtepctl_ctx, c); ovs_assert(!c->output.string); @@ -2304,6 +2307,9 @@ do_vtep_ctl(const char *args, struct ctl_command *commands, if (c->syntax->run) { (c->syntax->run)(&vtepctl_ctx.base); } + if (vtepctl_ctx.base.error) { + ctl_fatal("%s", vtepctl_ctx.base.error); + } vtep_ctl_context_done_command(&vtepctl_ctx, c); if (vtepctl_ctx.base.try_again) { @@ -2339,6 +2345,9 @@ do_vtep_ctl(const char *args, struct ctl_command *commands, if (c->syntax->postprocess) { vtep_ctl_context_init(&vtepctl_ctx, c, idl, txn, vtep_global, symtab); (c->syntax->postprocess)(&vtepctl_ctx.base); + if (vtepctl_ctx.base.error) { + ctl_fatal("%s", vtepctl_ctx.base.error); + } vtep_ctl_context_done(&vtepctl_ctx, c); } } From patchwork Mon Jul 2 10:50:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K43Q2Vw9z9s29 for ; Mon, 2 Jul 2018 20:57:54 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B20F6CFB; Mon, 2 Jul 2018 10:51:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 660F4D05 for ; Mon, 2 Jul 2018 10:51:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D1F5B674 for ; Mon, 2 Jul 2018 10:50:58 +0000 (UTC) Received: by mail-wr0-f173.google.com with SMTP id k7-v6so11553379wrq.0 for ; Mon, 02 Jul 2018 03:50:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=cL3hLyd243stK86Xz0mb+LqmLERLaARbFP/8F+MSBIw=; b=pSoCO1LFWSYQlsSjeAHVORUKXvNo0+X8gHumQm34OR0bQNH1vjuX/vLBOXAQpavSd6 GSUg1XEG1OSsm0m9GuPruAi60ekbdV5SnER96bEZuRjwRaYUP7znDjKAN0vXTORWZ2t1 C4Myc8HVwbvE88XWPaXkN85D7w/oXhtuz20XEQk7UPosRUZAu9Fvcic68rXpkllPA2au prl3EDaRQQiFZ5QKfIofNB97e0fi0jEzyf15R3WyWMdI0k3L5Iy+BiEJkJeIXDsw79x/ iRJIGDsfWPRlA06vnLThVPDyfNQuyCVb/RaUPPP0pW1xVtS1p1wGe2MwjSYUsKlJribY Vl2g== X-Gm-Message-State: APt69E15dKOkfmPLSy55d5fTqsSEUU9VTfWsiMk4BWB5/NoTdVPAEreA Mn+BvdjAe5yB1dqe/17K4gC4i/8gP+s= X-Google-Smtp-Source: AAOMgpevDVSwFmRevdkt/cHSHjtgHI1IjLYCCO3v/4NU2uetEE7svHRu9/yczzBxkG/aTLn5ho+A3Q== X-Received: by 2002:adf:8610:: with SMTP id 16-v6mr18737866wrv.255.1530528657112; Mon, 02 Jul 2018 03:50:57 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id n5-v6sm8906426wrp.69.2018.07.02.03.50.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:56 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:11 +0200 Message-Id: <20180702105019.10345-16-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 15/23] db-ctl-base: Stop using die_if_error(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Propagate the error via the context for the caller to handle it. Result of applying the following semantic patch (Coccinelle): @@ expression s; @@ - die_if_error(s); + ctx->error = s; + if (ctx->error) { + return; + } Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 294 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 229 insertions(+), 65 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 14cdff6eb..2fff7127b 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -880,14 +880,20 @@ pre_cmd_get(struct ctl_context *ctx) "possibly erroneous"); } - die_if_error(pre_get_table(ctx, table_name, &table)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } for (i = 3; i < ctx->argc; i++) { if (!strcasecmp(ctx->argv[i], "_uuid") || !strcasecmp(ctx->argv[i], "-uuid")) { continue; } - die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table)); + ctx->error = pre_parse_column_key_value(ctx, ctx->argv[i], table); + if (ctx->error) { + return; + } } } @@ -907,8 +913,14 @@ cmd_get(struct ctl_context *ctx) ctl_fatal("--if-exists and --id may not be specified together"); } - die_if_error(get_table(table_name, &table)); - die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = ctl_get_row(ctx, table, record_id, must_exist, &row); + if (ctx->error) { + return; + } if (!row) { return; } @@ -917,7 +929,10 @@ cmd_get(struct ctl_context *ctx) struct ovsdb_symbol *symbol; bool new; - die_if_error(create_symbol(ctx->symtab, id, &symbol, &new)); + ctx->error = create_symbol(ctx->symtab, id, &symbol, &new); + if (ctx->error) { + return; + } if (!new) { ctl_fatal("row id \"%s\" specified on \"get\" command was used " "before it was defined", id); @@ -942,9 +957,11 @@ cmd_get(struct ctl_context *ctx) continue; } - die_if_error(parse_column_key_value(ctx->argv[i], table, - &column, &key_string, - NULL, NULL, 0, NULL)); + ctx->error = parse_column_key_value(ctx->argv[i], table, &column, + &key_string, NULL, NULL, 0, NULL); + if (ctx->error) { + return; + } ovsdb_idl_txn_verify(row, column); datum = ovsdb_idl_read(row, column); @@ -957,9 +974,11 @@ cmd_get(struct ctl_context *ctx) column->name); } - die_if_error(ovsdb_atom_from_string(&key, NULL, - &column->type.key, - key_string, ctx->symtab)); + ctx->error = ovsdb_atom_from_string(&key, NULL, &column->type.key, + key_string, ctx->symtab); + if (ctx->error) { + return; + } idx = ovsdb_datum_find_key(datum, &key, column->type.key.type); @@ -1071,8 +1090,14 @@ pre_cmd_list(struct ctl_context *ctx) const char *table_name = ctx->argv[1]; const struct ovsdb_idl_table_class *table; - die_if_error(pre_get_table(ctx, table_name, &table)); - die_if_error(pre_list_columns(ctx, table, column_names)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } + ctx->error = pre_list_columns(ctx, table, column_names); + if (ctx->error) { + return; + } } static struct table * @@ -1143,15 +1168,24 @@ cmd_list(struct ctl_context *ctx) size_t n_columns; int i; - die_if_error(get_table(table_name, &table)); - die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = parse_column_names(column_names, table, &columns, &n_columns); + if (ctx->error) { + return; + } out = ctx->table = list_make_table(columns, n_columns); if (ctx->argc > 2) { for (i = 2; i < ctx->argc; i++) { const struct ovsdb_idl_row *row; - die_if_error(ctl_get_row(ctx, table, ctx->argv[i], must_exist, - &row)); + ctx->error = ctl_get_row(ctx, table, ctx->argv[i], must_exist, + &row); + if (ctx->error) { + return; + } list_record(row, columns, n_columns, out); } } else { @@ -1203,10 +1237,19 @@ pre_cmd_find(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - die_if_error(pre_get_table(ctx, table_name, &table)); - die_if_error(pre_list_columns(ctx, table, column_names)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } + ctx->error = pre_list_columns(ctx, table, column_names); + if (ctx->error) { + return; + } for (i = 2; i < ctx->argc; i++) { - die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table)); + ctx->error = pre_parse_column_key_value(ctx, ctx->argv[i], table); + if (ctx->error) { + return; + } } } @@ -1221,8 +1264,14 @@ cmd_find(struct ctl_context *ctx) struct table *out; size_t n_columns; - die_if_error(get_table(table_name, &table)); - die_if_error(parse_column_names(column_names, table, &columns, &n_columns)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = parse_column_names(column_names, table, &columns, &n_columns); + if (ctx->error) { + return; + } out = ctx->table = list_make_table(columns, n_columns); for (row = ovsdb_idl_first_row(ctx->idl, table); row; row = ovsdb_idl_next_row(row)) { @@ -1231,8 +1280,11 @@ cmd_find(struct ctl_context *ctx) for (i = 2; i < ctx->argc; i++) { bool satisfied; - die_if_error(check_condition(table, row, ctx->argv[i], ctx->symtab, - &satisfied)); + ctx->error = check_condition(table, row, ctx->argv[i], + ctx->symtab, &satisfied); + if (ctx->error) { + return; + } if (!satisfied) { goto next_row; } @@ -1326,9 +1378,15 @@ pre_cmd_set(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - die_if_error(pre_get_table(ctx, table_name, &table)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } for (i = 3; i < ctx->argc; i++) { - die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table)); + ctx->error = pre_parse_column_key_value(ctx, ctx->argv[i], table); + if (ctx->error) { + return; + } } } @@ -1342,14 +1400,23 @@ cmd_set(struct ctl_context *ctx) const struct ovsdb_idl_row *row; int i; - die_if_error(get_table(table_name, &table)); - die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = ctl_get_row(ctx, table, record_id, must_exist, &row); + if (ctx->error) { + return; + } if (!row) { return; } for (i = 3; i < ctx->argc; i++) { - die_if_error(set_column(table, row, ctx->argv[i], ctx->symtab)); + ctx->error = set_column(table, row, ctx->argv[i], ctx->symtab); + if (ctx->error) { + return; + } } invalidate_cache(ctx); @@ -1363,8 +1430,14 @@ pre_cmd_add(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; const struct ovsdb_idl_column *column; - die_if_error(pre_get_table(ctx, table_name, &table)); - die_if_error(pre_get_column(ctx, table, column_name, &column)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } + ctx->error = pre_get_column(ctx, table, column_name, &column); + if (ctx->error) { + return; + } } static void @@ -1381,13 +1454,25 @@ cmd_add(struct ctl_context *ctx) struct ovsdb_datum old; int i; - die_if_error(get_table(table_name, &table)); - die_if_error(get_column(table, column_name, &column)); - die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = get_column(table, column_name, &column); + if (ctx->error) { + return; + } + ctx->error = ctl_get_row(ctx, table, record_id, must_exist, &row); + if (ctx->error) { + return; + } if (!row) { return; } - die_if_error(check_mutable(row, column)); + ctx->error = check_mutable(row, column); + if (ctx->error) { + return; + } type = &column->type; ovsdb_datum_clone(&old, ovsdb_idl_read(row, column), &column->type); @@ -1398,8 +1483,11 @@ cmd_add(struct ctl_context *ctx) add_type = *type; add_type.n_min = 1; add_type.n_max = UINT_MAX; - die_if_error(ovsdb_datum_from_string(&add, &add_type, ctx->argv[i], - ctx->symtab)); + ctx->error = ovsdb_datum_from_string(&add, &add_type, ctx->argv[i], + ctx->symtab); + if (ctx->error) { + return; + } ovsdb_datum_union(&old, &add, type, false); ovsdb_datum_destroy(&add, type); } @@ -1424,8 +1512,14 @@ pre_cmd_remove(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; const struct ovsdb_idl_column *column; - die_if_error(pre_get_table(ctx, table_name, &table)); - die_if_error(pre_get_column(ctx, table, column_name, &column)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } + ctx->error = pre_get_column(ctx, table, column_name, &column); + if (ctx->error) { + return; + } } static void @@ -1442,13 +1536,25 @@ cmd_remove(struct ctl_context *ctx) struct ovsdb_datum old; int i; - die_if_error(get_table(table_name, &table)); - die_if_error(get_column(table, column_name, &column)); - die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = get_column(table, column_name, &column); + if (ctx->error) { + return; + } + ctx->error = ctl_get_row(ctx, table, record_id, must_exist, &row); + if (ctx->error) { + return; + } if (!row) { return; } - die_if_error(check_mutable(row, column)); + ctx->error = check_mutable(row, column); + if (ctx->error) { + return; + } type = &column->type; ovsdb_datum_clone(&old, ovsdb_idl_read(row, column), &column->type); @@ -1467,8 +1573,12 @@ cmd_remove(struct ctl_context *ctx) if (ovsdb_type_is_map(&rm_type)) { rm_type.value.type = OVSDB_TYPE_VOID; free(error); - die_if_error(ovsdb_datum_from_string( - &rm, &rm_type, ctx->argv[i], ctx->symtab)); + ctx->error = ovsdb_datum_from_string(&rm, &rm_type, + ctx->argv[i], + ctx->symtab); + if (ctx->error) { + return; + } } else { ctl_fatal("%s", error); } @@ -1496,11 +1606,17 @@ pre_cmd_clear(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - die_if_error(pre_get_table(ctx, table_name, &table)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } for (i = 3; i < ctx->argc; i++) { const struct ovsdb_idl_column *column; - die_if_error(pre_get_column(ctx, table, ctx->argv[i], &column)); + ctx->error = pre_get_column(ctx, table, ctx->argv[i], &column); + if (ctx->error) { + return; + } } } @@ -1514,8 +1630,14 @@ cmd_clear(struct ctl_context *ctx) const struct ovsdb_idl_row *row; int i; - die_if_error(get_table(table_name, &table)); - die_if_error(ctl_get_row(ctx, table, record_id, must_exist, &row)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = ctl_get_row(ctx, table, record_id, must_exist, &row); + if (ctx->error) { + return; + } if (!row) { return; } @@ -1525,8 +1647,14 @@ cmd_clear(struct ctl_context *ctx) const struct ovsdb_type *type; struct ovsdb_datum datum; - die_if_error(get_column(table, ctx->argv[i], &column)); - die_if_error(check_mutable(row, column)); + ctx->error = get_column(table, ctx->argv[i], &column); + if (ctx->error) { + return; + } + ctx->error = check_mutable(row, column); + if (ctx->error) { + return; + } type = &column->type; if (type->n_min > 0) { @@ -1549,7 +1677,10 @@ pre_create(struct ctl_context *ctx) const char *table_name = ctx->argv[1]; const struct ovsdb_idl_table_class *table; - die_if_error(get_table(table_name, &table)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } if (!id && !table->is_root) { VLOG_WARN("applying \"create\" command to table %s without --id " "option will have no effect", table->name); @@ -1566,11 +1697,17 @@ cmd_create(struct ctl_context *ctx) const struct uuid *uuid; int i; - die_if_error(get_table(table_name, &table)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } if (id) { struct ovsdb_symbol *symbol; - die_if_error(create_symbol(ctx->symtab, id, &symbol, NULL)); + ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL); + if (ctx->error) { + return; + } if (table->is_root) { /* This table is in the root set, meaning that rows created in it * won't disappear even if they are unreferenced, so disable @@ -1584,7 +1721,10 @@ cmd_create(struct ctl_context *ctx) row = ovsdb_idl_txn_insert(ctx->txn, table, uuid); for (i = 2; i < ctx->argc; i++) { - die_if_error(set_column(table, row, ctx->argv[i], ctx->symtab)); + ctx->error = set_column(table, row, ctx->argv[i], ctx->symtab); + if (ctx->error) { + return; + } } ds_put_format(&ctx->output, UUID_FMT, UUID_ARGS(&row->uuid)); } @@ -1620,7 +1760,10 @@ pre_cmd_destroy(struct ctl_context *ctx) { const char *table_name = ctx->argv[1]; - die_if_error(pre_get_table(ctx, table_name, NULL)); + ctx->error = pre_get_table(ctx, table_name, NULL); + if (ctx->error) { + return; + } } static void @@ -1632,7 +1775,10 @@ cmd_destroy(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - die_if_error(get_table(table_name, &table)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } if (delete_all && ctx->argc > 2) { ctl_fatal("--all and records argument should not be specified together"); @@ -1656,8 +1802,11 @@ cmd_destroy(struct ctl_context *ctx) for (i = 2; i < ctx->argc; i++) { const struct ovsdb_idl_row *row; - die_if_error(ctl_get_row(ctx, table, ctx->argv[i], must_exist, - &row)); + ctx->error = ctl_get_row(ctx, table, ctx->argv[i], must_exist, + &row); + if (ctx->error) { + return; + } if (row) { ovsdb_idl_txn_delete(row); } @@ -1673,10 +1822,16 @@ pre_cmd_wait_until(struct ctl_context *ctx) const struct ovsdb_idl_table_class *table; int i; - die_if_error(pre_get_table(ctx, table_name, &table)); + ctx->error = pre_get_table(ctx, table_name, &table); + if (ctx->error) { + return; + } for (i = 3; i < ctx->argc; i++) { - die_if_error(pre_parse_column_key_value(ctx, ctx->argv[i], table)); + ctx->error = pre_parse_column_key_value(ctx, ctx->argv[i], table); + if (ctx->error) { + return; + } } } @@ -1689,8 +1844,14 @@ cmd_wait_until(struct ctl_context *ctx) const struct ovsdb_idl_row *row; int i; - die_if_error(get_table(table_name, &table)); - die_if_error(ctl_get_row(ctx, table, record_id, false, &row)); + ctx->error = get_table(table_name, &table); + if (ctx->error) { + return; + } + ctx->error = ctl_get_row(ctx, table, record_id, false, &row); + if (ctx->error) { + return; + } if (!row) { ctx->try_again = true; return; @@ -1699,8 +1860,11 @@ cmd_wait_until(struct ctl_context *ctx) for (i = 3; i < ctx->argc; i++) { bool satisfied; - die_if_error(check_condition(table, row, ctx->argv[i], ctx->symtab, - &satisfied)); + ctx->error = check_condition(table, row, ctx->argv[i], ctx->symtab, + &satisfied); + if (ctx->error) { + return; + } if (!satisfied) { ctx->try_again = true; return; From patchwork Mon Jul 2 10:50:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K43w65xTz9s29 for ; Mon, 2 Jul 2018 20:58:20 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 74D50D10; Mon, 2 Jul 2018 10:51:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AC17CCF8 for ; Mon, 2 Jul 2018 10:51:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 43116334 for ; Mon, 2 Jul 2018 10:51:00 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id a12-v6so15060868wro.1 for ; Mon, 02 Jul 2018 03:51:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=irbaDXyS9pyLGXK+JG+o07Q22qNTwbF2p2S7nEWwLN8=; b=t8/WhFbcACc1Z/Kadp9qLG4QfO8JUOjWgm5moX9L/DbjrI2PQQvjgdCDzrlsitqbBZ tAZYpjBiSOLJ1pvCIfY5BBOuJJn2on+gAg3OXS4J45HA9pbuc9FjGmIcPLhGXXfDHcnj RRLWy8q2K1hGH78fK/phJ4vvgd8bauKWRfdsNaIZMxGh+xR178a3j7a65ulbd+C/1KGN qy0EorbDuJfVHvGS239RwtB3QUZTdzFD2cnKgJXq82je8wIk5tKTS0M8w0lKacmd+fYY snDxOjLbCmZbMlxOQXphu3iaLLirnBEzxqRPeFGdrX7FF604SDHe2XDhtZ7uoJG3eAEe /FZw== X-Gm-Message-State: APt69E0Ba4K/KEhTnHnjJAzOBYljdvegxyl1tLaMAD/L8EXJ1t0LQCyn K7oPVerpVJmorW3RTp4+4KGTwy0+Rgc= X-Google-Smtp-Source: AAOMgpf1nyW0lsZ0qFsZMBfM3Hm0SyPP17U/EHIKNWq6EYFaD7tvyZuD7gBWyLlcIcGqsg0YLihxfQ== X-Received: by 2002:adf:a285:: with SMTP id s5-v6mr18593756wra.114.1530528658722; Mon, 02 Jul 2018 03:50:58 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id u13-v6sm7428438wri.72.2018.07.02.03.50.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:58 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:12 +0200 Message-Id: <20180702105019.10345-17-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 16/23] db-ctl-base: Fix resource deallocation on error path in cmd_get(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Release resources now that we are returning to the caller on error. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 2fff7127b..8d4799433 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -977,6 +977,7 @@ cmd_get(struct ctl_context *ctx) ctx->error = ovsdb_atom_from_string(&key, NULL, &column->type.key, key_string, ctx->symtab); if (ctx->error) { + free(key_string); return; } From patchwork Mon Jul 2 10:50:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K44P1617z9s29 for ; Mon, 2 Jul 2018 20:58:45 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 25ED3D16; Mon, 2 Jul 2018 10:51:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 53F2DCEA for ; Mon, 2 Jul 2018 10:51:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D2E7E334 for ; Mon, 2 Jul 2018 10:51:01 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id b188-v6so8552160wme.3 for ; Mon, 02 Jul 2018 03:51:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5jdCK2Ln9R19tlMyCIzWrNOB2xTpHtVRl489MTphu+A=; b=dOO9z2tLY6t8fidAHjlui9Z+PRvSQ8owXfPej3W2SVTt6tbzgm1O1c+XHKmW1bbAvh twOjnREcVdkROq40Yu2WA5i6upjhxc/SRBEZTkLj33gA578Ci8xL+usamGONoSvBi7RP TurXw7h/g/V6jqRWPQrf9OUIft8YKhebA+GVnQIMZIubaIMnEks/PTHzroiaUrO1LZvd E4LtdqneWQPeGY/Voc0yQQyyAtvpeD/UKqor46a1Y6jQQ/1elws5Z0pt6a5+LIG090wG apsK3ZWiZBShzU9h/yiXGfGEg5icOdrobDE+7/xNqgF0UrmmatP8KO6FQ0ZeCnyLtMXI 2XZA== X-Gm-Message-State: APt69E0gwqCets38EUAmd8o2y1qVoMG5lNeXEIx008CVrzBsWg4avJqb OJqPyFCjlMnSvRlzK3vxEhXhAi4FFFY= X-Google-Smtp-Source: AAOMgpdmxAFQ+z8yuefS4/4mrVMMfx7f1e6rSXX3fqZy4ORJmJuMby0WNphj4dPzYMJqZa6VsGYcNw== X-Received: by 2002:a1c:8692:: with SMTP id i140-v6mr7995137wmd.11.1530528660343; Mon, 02 Jul 2018 03:51:00 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id 130-v6sm20454274wmr.1.2018.07.02.03.50.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:50:59 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:13 +0200 Message-Id: <20180702105019.10345-18-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 17/23] db-ctl-base: Fix resource deallocation on error path in cmd_list(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Release resources now that we are returning to the caller on error. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 8d4799433..5f386cab5 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1185,6 +1185,7 @@ cmd_list(struct ctl_context *ctx) ctx->error = ctl_get_row(ctx, table, ctx->argv[i], must_exist, &row); if (ctx->error) { + free(columns); return; } list_record(row, columns, n_columns, out); From patchwork Mon Jul 2 10:50:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K44s2H2kz9s29 for ; Mon, 2 Jul 2018 20:59:09 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DA1C0D14; Mon, 2 Jul 2018 10:51:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 250DED15 for ; Mon, 2 Jul 2018 10:51:04 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B2100334 for ; Mon, 2 Jul 2018 10:51:03 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id q10-v6so324679wrd.4 for ; Mon, 02 Jul 2018 03:51:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=oSRFp1j3rpRryBObQ9u5PVwZMR95oTIvX9Dv753gx1M=; b=Opeh7ZPat9WA0xgbsVpaUZjNMxJcu7exTQ3zY3Vy9rK080+cKpkbkH0tsfyIHO8AeX CMZlr/pv1NU5ocATqEPCSt0wttAJhIAJTnkDHQnXazBYz7UBiHvEE2jNwRnTVhv/l4Aw 6MVhSkxI7cLFxg+IaQSX+FsZv2BqZkBn9jIbPqMGCAcoqglFqR5lk4ZC1EPNuxCrr5vc jQ4KTo4WU02FaCKBkPb1LcDZFnFL9/V+t+YldMKLD2kiWowAkEYtRnL2wHonj4MN486R zL2xzFjwrIlv0pr7FEDMkRW0DsKkGdPY4BIJXAxwmab6KrJxl3OFqB3aQqnnKdsbns7+ CwAw== X-Gm-Message-State: APt69E1roTeqQ0UHA3Uxvq7b7LhBLHNW7Mlxz5UdMBnlvvytWlfCadId rcu14Uooa7aayG27dQ9zPKhWoxIPZmQ= X-Google-Smtp-Source: AAOMgpcN91zqsy3nr7XhIG8d0HWQmmNIPRczaXXlIzBMiSJQyJpQMnLUWlFjRsjmkCJDcxaqAjrPhQ== X-Received: by 2002:adf:b05c:: with SMTP id g28-v6mr19038756wra.128.1530528662134; Mon, 02 Jul 2018 03:51:02 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id r14-v6sm22449543wrl.4.2018.07.02.03.51.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:51:01 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:14 +0200 Message-Id: <20180702105019.10345-19-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 18/23] db-ctl-base: Fix resource deallocation on error path in cmd_find(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Release resources now that we are returning to the caller on error. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 5f386cab5..d3ca4ca70 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1285,6 +1285,7 @@ cmd_find(struct ctl_context *ctx) ctx->error = check_condition(table, row, ctx->argv[i], ctx->symtab, &satisfied); if (ctx->error) { + free(columns); return; } if (!satisfied) { From patchwork Mon Jul 2 10:50:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K45S5N34z9s29 for ; Mon, 2 Jul 2018 20:59:40 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D8913D1A; Mon, 2 Jul 2018 10:51:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AF1D6D23 for ; Mon, 2 Jul 2018 10:51:05 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 36EEB334 for ; Mon, 2 Jul 2018 10:51:05 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id b188-v6so8552373wme.3 for ; Mon, 02 Jul 2018 03:51:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ReXv62bVHF7f69LKYUfwwMSgt9zoeeaM/uExkOp1pVo=; b=LexX1TqivNWke+Mgk7uG7bbOmU4CT+mz9WGx3UwsEqKin+AKsofqHl/j2it3ILnTWP KJw/Y90RlDdYvFzBDtOv88R9QU260h5Qq3U4R8Y2qRBjBl8G2qgTq0EcmtNepQQMyACy IdeOaMZ8BYCzGl9hE+B8GqyvLNUybOGWxg0a9QdIoO2A4q0MC2zdkzs6rLdcv5WN6YQz r2/z10fnoP2UciL5LkpDQVoZoImQyrTZ8FJj4KeURGtrRo36NVs70fO9vWwoWWFaBNpB VnIm9/T2mDDxookk57d5wMerFocZVHGQaM/FT04N4C+P2vNi+dmoMtRDCBrepQWLivJQ qCIA== X-Gm-Message-State: APt69E3j1xqXfQ9ShbroF3/m6iuuSrtmQ8IQNrtnvIBmKwLw7XOZFPoA bZKyGH7Iu+x/aSnRP7dC785N0wM+ufg= X-Google-Smtp-Source: AAOMgpcUzdGzLL27C/MTtzoLJ4ezuSXZXX5UYG12XGqToJcFL3OWZG/B7qd5iQJVIbdokVlw60d45g== X-Received: by 2002:a1c:ec1b:: with SMTP id k27-v6mr5679477wmh.157.1530528663709; Mon, 02 Jul 2018 03:51:03 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id 189-v6sm8994012wmd.17.2018.07.02.03.51.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:51:03 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:15 +0200 Message-Id: <20180702105019.10345-20-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 19/23] db-ctl-base: Kill die_if_error() helper. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org All users are gone. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index d3ca4ca70..c670236da 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -186,14 +186,6 @@ print_command_arguments(const struct ctl_command_syntax *command) free(output); } -static void -die_if_error(char *error) -{ - if (error) { - ctl_fatal("%s", error); - } -} - static int to_lower_and_underscores(unsigned c) { From patchwork Mon Jul 2 10:50:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K45x6d7xz9s2R for ; Mon, 2 Jul 2018 21:00:05 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 83FB4D32; Mon, 2 Jul 2018 10:51:09 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E48D5D23 for ; Mon, 2 Jul 2018 10:51:07 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 66493334 for ; Mon, 2 Jul 2018 10:51:07 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id b188-v6so8552524wme.3 for ; Mon, 02 Jul 2018 03:51:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=FE6Ge4mfO3xDQNMWNFA5b3hCp7lFTdoQBILKBZ/KzyE=; b=MaB7zlxi4jN63WRvlbCIlC5kroF++pmUo+FBWxQfNdeR0TZWisBXrJ2cgWPpKTnXUQ H5FyVgSRQXlEDurl5AglHx0jTA5WIwt62O0BDqweBr/Vh5dkpLMoCoAcnymR84gqJQvP cI7Mwz+oXrOsYpRArZmTuPdg+0JBRRpAVHu3dMzmmoQrQN3afETCIjBUwu1xcB4iDwLX vSWtO7SOXglyszRrNbrpFVCMeynSS9m2gjmI9SVh2s8ikL6qKig1d/cAYgymTloD9V+5 fc6m3O0xs05uvU6jctZW7BiAuLyAdgymhG8R1vp5iY1GMC4Q1He+IDvUsxeSnGMWpE/n Br7g== X-Gm-Message-State: APt69E3x1kYUCNYbOSdWJukbbcpBJdAL64AUzgAhiCHsu9uvIOvkw1H+ aHVDlwa2/cYKqvUq1tnxaTJ23HnvecM= X-Google-Smtp-Source: AAOMgpf6Usu108dqEfFQDydFOJCeIXUXT7yL0QZxluOgwghOj4u7r/98c59rnWTxdD/KV0Ih/5+vLw== X-Received: by 2002:a1c:ed0d:: with SMTP id l13-v6mr8122337wmh.73.1530528665290; Mon, 02 Jul 2018 03:51:05 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id w2-v6sm12626884wme.45.2018.07.02.03.51.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:51:04 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:16 +0200 Message-Id: <20180702105019.10345-21-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 20/23] db-ctl-base: Don't die in cmd_get() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Return the error via the context instead of calling ctl_fatal() so that the caller can decide how to handle it. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index c670236da..7c1e10373 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -902,7 +902,8 @@ cmd_get(struct ctl_context *ctx) int i; if (id && !must_exist) { - ctl_fatal("--if-exists and --id may not be specified together"); + ctl_error(ctx, "--if-exists and --id may not be specified together"); + return; } ctx->error = get_table(table_name, &table); @@ -926,8 +927,9 @@ cmd_get(struct ctl_context *ctx) return; } if (!new) { - ctl_fatal("row id \"%s\" specified on \"get\" command was used " - "before it was defined", id); + ctl_error(ctx, "row id \"%s\" specified on \"get\" command was " + "used before it was defined", id); + return; } symbol->uuid = row->uuid; @@ -962,8 +964,11 @@ cmd_get(struct ctl_context *ctx) unsigned int idx; if (column->type.value.type == OVSDB_TYPE_VOID) { - ctl_fatal("cannot specify key to get for non-map column %s", + ctl_error(ctx, + "cannot specify key to get for non-map column %s", column->name); + free(key_string); + return; } ctx->error = ovsdb_atom_from_string(&key, NULL, &column->type.key, @@ -977,9 +982,11 @@ cmd_get(struct ctl_context *ctx) column->type.key.type); if (idx == UINT_MAX) { if (must_exist) { - ctl_fatal("no key \"%s\" in %s record \"%s\" column %s", - key_string, table->name, record_id, - column->name); + ctl_error( + ctx, "no key \"%s\" in %s record \"%s\" column %s", + key_string, table->name, record_id, column->name); + free(key_string); + return; } } else { ovsdb_atom_to_string(&datum->values[idx], From patchwork Mon Jul 2 10:50:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K46R650fz9s29 for ; Mon, 2 Jul 2018 21:00:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 53683D30; Mon, 2 Jul 2018 10:51:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id EEB8AD23 for ; Mon, 2 Jul 2018 10:51:08 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7F8B1689 for ; Mon, 2 Jul 2018 10:51:08 +0000 (UTC) Received: by mail-wr0-f182.google.com with SMTP id p12-v6so15038353wrn.11 for ; Mon, 02 Jul 2018 03:51:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=t+VKk78GHLiHEv0XqyYYQD1d4wulIrDJ4CZxdAb3S9g=; b=G68yvueZ+xY1bz8hVO9SQ616N41HOnh5bgow+0b+2RVNYoINpR25AoPYOZjiLMIqB2 1C8CfJ8WcT3E2iZhuzQnK/bFhS0uuIOw7vLZE4BSjjvgkKIIsMXbRvMoaR2IeqhnVI1b klnOZUjGumOKE7aD4TnByEmBIr3JShV3aKnmxd+XCJweQEYCP+0eYjGKzBjA5Vlim7JO b4Luz4kJTFxx7F3vw0/4TVbt8k18VH8ETQ7ED5hdl6e87PUJSTHsZT5C9Cc3LDVHR2at PMIf6vUCu3hGkx2ek/vLRaIawdp/yPrVqj6Yw/dInDdv+qjxi8UAf5fmbQobDBROU3pX hzGA== X-Gm-Message-State: APt69E2DuxsVLLCT2HQ7oarNlX/mwF5FPGaQwyFjRvtOrM+DYQQZG2+4 Sykc+a3+ZxUMmr4+iMUkP45HOA057f8= X-Google-Smtp-Source: AAOMgpepvd0TkEcJK9GbbEzS3aHZsD1cdz+VfDhDU3V2BtiDQG/+Q+A2dc0qqSFLUozXbRbOMhA5Jg== X-Received: by 2002:a5d:6841:: with SMTP id o1-v6mr6093180wrw.159.1530528666969; Mon, 02 Jul 2018 03:51:06 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id z9-v6sm8332661wre.49.2018.07.02.03.51.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:51:06 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:17 +0200 Message-Id: <20180702105019.10345-22-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 21/23] db-ctl-base: Don't die in cmd_remove() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Return the error via the context instead of calling ctl_fatal() so that the caller can decide how to handle it. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 7c1e10373..585cf67a0 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1582,18 +1582,19 @@ cmd_remove(struct ctl_context *ctx) return; } } else { - ctl_fatal("%s", error); + ctx->error = error; + return; } } ovsdb_datum_subtract(&old, type, &rm, &rm_type); ovsdb_datum_destroy(&rm, &rm_type); } if (old.n < type->n_min) { - ctl_fatal("\"remove\" operation would put %u %s in column %s of " - "table %s but the minimum number is %u", - old.n, + ctl_error(ctx, "\"remove\" operation would put %u %s in column %s of " + "table %s but the minimum number is %u", old.n, type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs", column->name, table->name, type->n_min); + return; } ovsdb_idl_txn_verify(row, column); ovsdb_idl_txn_write(row, column, &old); From patchwork Mon Jul 2 10:50:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K475177pz9s29 for ; Mon, 2 Jul 2018 21:01:04 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EB3F7D3E; Mon, 2 Jul 2018 10:51:16 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9E4A2D36 for ; Mon, 2 Jul 2018 10:51:15 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0053F691 for ; Mon, 2 Jul 2018 10:51:14 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id k7-v6so11554196wrq.0 for ; Mon, 02 Jul 2018 03:51:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=DG24iJq1k+KT3Q9wRM3PqtdRfuielTPAWe24qyG61qI=; b=sXdbK+2CkoT01D5urNmlOjHpwNWuM3OendrbyuV1dIVkAYykOUFkNw9Gbk0Y2i8hnF uxG5BDbCE1R3mwJdm7aFQFi8hPpIfhsHZNbrrVMEEHdZLJ2rkAdQ4NDZElaFux3dFrD/ Ao5R8B4t8/u0Stm849eaS9UYJm2O6Wl7FA8l/A3ry4QwVqGnSSrcjKs5N5djh+SikjMY PdOB7iR7cqK456W5FGwR3gxbZwvT/dJLWSq874vqE3662OrBKPWFs2g5UEpHb0+Ts7sJ cIH631Lvd8BdpRzkkSc4wUtqjTUnAXQ/2YgpVSnq2uLd/R1zIbLDwafsc6h4hXLdLM1s PNow== X-Gm-Message-State: APt69E0i3iC3lNU8jbUFt34IJd3Ah4/ZKt5GkO0kZhhlvkm9Bwvm9JLP bsu9z+CYq+rbYtQ5iT1tbWqEwG7Inrg= X-Google-Smtp-Source: AAOMgpeF8D9s6qTeSaaf773MvnjZ0CW1mYr8t6QUAnJFA0MbSGHX9zXZEvOsC/QuZc+HxoXsugOD6w== X-Received: by 2002:adf:dd8e:: with SMTP id x14-v6mr16286662wrl.212.1530528673451; Mon, 02 Jul 2018 03:51:13 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id n16-v6sm4893263wrg.58.2018.07.02.03.51.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:51:12 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:18 +0200 Message-Id: <20180702105019.10345-23-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 22/23] db-ctl-base: Don't die in cmd_clear() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Return the error via the context instead of calling ctl_fatal() so that the caller can decide how to handle it. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 585cf67a0..f5492aadb 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1661,9 +1661,10 @@ cmd_clear(struct ctl_context *ctx) type = &column->type; if (type->n_min > 0) { - ctl_fatal("\"clear\" operation cannot be applied to column %s " - "of table %s, which is not allowed to be empty", + ctl_error(ctx, "\"clear\" operation cannot be applied to column " + "%s of table %s, which is not allowed to be empty", column->name, table->name); + return; } ovsdb_datum_init_empty(&datum); From patchwork Mon Jul 2 10:50:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 937816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K47c5Sjfz9s2R for ; Mon, 2 Jul 2018 21:01:32 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9AC41D39; Mon, 2 Jul 2018 10:51:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C8312D23 for ; Mon, 2 Jul 2018 10:51:16 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4B575674 for ; Mon, 2 Jul 2018 10:51:16 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id v16-v6so8535671wmv.5 for ; Mon, 02 Jul 2018 03:51:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SydivZa2X1bAQF4NFD6/ldPGpJNpY3BmuoPEsLpB10k=; b=id/UXyLGDwxCwaomSALsYZSorFc6ccfR50wdXomRZsTUuYJYbSYzyjupvx8RH6qyn0 t0vGYI1PjtBpO/mhVrU4+ZK97mMm3NaZDmp/nS7rV85rheiQ2AgaO26nqgUiKmL//z8f qeLjvV1AoTVW6gjQasVWkXcRv58gFEpJExM4ZUdVaRm+4HVg3bmwNqmaRnjeIenObbeQ wQjMnh67sJjRhj7DLRScB/e/j/GTnBC+x+wiENr0sl6ohsZ359J+1ExoQ53gPWwEb2XT hAfdpCmJDqaK2PxXcODGW/0EfwxWRjZGDvGuFXnqt3V7Lh9mH2R5j/pFEf//dzvfp3sF yG1A== X-Gm-Message-State: APt69E3O5X0r2Zmk3lAj1/GL+fV0fhKThzUPscBW/LriKtks7rqMUe8j jDMVbiOrPbqAQ1KKM6/U4peNnquF4C8= X-Google-Smtp-Source: AAOMgpee5bhXjyOmvmmw6etmwT+nplFYYa6O0XXCTWgCCGS1g8bt3LHX9AgnlGyu5jUqxIYQcMj8Pw== X-Received: by 2002:a1c:f46:: with SMTP id 67-v6mr5234134wmp.122.1530528674752; Mon, 02 Jul 2018 03:51:14 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id r10-v6sm17564281wrm.66.2018.07.02.03.51.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 03:51:14 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Mon, 2 Jul 2018 12:50:19 +0200 Message-Id: <20180702105019.10345-24-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180702105019.10345-1-jkbs@redhat.com> References: <20180702105019.10345-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 23/23] db-ctl-base: Don't die in cmd_destroy() on error. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Return the error via the context instead of calling ctl_fatal() so that the caller can decide how to handle it. Signed-off-by: Jakub Sitnicki --- lib/db-ctl-base.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index f5492aadb..bfec8257a 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1785,11 +1785,15 @@ cmd_destroy(struct ctl_context *ctx) } if (delete_all && ctx->argc > 2) { - ctl_fatal("--all and records argument should not be specified together"); + ctl_error(ctx, "--all and records argument should not be specified " + "together"); + return; } if (delete_all && !must_exist) { - ctl_fatal("--all and --if-exists should not be specified together"); + ctl_error(ctx, "--all and --if-exists should not be specified " + "together"); + return; } if (delete_all) {