diff mbox series

[RFC,29/32] qapi/options: QAPIfy --echr argument type

Message ID 20171002152552.27999-30-armbru@redhat.com
State New
Headers show
Series Command line QAPIfication | expand

Commit Message

Markus Armbruster Oct. 2, 2017, 3:25 p.m. UTC
Bonus: more rigorous error checking.  Crap like '-echar 666' and
'-echar 0x' are now rejected.

FIXME the error messages are crap:
qemu-system-x86_64: -echr 666: Parameter 'null' expects int8_t
qemu-system-x86_64: -echr 0x: Parameter '<anonymous>' expects integer

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/options.json |  2 +-
 vl.c              | 10 ++--------
 2 files changed, 3 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/qapi/options.json b/qapi/options.json
index 5a8fdc04ad..853908560d 100644
--- a/qapi/options.json
+++ b/qapi/options.json
@@ -3892,7 +3892,7 @@ 
 # !end texinfo
 ##
 { 'option': '--echr',
-  'data': 'str',                # FIXME int
+  'data': 'int8',
   'help': "-echr chr       set terminal escape character instead of ctrl-a" }
 
 ##
diff --git a/vl.c b/vl.c
index b9524f7e11..4af2905c60 100644
--- a/vl.c
+++ b/vl.c
@@ -3574,14 +3574,8 @@  int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QAPI_OPTION_KIND_ECHR:
-                {
-                    char *r;
-                    term_escape_char = strtol(qopt[i].u.echr.data, &r, 0);
-                    if (r == qopt[i].u.echr.data) {
-                        printf("Bad argument to echr\n");
-                    }
-                    break;
-                }
+                term_escape_char = qopt[i].u.echr.data;
+                break;
             case QAPI_OPTION_KIND_MONITOR:
                 default_monitor = 0;
                 if (strncmp(qopt[i].u.monitor.data, "none", 4)) {