This will have its first user in an upcoming commit.

Signed-off-by: Ben Pfaff <[email protected]>
---
 lib/ovsdb-parser.c | 14 +++++++++++++-
 lib/ovsdb-parser.h |  3 ++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/ovsdb-parser.c b/lib/ovsdb-parser.c
index 3e448332bc47..42937b649123 100644
--- a/lib/ovsdb-parser.c
+++ b/lib/ovsdb-parser.c
@@ -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)
 {
diff --git a/lib/ovsdb-parser.h b/lib/ovsdb-parser.h
index 31c5a60c82a0..62e4c004f1e8 100644
--- a/lib/ovsdb-parser.h
+++ b/lib/ovsdb-parser.h
@@ -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 *)
-- 
2.10.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to