qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 38/56] json: Pass lexical errors and limit viola


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 38/56] json: Pass lexical errors and limit violations to callback
Date: Mon, 13 Aug 2018 10:51:42 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 08/08/2018 07:03 AM, Markus Armbruster wrote:
The callback to consume JSON values takes QObject *json, Error *err.
If both are null, the callback is supposed to make up an error by
itself.  This sucks.

qjson.c's consume_json() neglects to do so, which makes
qobject_from_json() & friends return null instead of failing.  I
consider that a bug.

The culprit is json_message_process_token(): it passes two null
pointers when it runs into a lexical error or a limit violation.  Fix
it to pass a proper Error object then.  Update the callbacks:


+++ b/include/qapi/qmp/qerror.h
@@ -61,9 +61,6 @@
  #define QERR_IO_ERROR \
      "An IO error has occurred"
-#define QERR_JSON_PARSING \
-    "Invalid JSON syntax"
-

Bonus - one less of these annoying defines.

Reviewed-by: Eric Blake <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]