From 9cd405497f4822322e068dc4b5df4b61ae91c84a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 4 Jul 2007 09:16:23 +0000 Subject: [PATCH] Wed Jul 4 10:14:00 BST 2007 Richard W.M. Jones * src/conf.c, src/test.c, src/xen_internal.c: Readd checking of errors from virBuffer functions. * src/sexpr.c: Add comment about use of _GNU_SOURCE. * src/virsh.c: Remove use of _GNU_SOURCE / isblank. * src/xml.c, tests/Makefile.am: Minor cleanup. --- ChangeLog | 8 ++++++++ src/conf.c | 8 ++++++-- src/sexpr.c | 2 +- src/test.c | 1 + src/virsh.c | 6 ++---- src/xen_internal.c | 11 ++++++----- src/xml.c | 3 --- tests/Makefile.am | 4 ++-- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4310b5f348..f4b1c234a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Jul 4 10:14:00 BST 2007 Richard W.M. Jones + + * src/conf.c, src/test.c, src/xen_internal.c: Readd checking + of errors from virBuffer functions. + * src/sexpr.c: Add comment about use of _GNU_SOURCE. + * src/virsh.c: Remove use of _GNU_SOURCE / isblank. + * src/xml.c, tests/Makefile.am: Minor cleanup. + Mon Jul 2 09:35:00 EST 2007 Daniel P. Berrange * src/qemu_driver.c: Change 'qemu' to 'QEMU' to get compatability diff --git a/src/conf.c b/src/conf.c index 8f4fc64cc7..3d4615a453 100644 --- a/src/conf.c +++ b/src/conf.c @@ -883,8 +883,10 @@ __virConfWriteFile(const char *filename, virConfPtr conf) return(-1); buf = virBufferNew(500); - if (buf == NULL) + if (buf == NULL) { + virConfError(NULL, VIR_ERR_NO_MEMORY, _("failed to allocate buffer"), 0); return(-1); + } cur = conf->entries; while (cur != NULL) { @@ -935,8 +937,10 @@ __virConfWriteMem(char *memory, int *len, virConfPtr conf) return(-1); buf = virBufferNew(500); - if (buf == NULL) + if (buf == NULL) { + virConfError(NULL, VIR_ERR_NO_MEMORY, _("failed to allocate buffer"), 0); return(-1); + } cur = conf->entries; while (cur != NULL) { diff --git a/src/sexpr.c b/src/sexpr.c index 12599518cb..f88de95a45 100644 --- a/src/sexpr.c +++ b/src/sexpr.c @@ -10,7 +10,7 @@ * archive for more details. */ -#define _GNU_SOURCE +#define _GNU_SOURCE /* for strndup */ #include "sexpr.h" #include "internal.h" diff --git a/src/test.c b/src/test.c index 31a24ded17..6e5723b7b3 100644 --- a/src/test.c +++ b/src/test.c @@ -1389,6 +1389,7 @@ char * testDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED) con = &node->connections[priv->handle]; if (!(buf = virBufferNew(4000))) { + testError(domain->conn, domain, VIR_ERR_NO_MEMORY, __FUNCTION__); return (NULL); } diff --git a/src/virsh.c b/src/virsh.c index 443e12dea1..7d05fdb8db 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -13,8 +13,6 @@ * $Id$ */ -#define _GNU_SOURCE /* isblank() */ - #include "libvirt/libvirt.h" #include "libvirt/virterror.h" #include @@ -3806,7 +3804,7 @@ vshCommandGetToken(vshControl * ctl, char *str, char **end, char **res) *end = NULL; - while (p && *p && isblank((unsigned char) *p)) + while (p && *p && (*p == ' ' || *p == '\t')) p++; if (p == NULL || *p == '\0') @@ -3817,7 +3815,7 @@ vshCommandGetToken(vshControl * ctl, char *str, char **end, char **res) } while (*p) { /* end of token is blank space or ';' */ - if ((quote == FALSE && isblank((unsigned char) *p)) || *p == ';') + if ((quote == FALSE && (*p == ' ' || *p == '\t')) || *p == ';') break; /* end of option name could be '=' */ diff --git a/src/xen_internal.c b/src/xen_internal.c index 4221be356e..c410a0cc99 100644 --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -2138,7 +2138,10 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn ATTRIBUTE_UNUSED, /* Construct the final XML. */ xml = virBufferNew (1024); - if (!xml) return NULL; + if (!xml) { + virXenError(VIR_ERR_NO_MEMORY, __FUNCTION__, 0); + return NULL; + } r = virBufferVSprintf (xml, "\ \n\ @@ -2225,15 +2228,13 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn ATTRIBUTE_UNUSED, \n", -1); if (r == -1) goto vir_buffer_failed; xml_str = strdup (xml->content); - if (!xml_str) { - virXenError(VIR_ERR_NO_MEMORY, "strdup", 0); - goto vir_buffer_failed; - } + if (!xml_str) goto vir_buffer_failed; virBufferFree (xml); return xml_str; vir_buffer_failed: + virXenError(VIR_ERR_NO_MEMORY, __FUNCTION__, 0); virBufferFree (xml); return NULL; } diff --git a/src/xml.c b/src/xml.c index 16e51499c4..52c186788c 100644 --- a/src/xml.c +++ b/src/xml.c @@ -267,10 +267,7 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) { xmlXPathFreeObject(obj); return(ret); } -#endif /* !PROXY */ - -#ifndef PROXY /** * virtDomainParseXMLGraphicsDescImage: * @conn: pointer to the hypervisor connection diff --git a/tests/Makefile.am b/tests/Makefile.am index 35c056c3c9..f4f810c651 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,8 +46,8 @@ valgrind: xmlrpctest_SOURCES = \ xmlrpctest.c \ testutils.c testutils.h \ - $(top_builddir)/src/xmlrpc.c \ - $(top_builddir)/src/xmlrpc.h + @top_srcdir@/src/xmlrpc.c \ + @top_srcdir@/src/xmlrpc.h xmlrpctest_LDFLAGS = xmlrpctest_LDADD = $(LDADDS) -- GitLab