Skip to contentSkip to conversation

qemu: jaso-parser: Output the content of invalid keyword

PATCH RESEND In review Amos Kong 5 participants 7 messages Mar 24, 2010 KVM

lore
Share & tools
lore

Amos Kong

author
#0 lore raw

PATCH RESEND 1/1 qemu: jaso-parser: Output the content of invalid keyword

When input some invialid words in QMP port, qemu outputs this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content, like:
"parse error: invalid keyword `unknow_cmd'"

---
 json-parser.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
json-parser.c +6 -1
index 579928f..98a82af 100644
@@ -12,6 +12,7 @@
  */
 
 #include <stdbool.h>
+#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qstring.h"
@@ -93,7 +94,11 @@ static int token_is_escape(QObject *obj, const char *value)
  */
 static void parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...)
 {
-    fprintf(stderr, "parse error: %s\n", msg);
+    va_list ap;
+    va_start(ap, msg);
+    fprintf(stderr, "parse error: ");
+    vfprintf(stderr, msg, ap);
+    fprintf(stderr, "\n");
 }
 
 /**
Signature · 1 line
1.5.5.6
#1 lore raw

json-parser.c static int token_is_escape(QObject *obj, const char *value) · line 101

Quoted 6 lines · Amos Kong
json-parser.c +5 -1
-    fprintf(stderr, "parse error: %s\n", msg);
+    va_list ap;
+    va_start(ap, msg);
+    fprintf(stderr, "parse error: ");
+    vfprintf(stderr, msg, ap);
+    fprintf(stderr, "\n");

Technically you need va_end here.

r~

author
#2 lore raw

PATCH 1/1 qemu: jaso-parser: Output the content of invalid keyword

When input some invialid word 'unknowcmd' through QMP port, qemu outputs this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content of invalid keyword, like:
"parse error: invalid keyword `unknowcmd'"

---
 json-parser.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
json-parser.c +7 -1
index 579928f..b55d763 100644
@@ -12,6 +12,7 @@
  */
 
 #include <stdbool.h>
+#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qstring.h"
@@ -93,7 +94,12 @@ static int token_is_escape(QObject *obj, const char *value)
  */
 static void parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...)
 {
-    fprintf(stderr, "parse error: %s\n", msg);
+    va_list ap;
+    va_start(ap, msg);
+    fprintf(stderr, "parse error: ");
+    vfprintf(stderr, msg, ap);
+    fprintf(stderr, "\n");
+    va_end(ap);
 }
 
 /**
Signature · 1 line
1.6.3.3
author
#3 lore raw

PATCH 1/1 qemu: jaso-parser: Output the content of invalid keyword

In reply to Richard Henderson

When input some invialid word 'unknowcmd' through QMP port, qemu outputs this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content of invalid keyword, like:
"parse error: invalid keyword `unknowcmd'"

---
 json-parser.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
json-parser.c +7 -1
index 579928f..b55d763 100644
@@ -12,6 +12,7 @@
  */
 
 #include <stdbool.h>
+#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qstring.h"
@@ -93,7 +94,12 @@ static int token_is_escape(QObject *obj, const char *value)
  */
 static void parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...)
 {
-    fprintf(stderr, "parse error: %s\n", msg);
+    va_list ap;
+    va_start(ap, msg);
+    fprintf(stderr, "parse error: ");
+    vfprintf(stderr, msg, ap);
+    fprintf(stderr, "\n");
+    va_end(ap);
 }
 
 /**
Signature · 1 line
1.6.3.3
#4 lore raw
Quoted 7 lines · Amos Kong

When input some invialid word 'unknowcmd' through QMP port, qemu outputs this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content of invalid keyword, like:
"parse error: invalid keyword `unknowcmd'"

Looks good to me.

Hint: it's best to put a version in the subject when you respin, like [PATCH v2] ...

#5 lore raw
Quoted 8 lines · On Wed, 24 Mar 2010 17:00:14 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 6 lines · Amos Kong

When input some invialid word 'unknowcmd' through QMP port, qemu outputs this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content of invalid keyword, like:
"parse error: invalid keyword `unknowcmd'"

Quoted 6 lines
Quoted 1 line

Looks good to me.

Hint: it's best to put a version in the subject when you respin, like [PATCH v2] ...

Yes, and maintainers may miss a patch down a thread (and it's a good
opportunity to fix the subject).

Acked-by on v1 1/1
#6 lore raw
In reply to Amos Kong
Quoted 8 lines · Amos Kong

When input some invialid word 'unknowcmd' through QMP port, qemu outputs this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content of invalid keyword, like:
"parse error: invalid keyword `unknowcmd'"

Quoted 30 lines
---
 json-parser.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
json-parser.c +7 -1
index 579928f..b55d763 100644
@@ -12,6 +12,7 @@
  */
 
 #include <stdbool.h>
+#include <stdarg.h>
 
 #include "qemu-common.h"
 #include "qstring.h"
@@ -93,7 +94,12 @@ static int token_is_escape(QObject *obj, const char *value)
  */
 static void parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...)
 {
-    fprintf(stderr, "parse error: %s\n", msg);
+    va_list ap;
+    va_start(ap, msg);
+    fprintf(stderr, "parse error: ");
+    vfprintf(stderr, msg, ap);
+    fprintf(stderr, "\n");
+    va_end(ap);
 }
 
 /**