{"id":815881,"url":"http://patchwork.ozlabs.org/api/patches/815881/?format=json","web_url":"http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-15-blp@ovn.org/","project":{"id":47,"url":"http://patchwork.ozlabs.org/api/projects/47/?format=json","name":"Open vSwitch","link_name":"openvswitch","list_id":"ovs-dev.openvswitch.org","list_email":"ovs-dev@openvswitch.org","web_url":"http://openvswitch.org/","scm_url":"git@github.com:openvswitch/ovs.git","webscm_url":"https://github.com/openvswitch/ovs","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170919220125.32535-15-blp@ovn.org>","list_archive_url":null,"date":"2017-09-19T22:00:47","name":"[ovs-dev,RFC,14/52] ovsdb-error: New function ovsdb_error_to_string_free().","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"8098835abed06496acc0a7915123bdb7bc705d45","submitter":{"id":67603,"url":"http://patchwork.ozlabs.org/api/people/67603/?format=json","name":"Ben Pfaff","email":"blp@ovn.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-15-blp@ovn.org/mbox/","series":[{"id":3975,"url":"http://patchwork.ozlabs.org/api/series/3975/?format=json","web_url":"http://patchwork.ozlabs.org/project/openvswitch/list/?series=3975","date":"2017-09-19T22:00:34","name":"clustering implementation","version":1,"mbox":"http://patchwork.ozlabs.org/series/3975/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815881/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815881/checks/","tags":{},"related":[],"headers":{"Return-Path":"<ovs-dev-bounces@openvswitch.org>","X-Original-To":["incoming@patchwork.ozlabs.org","dev@openvswitch.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","ovs-dev@mail.linuxfoundation.org"],"Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)","Received":["from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxcXS2T12z9sMN\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 08:11:20 +1000 (AEST)","from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 13E16CAF;\n\tTue, 19 Sep 2017 22:02:02 +0000 (UTC)","from smtp2.linuxfoundation.org (smtp2.linux-foundation.org\n\t[172.17.192.36])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id EF1D7A55\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:01:57 +0000 (UTC)","from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby smtp2.linuxfoundation.org (Postfix) with ESMTPS id 5E2661DC96\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:01:56 +0000 (UTC)","from sigabrt.benpfaff.org (unknown [208.91.2.3])\n\t(Authenticated sender: blp@ovn.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 0086717209C;\n\tWed, 20 Sep 2017 00:01:53 +0200 (CEST)"],"X-Greylist":"domain auto-whitelisted by SQLgrey-1.7.6","X-Originating-IP":"208.91.2.3","From":"Ben Pfaff <blp@ovn.org>","To":"dev@openvswitch.org","Date":"Tue, 19 Sep 2017 15:00:47 -0700","Message-Id":"<20170919220125.32535-15-blp@ovn.org>","X-Mailer":"git-send-email 2.10.2","In-Reply-To":"<20170919220125.32535-1-blp@ovn.org>","References":"<20170919220125.32535-1-blp@ovn.org>","X-Spam-Status":"No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW\n\tautolearn=ham version=3.3.1","X-Spam-Checker-Version":"SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp2.linux-foundation.org","Cc":"Ben Pfaff <blp@ovn.org>","Subject":"[ovs-dev] [PATCH RFC 14/52] ovsdb-error: New function\n\tovsdb_error_to_string_free().","X-BeenThere":"ovs-dev@openvswitch.org","X-Mailman-Version":"2.1.12","Precedence":"list","List-Id":"<ovs-dev.openvswitch.org>","List-Unsubscribe":"<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>","List-Archive":"<http://mail.openvswitch.org/pipermail/ovs-dev/>","List-Post":"<mailto:ovs-dev@openvswitch.org>","List-Help":"<mailto:ovs-dev-request@openvswitch.org?subject=help>","List-Subscribe":"<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"ovs-dev-bounces@openvswitch.org","Errors-To":"ovs-dev-bounces@openvswitch.org"},"content":"Signed-off-by: Ben Pfaff <blp@ovn.org>\n---\n lib/ovsdb-data.c     |  5 ++---\n lib/ovsdb-error.c    | 21 +++++++++++++++------\n lib/ovsdb-error.h    |  3 ++-\n lib/ovsdb-idl.c      |  9 +++------\n ovsdb/file.c         |  7 ++-----\n ovsdb/ovsdb-server.c |  6 ++----\n tests/test-ovsdb.c   | 18 ++++++------------\n 7 files changed, 32 insertions(+), 37 deletions(-)","diff":"diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c\nindex 840e18fa1824..af386b3ce480 100644\n--- a/lib/ovsdb-data.c\n+++ b/lib/ovsdb-data.c\n@@ -1,4 +1,4 @@\n-/* Copyright (c) 2009, 2010, 2011, 2012, 2014, 2016 Nicira, Inc.\n+/* Copyright (c) 2009, 2010, 2011, 2012, 2014, 2016, 2017 Nicira, Inc.\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\");\n  * you may not use this file except in compliance with the License.\n@@ -664,8 +664,7 @@ ovsdb_atom_from_string(union ovsdb_atom *atom,\n             free(*range_end_atom);\n             *range_end_atom = NULL;\n         }\n-        msg = ovsdb_error_to_string(error);\n-        ovsdb_error_destroy(error);\n+        msg = ovsdb_error_to_string_free(error);\n     }\n     return msg;\n }\ndiff --git a/lib/ovsdb-error.c b/lib/ovsdb-error.c\nindex d8161e6d7b9a..82dc10966e99 100644\n--- a/lib/ovsdb-error.c\n+++ b/lib/ovsdb-error.c\n@@ -1,4 +1,4 @@\n-/* Copyright (c) 2009, 2010, 2011, 2012, 2016 Nicira, Inc.\n+/* Copyright (c) 2009, 2010, 2011, 2012, 2016, 2017 Nicira, Inc.\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\");\n  * you may not use this file except in compliance with the License.\n@@ -153,11 +153,9 @@ ovsdb_internal_error(struct ovsdb_error *inner_error,\n     ds_put_format(&ds, \" (%s %s)\", program_name, VERSION);\n \n     if (inner_error) {\n-        char *s = ovsdb_error_to_string(inner_error);\n+        char *s = ovsdb_error_to_string_free(inner_error);\n         ds_put_format(&ds, \" (generated from: %s)\", s);\n         free(s);\n-\n-        ovsdb_error_destroy(inner_error);\n     }\n \n     error = ovsdb_error(\"internal error\", \"%s\", ds_cstr(&ds));\n@@ -240,6 +238,18 @@ ovsdb_error_to_string(const struct ovsdb_error *error)\n     return ds_steal_cstr(&ds);\n }\n \n+char *\n+ovsdb_error_to_string_free(struct ovsdb_error *error)\n+{\n+    if (error) {\n+        char *s = ovsdb_error_to_string(error);\n+        ovsdb_error_destroy(error);\n+        return s;\n+    } else {\n+        return NULL;\n+    }\n+}\n+\n const char *\n ovsdb_error_get_tag(const struct ovsdb_error *error)\n {\n@@ -254,9 +264,8 @@ ovsdb_error_assert(struct ovsdb_error *error)\n {\n     if (error) {\n         static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);\n-        char *s = ovsdb_error_to_string(error);\n+        char *s = ovsdb_error_to_string_free(error);\n         VLOG_ERR_RL(&rl, \"unexpected ovsdb error: %s\", s);\n         free(s);\n-        ovsdb_error_destroy(error);\n     }\n }\ndiff --git a/lib/ovsdb-error.h b/lib/ovsdb-error.h\nindex da91b74999d1..ff9b889a8687 100644\n--- a/lib/ovsdb-error.h\n+++ b/lib/ovsdb-error.h\n@@ -1,4 +1,4 @@\n-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.\n+/* Copyright (c) 2009, 2010, 2011, 2016, 2017 Nicira, Inc.\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\");\n  * you may not use this file except in compliance with the License.\n@@ -64,6 +64,7 @@ struct ovsdb_error *ovsdb_error_clone(const struct ovsdb_error *)\n     OVS_WARN_UNUSED_RESULT;\n \n char *ovsdb_error_to_string(const struct ovsdb_error *);\n+char *ovsdb_error_to_string_free(struct ovsdb_error *);\n struct json *ovsdb_error_to_json(const struct ovsdb_error *);\n \n const char *ovsdb_error_get_tag(const struct ovsdb_error *);\ndiff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c\nindex af1821bfff9c..62a6c3898227 100644\n--- a/lib/ovsdb-idl.c\n+++ b/lib/ovsdb-idl.c\n@@ -1431,10 +1431,9 @@ ovsdb_idl_send_schema_request(struct ovsdb_idl *idl)\n static void\n log_error(struct ovsdb_error *error)\n {\n-    char *s = ovsdb_error_to_string(error);\n+    char *s = ovsdb_error_to_string_free(error);\n     VLOG_WARN(\"error parsing database schema: %s\", s);\n     free(s);\n-    ovsdb_error_destroy(error);\n }\n \n /* Frees 'schema', which is in the format returned by parse_schema(). */\n@@ -1954,12 +1953,11 @@ ovsdb_idl_row_change__(struct ovsdb_idl_row *row, const struct json *row_json,\n \n             ovsdb_datum_destroy(&datum, &column->type);\n         } else {\n-            char *s = ovsdb_error_to_string(error);\n+            char *s = ovsdb_error_to_string_free(error);\n             VLOG_WARN_RL(&syntax_rl, \"error parsing column %s in row \"UUID_FMT\n                          \" in table %s: %s\", column_name,\n                          UUID_ARGS(&row->uuid), table->class_->name, s);\n             free(s);\n-            ovsdb_error_destroy(error);\n         }\n     }\n     return changed;\n@@ -4123,11 +4121,10 @@ ovsdb_idl_txn_process_insert_reply(struct ovsdb_idl_txn_insert *insert,\n \n     error = ovsdb_atom_from_json(&uuid, &uuid_type, json_uuid, NULL);\n     if (error) {\n-        char *s = ovsdb_error_to_string(error);\n+        char *s = ovsdb_error_to_string_free(error);\n         VLOG_WARN_RL(&syntax_rl, \"\\\"insert\\\" reply \\\"uuid\\\" is not a JSON \"\n                      \"UUID: %s\", s);\n         free(s);\n-        ovsdb_error_destroy(error);\n         return false;\n     }\n \ndiff --git a/ovsdb/file.c b/ovsdb/file.c\nindex 16461a75bfe5..1668220bc9a2 100644\n--- a/ovsdb/file.c\n+++ b/ovsdb/file.c\n@@ -237,11 +237,9 @@ ovsdb_file_open__(const char *file_name,\n         /* Log error but otherwise ignore it.  Probably the database just got\n          * truncated due to power failure etc. and we should use its current\n          * contents. */\n-        char *msg = ovsdb_error_to_string(error);\n+        char *msg = ovsdb_error_to_string_free(error);\n         VLOG_ERR(\"%s\", msg);\n         free(msg);\n-\n-        ovsdb_error_destroy(error);\n     }\n \n     if (!read_only) {\n@@ -609,8 +607,7 @@ ovsdb_file_commit(struct ovsdb_replica *replica,\n     {\n         error = ovsdb_file_compact(file);\n         if (error) {\n-            char *s = ovsdb_error_to_string(error);\n-            ovsdb_error_destroy(error);\n+            char *s = ovsdb_error_to_string_free(error);\n             VLOG_WARN(\"%s: compacting database failed (%s), retrying in \"\n                       \"%d seconds\",\n                       file->file_name, s, COMPACT_RETRY_MSEC / 1000);\ndiff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c\nindex 030d86ba467f..28f258a4ff70 100644\n--- a/ovsdb/ovsdb-server.c\n+++ b/ovsdb/ovsdb-server.c\n@@ -902,10 +902,9 @@ update_remote_status(const struct ovsdb_jsonrpc_server *jsonrpc,\n         db = node->data;\n         error = ovsdb_txn_commit(db->txn, false);\n         if (error) {\n-            char *msg = ovsdb_error_to_string(error);\n+            char *msg = ovsdb_error_to_string_free(error);\n             VLOG_ERR_RL(&rl, \"Failed to update remote status: %s\", msg);\n             free(msg);\n-            ovsdb_error_destroy(error);\n         }\n     }\n }\n@@ -1143,10 +1142,9 @@ ovsdb_server_compact(struct unixctl_conn *conn, int argc,\n \n             error = ovsdb_file_compact(db->file);\n             if (error) {\n-                char *s = ovsdb_error_to_string(error);\n+                char *s = ovsdb_error_to_string_free(error);\n                 ds_put_format(&reply, \"%s\\n\", s);\n                 free(s);\n-                ovsdb_error_destroy(error);\n             }\n \n             n++;\ndiff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c\nindex 36b23effff81..742c08a92106 100644\n--- a/tests/test-ovsdb.c\n+++ b/tests/test-ovsdb.c\n@@ -280,8 +280,7 @@ print_and_free_json(struct json *json)\n static void\n print_and_free_ovsdb_error(struct ovsdb_error *error)\n {\n-    char *string = ovsdb_error_to_string(error);\n-    ovsdb_error_destroy(error);\n+    char *string = ovsdb_error_to_string_free(error);\n     puts(string);\n     free(string);\n }\n@@ -290,8 +289,7 @@ static void\n check_ovsdb_error(struct ovsdb_error *error)\n {\n     if (error) {\n-        char *s = ovsdb_error_to_string(error);\n-        ovsdb_error_destroy(error);\n+        char *s = ovsdb_error_to_string_free(error);\n         ovs_fatal(0, \"%s\", s);\n     }\n }\n@@ -355,10 +353,9 @@ do_log_io(struct ovs_cmdl_context *ctx)\n             ovs_fatal(0, \"unknown log-io command \\\"%s\\\"\", command);\n         }\n         if (error) {\n-            char *s = ovsdb_error_to_string(error);\n+            char *s = ovsdb_error_to_string_free(error);\n             printf(\"%s: %s failed: %s\\n\", name, command, s);\n             free(s);\n-            ovsdb_error_destroy(error);\n         } else {\n             printf(\"%s: %s successful\\n\", name, command);\n         }\n@@ -461,8 +458,7 @@ do_diff_data(struct ovs_cmdl_context *ctx)\n         /* Apply diff to 'old' to create'reincarnation'. */\n         error = ovsdb_datum_apply_diff(&reincarnation, &old, &diff, &type);\n         if (error) {\n-            char *string = ovsdb_error_to_string(error);\n-            ovsdb_error_destroy(error);\n+            char *string = ovsdb_error_to_string_free(error);\n             ovs_fatal(0, \"%s\", string);\n         }\n \n@@ -883,10 +879,9 @@ do_parse_conditions(struct ovs_cmdl_context *ctx)\n         if (!error) {\n             print_and_free_json(ovsdb_condition_to_json(&cnd));\n         } else {\n-            char *s = ovsdb_error_to_string(error);\n+            char *s = ovsdb_error_to_string_free(error);\n             ovs_error(0, \"%s\", s);\n             free(s);\n-            ovsdb_error_destroy(error);\n             exit_code = 1;\n         }\n         json_destroy(json);\n@@ -1054,10 +1049,9 @@ do_parse_mutations(struct ovs_cmdl_context *ctx)\n         if (!error) {\n             print_and_free_json(ovsdb_mutation_set_to_json(&set));\n         } else {\n-            char *s = ovsdb_error_to_string(error);\n+            char *s = ovsdb_error_to_string_free(error);\n             ovs_error(0, \"%s\", s);\n             free(s);\n-            ovsdb_error_destroy(error);\n             exit_code = 1;\n         }\n         json_destroy(json);\n","prefixes":["ovs-dev","RFC","14/52"]}