[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] tools/libxl: Improvements to libxl-save-helper when using valgrind
commit 82774acf35575d40bd90606595e8170ae38ded50 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Fri Apr 11 16:46:14 2014 +0100 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Wed Apr 16 17:08:02 2014 +0100 tools/libxl: Improvements to libxl-save-helper when using valgrind Fix two unfree()'d allocations in libxl-save-helper, to get them out of the way of other legitimate complaints from valgrind. The first is easy; close the interface to libxc when done with it. The second can be fixed by removing the complexity of creating the logging instance. Initialise the global 'logger' in place rather than as an allocation, which requires changing the indirection of its use in 5 locations. struct xentoollog_logger_tellparent and function createlogger_tellparent() are now unused and removed. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/libxl_save_helper.c | 31 ++++++++++--------------------- 1 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index d6fa5dd..c36314c 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -79,7 +79,11 @@ static void tellparent_destroy(struct xentoollog_logger *logger_in) /*----- globals -----*/ static const char *program = "libxl-save-helper"; -static xentoollog_logger *logger; +static xentoollog_logger logger = { + tellparent_vmessage, + tellparent_progress, + tellparent_destroy, +}; static xc_interface *xch; /*----- error handling -----*/ @@ -90,7 +94,7 @@ static void fail(int errnoval, const char *fmt, ...) { va_list al; va_start(al,fmt); - xtl_logv(logger,XTL_ERROR,errnoval,program,fmt,al); + xtl_logv(&logger,XTL_ERROR,errnoval,program,fmt,al); exit(-1); } @@ -115,16 +119,6 @@ static void *xmalloc(size_t sz) return r; } -typedef struct { - xentoollog_logger vtable; -} xentoollog_logger_tellparent; - -static xentoollog_logger_tellparent *createlogger_tellparent(void) -{ - xentoollog_logger_tellparent newlogger; - return XTL_NEW_LOGGER(tellparent, newlogger); -} - /*----- helper functions called by autogenerated stubs -----*/ unsigned char * helper_allocbuf(int len, void *user) @@ -184,22 +178,17 @@ static int toolstack_save_cb(uint32_t domid, uint8_t **buf, } static void startup(const char *op) { - logger = (xentoollog_logger*)createlogger_tellparent(); - if (!logger) { - fprintf(stderr, "%s: cannot initialise logger\n", program); - exit(-1); - } - - xtl_log(logger,XTL_DEBUG,0,program,"starting %s",op); + xtl_log(&logger,XTL_DEBUG,0,program,"starting %s",op); - xch = xc_interface_open(logger,logger,0); + xch = xc_interface_open(&logger,&logger,0); if (!xch) fail(errno,"xc_interface_open failed"); } static void complete(int retval) { int errnoval = retval ? errno : 0; /* suppress irrelevant errnos */ - xtl_log(logger,XTL_DEBUG,errnoval,program,"complete r=%d",retval); + xtl_log(&logger,XTL_DEBUG,errnoval,program,"complete r=%d",retval); helper_stub_complete(retval,errnoval,0); + xc_interface_close(xch); exit(0); } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |