]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovsdb-parser: New function ovsdb_parser_put_error().
authorBen Pfaff <blp@ovn.org>
Mon, 18 Sep 2017 18:25:35 +0000 (11:25 -0700)
committerBen Pfaff <blp@ovn.org>
Wed, 13 Dec 2017 19:33:07 +0000 (11:33 -0800)
This will have its first user in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
lib/ovsdb-parser.c
lib/ovsdb-parser.h

index 3e448332bc47eaa020965eddc65e09cdb22447ce..42937b64912344d9cba8cc77d3e93321d06c6bea 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2011, 2013, 2015 Nicira, Inc.
+/* Copyright (c) 2009, 2011, 2013, 2015, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -114,6 +114,18 @@ ovsdb_parser_raise_error(struct ovsdb_parser *parser, const char *format, ...)
     }
 }
 
+/* If 'parser' isn't already in an error state, sets its error to 'error'.
+ * Always takes ownership of 'error'. */
+void
+ovsdb_parser_put_error(struct ovsdb_parser *parser, struct ovsdb_error *error)
+{
+    if (!parser->error) {
+        parser->error = error;
+    } else {
+        ovsdb_error_destroy(error);
+    }
+}
+
 struct ovsdb_error *
 ovsdb_parser_get_error(const struct ovsdb_parser *parser)
 {
index 31c5a60c82a05ccf5ff30fdd694d57ce04d3c87d..62e4c004f1e8ad00452680efa8c5cc63f88f7a53 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011, 2015 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2015, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,6 +68,7 @@ const struct json *ovsdb_parser_member(struct ovsdb_parser *, const char *name,
 void ovsdb_parser_raise_error(struct ovsdb_parser *parser,
                               const char *format, ...)
     OVS_PRINTF_FORMAT(2, 3);
+void ovsdb_parser_put_error(struct ovsdb_parser *, struct ovsdb_error *);
 bool ovsdb_parser_has_error(const struct ovsdb_parser *);
 struct ovsdb_error *ovsdb_parser_get_error(const struct ovsdb_parser *);
 struct ovsdb_error *ovsdb_parser_finish(struct ovsdb_parser *)