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

[Xen-devel] libxl gentypes.pl "saved_FOO" oddity

Coverity is complaining (eg, CID 1358114) about this code in

 *** 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

Opinions welcome.  In particular, should I attempt a patch to make
this code less odd-looking ?


(CCing Wei who seems from git log like the only person who might have
a view.)

Xen-devel mailing list



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