[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] libxl: make libxl__poller_put tolerate p==NULL libxl_event_wait
Ian Campbell writes ("Re: [PATCH v2] libxl: only put poller if already gotten in libxl_event_wait"): > On Sun, 2013-09-29 at 18:24 +1300, Matthew Daley wrote: > > Coverity-ID: 1055292 > > Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx> > > Acked + applied, thanks. commit 9134bb273db4d55bec247d751b1de6e7876a7fe7 Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Date: Fri Oct 11 12:10:45 2013 +0100 libxl: make libxl__poller_put tolerate p==NULL 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@xxxxxxxxxxxxx> diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 6f033dd..a5c52bc 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1347,6 +1347,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); } @@ -1476,8 +1477,7 @@ int libxl_event_wait(libxl_ctx *ctx, libxl_event **event_r, } out: - if (poller) - libxl__poller_put(ctx, poller); + libxl__poller_put(ctx, poller); CTX_UNLOCK; EGC_FREE; @@ -1540,7 +1540,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); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4e15055..165dc00 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -829,7 +829,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. */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |