From 9b516aa31bdacfe5c65c1d4e3f1bfe7397b8ae6c Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 27 Jan 2012 17:35:09 +0000 Subject: [PATCH] Move virEmitXMLWarning into xml.h The virEmitXMLWarning function should always have been in the xml.[hc] files, and should use virXML as its name prefix * src/util/util.c, src/util/util.h: Remove virEmitXMLWarning * src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning --- src/libvirt_private.syms | 1 - src/util/util.c | 39 ------------------------------------ src/util/util.h | 4 ---- src/util/xml.c | 43 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8a83f07260..ce71d8b6ef 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1081,7 +1081,6 @@ virArgvToString; virAsprintf; virBuildPathInternal; virDirCreate; -virEmitXMLWarning; virEnumFromString; virEnumToString; virEventAddHandle; diff --git a/src/util/util.c b/src/util/util.c index baa0f12611..09062f684a 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -2472,42 +2472,3 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED) return false; } #endif - -int virEmitXMLWarning(int fd, - const char *name, - const char *cmd) { - size_t len; - const char *prologue = "\n\n"; - - if (fd < 0 || !name || !cmd) { - errno = EINVAL; - return -1; - } - - len = strlen(prologue); - if (safewrite(fd, prologue, len) != len) - return -1; - - len = strlen(cmd); - if (safewrite(fd, cmd, len) != len) - return -1; - - if (safewrite(fd, " ", 1) != 1) - return -1; - - len = strlen(name); - if (safewrite(fd, name, len) != len) - return -1; - - len = strlen(epilogue); - if (safewrite(fd, epilogue, len) != len) - return -1; - - return 0; -} diff --git a/src/util/util.h b/src/util/util.h index 96491e57b9..f62cb42b61 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -238,8 +238,4 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL; bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); -int virEmitXMLWarning(int fd, - const char *name, - const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); - #endif /* __VIR_UTIL_H__ */ diff --git a/src/util/xml.c b/src/util/xml.c index 2909e85386..c633521ce8 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -801,6 +801,47 @@ error: } +static int virXMLEmitWarning(int fd, + const char *name, + const char *cmd) +{ + size_t len; + const char *prologue = "\n\n"; + + if (fd < 0 || !name || !cmd) { + errno = EINVAL; + return -1; + } + + len = strlen(prologue); + if (safewrite(fd, prologue, len) != len) + return -1; + + len = strlen(cmd); + if (safewrite(fd, cmd, len) != len) + return -1; + + if (safewrite(fd, " ", 1) != 1) + return -1; + + len = strlen(name); + if (safewrite(fd, name, len) != len) + return -1; + + len = strlen(epilogue); + if (safewrite(fd, epilogue, len) != len) + return -1; + + return 0; +} + + struct virXMLRewritFileData { const char *warnName; const char *warnCommand; @@ -813,7 +854,7 @@ virXMLRewriteFile(int fd, void *opaque) struct virXMLRewritFileData *data = opaque; if (data->warnName && data->warnCommand) { - if (virEmitXMLWarning(fd, data->warnName, data->warnCommand) < 0) + if (virXMLEmitWarning(fd, data->warnName, data->warnCommand) < 0) return -1; }