From: Wei Liu <wei.liu2@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>
Subject: Re: libxl gentypes.pl "saved_FOO" oddity
Date: Mon, 4 Apr 2016 17:25:24 +0100 [thread overview]
Message-ID: <20160404162524.GP25710@citrix.com> (raw)
In-Reply-To: <22274.32958.537454.301598@mariner.uk.xensource.com>
On Mon, Apr 04, 2016 at 03:57:02PM +0100, Ian Jackson wrote:
> Coverity is complaining (eg, CID 1358114) about this code in
> _libxl_types.c:
>
> *** CID 1358114: Code maintainability issues (UNUSED_VALUE)
> /tools/libxl/_libxl_types.c: 11035 in libxl__device_usbdev_parse_json()
> 11029 x = libxl__json_map_get("hostaddr", x, JSON_INTEGER);
> 11030 if (x) {
> 11031 rc = libxl__uint8_parse_json(gc, x, &p->u.hostdev.hostaddr);
> 11032 if (rc)
> 11033 goto out;
> 11034 }
> >>> CID 1358114: Code maintainability issues (UNUSED_VALUE)
> >>> Assigning value from "saved_hostaddr" to "x" here, but that stored vale is overwritten before it can be used.
> 11035 x = saved_hostaddr;
>
> This does seem rather odd. I wasn't able to find any occurrences of
> `x' outside these save/restore regions. So x is saved and restored
> for no particular reason.
>
> The root cause seems to be the reuse of x by both inner and outer
> autogenerated code, where the generator may not know what is to be
> inserted. Why not have a separate variable for each
> libxl__json_map_get ?
>
> This code is generated by gentypes.py, near line 438. It was written
> by Ian Campbell in 2010 and doesn't seem to have been much touched
> since.
>
Actually I wrote that snippet back then. Maybe at the time I meant to
use `x' as a pointer of the node being processed for no particular
reason.
> Opinions welcome. In particular, should I attempt a patch to make
> this code less odd-looking ?
>
Sure. I don't object to this.
Wei.
> Thanks,
> Ian.
>
> (CCing Wei who seems from git log like the only person who might have
> a view.)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
prev parent reply other threads:[~2016-04-04 16:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 14:57 libxl gentypes.pl "saved_FOO" oddity Ian Jackson
2016-04-04 16:25 ` Wei Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160404162524.GP25710@citrix.com \
--to=wei.liu2@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.