]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: make libxl__poller_put tolerate p==NULL
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 11 Oct 2013 11:10:45 +0000 (12:10 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 12 Aug 2015 12:09:55 +0000 (13:09 +0100)
This is less fragile, and more in keeping with the usual style of
initialising everything to 0 and freeing things unconditionally.

Correspondingly, remove the tests at the call sites.

Apropos of c1f3f174.  No overall functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
(cherry picked from commit 6ed09e37722f601661fff42f80279a41773c574e)
(cherry picked from commit f66f746df7983fac7f63b38b1b6bde11a791f1ed)

tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h

index b990ae23b1e0d14d2363414281d515d6d5e95f28..3abcfb5c889edf39dcca2cfa2e0eee715bcc0f95 100644 (file)
@@ -1348,6 +1348,7 @@ libxl__poller *libxl__poller_get(libxl_ctx *ctx)
 
 void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p)
 {
+    if (!p) return;
     LIBXL_LIST_INSERT_HEAD(&ctx->pollers_idle, p, entry);
 }
 
@@ -1540,7 +1541,7 @@ void libxl__ao__destroy(libxl_ctx *ctx, libxl__ao *ao)
     AO_GC;
     if (!ao) return;
     LOG(DEBUG,"ao %p: destroy",ao);
-    if (ao->poller) libxl__poller_put(ctx, ao->poller);
+    libxl__poller_put(ctx, ao->poller);
     ao->magic = LIBXL__AO_MAGIC_DESTROYED;
     libxl__free_all(&ao->gc);
     free(ao);
index 2c8a56d6f6fec28c9aaaef38179a8f141ec7614d..5e2f8ea1356217d00e2883b070b4e27f2c7099b0 100644 (file)
@@ -826,7 +826,7 @@ _hidden void libxl__poller_dispose(libxl__poller *p);
  * away again afterwards.  _get can fail, returning NULL.
  * ctx must be locked. */
 _hidden libxl__poller *libxl__poller_get(libxl_ctx *ctx);
-_hidden void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p);
+_hidden void libxl__poller_put(libxl_ctx*, libxl__poller *p /* may be NULL */);
 
 /* Notifies whoever is polling using p that they should wake up.
  * ctx must be locked. */