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

Re: [PATCH for-4.21 1/6] tools/{lib,}xl: fix usage of error return from json_tokener_parse_verbose()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 15 Oct 2025 16:25:01 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3QImsDN2wK5fEuya1HulGCy+SFNNLC+96ZR78mu8jqk=; b=KmXXlacJRBEKJRO4CuYJ6R6zl25n15bBWT5fs8XsRQyf4oH4Fe7WVLDeyU+Zt1PPdRm5g+zfyCpSYWZCOHIeUTdYDT17sxnQxP7uH0vOnS1GslLbnyyOJ44lkHYWBGezfYjR8x9BLQ2BIda/dL5fmV6cnSTnOSdl6Cayw13AcjmsqrNKFG2+cEEPvq5hY7p9aGuUDSz6zJMpH0o94IBGO0ToxwUdV95sFqGT+JhJyigvjAd/XKxygtd3WBRyVnaIhM0XBxeLi3z71QZ1XJJfoioqfDJuj3E5FMqg+3/JSa5eyTQcTiE+0SFWZZOIxPKf6G7VpKTnR2AMSnEXS7wUwg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j+bvFwyUTLo0ozW8jIWEsi8INhMJ0gfg5dTjkp4zhcN0n2Z+MxrspaOQsIHYxD4N8zIv4Za3/3UgIwiRpa6bKcqSWoCa7CfSrI6tfSHGMlB0cE0R3Wkx96efzTOQtY4MgKg9tcPL7YrKIxmE57JHHjW6M46iJR4mqw/HQ0X3+8tOUkopQcndqxzZ66AOt7u3K3pdJXfqLuuCwd0Ejexei6ysAP9AD7eZDuCPM3nNFDeVTgILqDmV/9/KogL9vIGbGIoYliUKWFw3rW6FsBOF9VmRnLMiDMsw0mkpwG2WVoz+gzhRPNVtxhDq0zW4WFr6pPXMiF7B35hTfzQW8wIebg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, oleksii.kurochko@xxxxxxxxx, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Wed, 15 Oct 2025 14:25:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Oct 15, 2025 at 02:59:25PM +0100, Andrew Cooper wrote:
> On 15/10/2025 2:40 pm, Roger Pau Monne wrote:
> > diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c
> > index c76ae9f64a9d..a9e06b06932d 100644
> > --- a/tools/libs/light/libxl_json.c
> > +++ b/tools/libs/light/libxl_json.c
> > @@ -1366,11 +1366,13 @@ libxl__json_object *libxl__json_parse(libxl__gc 
> > *gc, const char *s)
> >      libxl__json_object *o = NULL;
> >  #ifdef USE_LIBJSONC_PARSER
> >      json_object *jso;
> > -    enum json_tokener_error error;
> > +    enum json_tokener_error error = json_tokener_success;
> 
> Looking at the options available, I'd suggest initialising to:
> 
>     json_tokener_error_parse_unexpected
> 
> and dropping the rest of the hunk.  I wouldn't assume that success
> cannot be passed here.

That error code translates to "unexpected character", which I didn't
think was very accurate here.  I didn't find any good error code to
map here, hence why I went with this kind of weird solution.

I don't mind using json_tokener_error_parse_unexpected, just
mentioning why I didn't use it in the first place.  Anthony, what's
your opinion?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.