From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrTz1-0001EH-Em for qemu-devel@nongnu.org; Wed, 08 Apr 2009 05:22:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrTyw-0001As-Dd for qemu-devel@nongnu.org; Wed, 08 Apr 2009 05:22:10 -0400 Received: from [199.232.76.173] (port=52491 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrTyw-0001Ag-3u for qemu-devel@nongnu.org; Wed, 08 Apr 2009 05:22:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:39303) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LrTyv-00068h-Nj for qemu-devel@nongnu.org; Wed, 08 Apr 2009 05:22:05 -0400 Message-ID: <49DC6CB7.8000602@redhat.com> Date: Wed, 08 Apr 2009 11:21:59 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 02/10] xen: backend driver core References: <1239115497-1884-1-git-send-email-kraxel@redhat.com> <1239115497-1884-3-git-send-email-kraxel@redhat.com> <49DBAC54.7010500@us.ibm.com> In-Reply-To: <49DBAC54.7010500@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: xen-devel@lists.xensource.com, qemu-devel@nongnu.org On 04/07/09 21:41, Anthony Liguori wrote: >> +/* private */ >> +static TAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = >> TAILQ_HEAD_INITIALIZER(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 > static instance. 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; >> + qemu_free(val); > > 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. Will fix. >> + dev = xs_directory(xenstore, 0, path, &cdev); >> + qemu_free(dev); > > Mixing qemu_free() with malloc'd memory. This too. > 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. cheers, Gerd