From 50e3cda49a754a2844c5fe94bcfe1aaca7425e04 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 2 Mar 2018 12:07:50 -0500 Subject: [PATCH] qapi: Drop string input visitor method optional() visit_optional() is to be called only between visit_start_struct() and visit_end_struct(). Visitors that don't support struct visits, i.e. don't implement start_struct(), end_struct(), have no use for it. Clarify documentation. The string input visitor doesn't support struct visits. Its parse_optional() is therefore useless. Drop it. Backports commit a8aec6de2ac1a5e36989fdfba29067b361009b75 from qemu --- qemu/include/qapi/visitor-impl.h | 4 ++-- qemu/qapi/string-input-visitor.c | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/qemu/include/qapi/visitor-impl.h b/qemu/include/qapi/visitor-impl.h index 698437a6..3f5341cb 100644 --- a/qemu/include/qapi/visitor-impl.h +++ b/qemu/include/qapi/visitor-impl.h @@ -103,8 +103,8 @@ struct Visitor /* Must be set to visit explicit null values. */ void (*type_null)(Visitor *v, const char *name, Error **errp); - /* Must be set for input visitors, optional otherwise. The core - * takes care of the return type in the public interface. */ + /* Must be set for input visitors to visit structs, optional otherwise. + The core takes care of the return type in the public interface. */ void (*optional)(Visitor *v, const char *name, bool *present); /* Must be set */ diff --git a/qemu/qapi/string-input-visitor.c b/qemu/qapi/string-input-visitor.c index e7884afd..0cdc32ca 100644 --- a/qemu/qapi/string-input-visitor.c +++ b/qemu/qapi/string-input-visitor.c @@ -292,18 +292,6 @@ static void parse_type_number(Visitor *v, const char *name, double *obj, *obj = val; } -static void parse_optional(Visitor *v, const char *name, bool *present) -{ - StringInputVisitor *siv = to_siv(v); - - if (!siv->string) { - *present = false; - return; - } - - *present = true; -} - static void string_input_free(Visitor *v) { StringInputVisitor *siv = to_siv(v); @@ -329,7 +317,6 @@ Visitor *string_input_visitor_new(const char *str) v->visitor.start_list = start_list; v->visitor.next_list = next_list; v->visitor.end_list = end_list; - v->visitor.optional = parse_optional; v->visitor.free = string_input_free; v->string = str;