aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/utils.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-06-10 19:58:22 +0100
committerKeir Fraser <keir@xensource.com>2007-06-10 19:58:22 +0100
commit840f138cfaa1a591ebf3bc330e29aa872340443a (patch)
treec86e1fa2311e25d7a2b0b71fbf3c22f68e548e7b /tools/xenstore/utils.c
parentebb19b1cc8cc27171f338c8ca2ea91fdc71f897e (diff)
downloadxen-840f138cfaa1a591ebf3bc330e29aa872340443a.tar.gz
xen-840f138cfaa1a591ebf3bc330e29aa872340443a.tar.bz2
xen-840f138cfaa1a591ebf3bc330e29aa872340443a.zip
tools: Fix xenstored build error by checking vasprintf() return code.
Signed-off-by: Charles Coffing <ccoffing@novell.com>
Diffstat (limited to 'tools/xenstore/utils.c')
-rw-r--r--tools/xenstore/utils.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/xenstore/utils.c b/tools/xenstore/utils.c
index 6655777bcd..16f87cdc05 100644
--- a/tools/xenstore/utils.c
+++ b/tools/xenstore/utils.c
@@ -27,33 +27,38 @@ void xprintf(const char *fmt, ...)
void barf(const char *fmt, ...)
{
char *str;
+ int bytes;
va_list arglist;
xprintf("FATAL: ");
va_start(arglist, fmt);
- vasprintf(&str, fmt, arglist);
+ bytes = vasprintf(&str, fmt, arglist);
va_end(arglist);
- xprintf("%s\n", str);
- free(str);
+ if (bytes >= 0) {
+ xprintf("%s\n", str);
+ free(str);
+ }
exit(1);
}
void barf_perror(const char *fmt, ...)
{
char *str;
- int err = errno;
+ int bytes, err = errno;
va_list arglist;
xprintf("FATAL: ");
va_start(arglist, fmt);
- vasprintf(&str, fmt, arglist);
+ bytes = vasprintf(&str, fmt, arglist);
va_end(arglist);
- xprintf("%s: %s\n", str, strerror(err));
- free(str);
+ if (bytes >= 0) {
+ xprintf("%s: %s\n", str, strerror(err));
+ free(str);
+ }
exit(1);
}