]> xenbits.xensource.com Git - qemu-xen-4.6-testing.git/commitdiff
qemu xen upstream synch (Gerd): [PATCH 4/7]: no malloc failure checks.
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 19 May 2009 14:40:06 +0000 (15:40 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 19 May 2009 14:40:06 +0000 (15:40 +0100)
qemu_malloc() will never return errors.  It will abort instead.
Thus no checks for failure are needed.

[This is] a series of patches for qemu-xen, making the code identical
to the xen support patches being submitted to upstream qemu.  The review
process on qemu-devel resulted in a number of fixes and cleanups in the
backend code, this is where most of the changes come from.

There are also some xenfb changes due to displaystate reorganization and
xenfb being merged in steps due to that.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/xen_backend.c
hw/xenfb.c

index 56b001f875fc9024ccba94c284047bcf79de583f..bb02634c03ceb81e8b5493a0f940cf5c5ca78e60 100644 (file)
@@ -67,9 +67,17 @@ char *xenstore_read_str(const char *base, const char *node)
 {
     char abspath[XEN_BUFSIZE];
     unsigned int len;
+    char *str, *ret = NULL;
 
     snprintf(abspath, sizeof(abspath), "%s/%s", base, node);
-    return xs_read(xenstore, 0, abspath, &len);
+    str = xs_read(xenstore, 0, abspath, &len);
+    if (str != NULL) {
+        /* move to qemu-allocated memory to make sure
+         * callers can savely qemu_free() stuff. */
+        ret = qemu_strdup(str);
+        free(str);
+    }
+    return ret;
 }
 
 int xenstore_write_int(const char *base, const char *node, int ival)
@@ -184,8 +192,6 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
 
     /* init new xendev */
     xendev = qemu_mallocz(ops->size);
-    if (!xendev)
-        return NULL;
     xendev->type  = type;
     xendev->dom   = dom;
     xendev->dev   = dev;
@@ -519,7 +525,7 @@ static int xenstore_scan(const char *type, int dom, struct XenDevOps *ops)
            continue;
        xen_be_check_state(xendev);
     }
-    qemu_free(dev);
+    free(dev);
     return 0;
 }
 
index 8336c82ed346adb2de573d9cda68413956a291d7..1764ac2c148f4f76f2f1906c7901087736a449bc 100644 (file)
@@ -483,8 +483,6 @@ static int xenfb_map_fb(struct XenFB *xenfb)
 
     pgmfns = qemu_mallocz(sizeof(unsigned long) * n_fbdirs);
     fbmfns = qemu_mallocz(sizeof(unsigned long) * xenfb->fbpages);
-    if (!pgmfns || !fbmfns)
-       goto out;
 
     xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd);
     map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,