[Xen-devel] Re: [Qemu-devel] [PATCH 02/10] xen: backend driver core
On 04/07/09 21:41, Anthony Liguori wrote:
+/* private */
+static TAILQ_HEAD(XenDeviceHead, XenDevice) xendevs =
+static int debug = 0;
Would be better to have all of this in a structure that had a single
static instance. Would be even better if you could avoid requiring the
Huh? Point being? This is just a list head, i.e. a pointer (or two?).
+char *xenstore_read_str(const char *base, const char *node)
+ char abspath[XEN_BUFSIZE];
+ unsigned int len;
+ snprintf(abspath, sizeof(abspath), "%s/%s", base, node);
+ return xs_read(xenstore, 0, abspath, &len);
xs_read() is a xenstore API, it's returning malloc()'d memory.
+int xenstore_read_int(const char *base, const char *node, int *ival)
+ char *val;
+ int rc = -1;
+ val = xenstore_read_str(base, node);
+ if (val && 1 == sscanf(val, "%d", ival))
+ rc = 0;
And here you're free()'ing with qemu_free.
Oops. Good catch.
+ xendev = qemu_mallocz(ops->size);
+ if (!xendev)
+ return NULL;
No need to check malloc failures.
+ dev = xs_directory(xenstore, 0, path, &cdev);
Mixing qemu_free() with malloc'd memory.
You also have open coded calls to fprintf(stderr)
whereas you've introduced a higher level function.
The high-level function wants a device instance and thus doesn't work
everythere. Nevertheless the code probably should use the new
qemu_log() function instead. I'll look into this.
Xen-devel mailing list