Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Xen: Devel

[PATCH 21/25] libxl: remove malloc failure handling from NEW_EVENT

 

 

Xen devel RSS feed   Index | Next | Previous | View Threaded


ian.jackson at eu

Apr 25, 2012, 8:55 AM

Post #1 of 1 (65 views)
Permalink
[PATCH 21/25] libxl: remove malloc failure handling from NEW_EVENT

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 [at] eu>
Acked-by: Ian Campbell <ian.campbell [at] citrix>
---
tools/libxl/libxl.c | 2 --
tools/libxl/libxl_event.c | 8 +-------
tools/libxl/libxl_internal.h | 4 ++--
3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 9238916..38e376c 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -779,7 +779,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);

@@ -866,7 +865,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");

diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
index 02deea5..f726fc2 100644
--- a/tools/libxl/libxl_event.c
+++ b/tools/libxl/libxl_event.c
@@ -985,13 +985,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;

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index d9dfd6d..4adbb5f 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -664,10 +664,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. */

/*
--
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel

Xen devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.