]> git.ipfire.org Git - thirdparty/qemu.git/commit
json: Report first rather than last parse error
authorMarkus Armbruster <armbru@redhat.com>
Thu, 23 Aug 2018 16:39:50 +0000 (18:39 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 24 Aug 2018 18:26:37 +0000 (20:26 +0200)
commit574bf16ff1f836a442d8de1853eb248c218a591d
treee2e1db0b4df1b63e6b3aacbfd944b2a01c153733
parente59f39d40397645477b959255aedfa17a7c9c779
json: Report first rather than last parse error

Quiz time!  When a parser reports multiple errors, but the user gets
to see just one, which one is (on average) the least useful one?

Yes, you're right, it's the last one!  You're clearly familiar with
compilers.

Which one does QEMU report?

Right again, the last one!  You're clearly familiar with QEMU.

Reproducer: feeding

    {"abc\xC2ijk": 1}\n

to QMP produces

    {"error": {"class": "GenericError", "desc": "JSON parse error, key is not a string in object"}}

Report the first error instead.  The reproducer now produces

    {"error": {"class": "GenericError", "desc": "JSON parse error, invalid UTF-8 sequence in string"}}

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-24-armbru@redhat.com>
qobject/json-parser.c