]> xenbits.xensource.com Git - people/vhanquez/xen-unstable.git/commitdiff
libxl: remove malloc failure handling from NEW_EVENT
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 11 May 2012 17:59:05 +0000 (18:59 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Fri, 11 May 2012 17:59:05 +0000 (18:59 +0100)
Change to use libxl__zalloc, where allocation failure is fatal.

Also remove a spurious semicolon from the helper macro.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h

index 482adaa6d73b11d8f20384227951822b691ab156..4d01cf86b9f01433ed045c682cfef36dde633c4b 100644 (file)
@@ -789,7 +789,6 @@ static void domain_death_occurred(libxl__egc *egc,
     *evg_upd = evg_next;
 
     libxl_event *ev = NEW_EVENT(egc, DOMAIN_DEATH, evg->domid);
-    if (!ev) return;
 
     libxl__event_occurred(egc, ev);
 
@@ -876,7 +875,6 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
             if (!evg->shutdown_reported &&
                 (got->flags & XEN_DOMINF_shutdown)) {
                 libxl_event *ev = NEW_EVENT(egc, DOMAIN_SHUTDOWN, got->domain);
-                if (!ev) goto out;
                 
                 LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, " shutdown reporting");
 
index 460ef66b6f6c7ff938307467c657770b2d209f4e..63719b2b5ddbfcc50ddc3f73be9817bd0b3809e2 100644 (file)
@@ -989,13 +989,7 @@ libxl_event *libxl__event_new(libxl__egc *egc,
 {
     libxl_event *ev;
 
-    ev = malloc(sizeof(*ev));
-    if (!ev) {
-        LIBXL__EVENT_DISASTER(egc, "allocate new event", errno, type);
-        return NULL;
-    }
-
-    memset(ev, 0, sizeof(*ev));
+    ev = libxl__zalloc(0,sizeof(*ev));
     ev->type = type;
     ev->domid = domid;
 
index d5cf69a715cda47be9b0e74ace167b8e4b8b97e6..a407317d3b0eb954d321bf4a3104833864eb2695 100644 (file)
@@ -654,10 +654,10 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type,
                                       uint32_t domid);
   /* Convenience function.
    * Allocates a new libxl_event, fills in domid and type.
-   * If allocation fails, calls _disaster, and returns NULL. */
+   * Cannot fail. */
 
 #define NEW_EVENT(egc, type, domid)                              \
-    libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid));
+    libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid))
     /* Convenience macro. */
 
 /*