On 10/10/2016 08:04 AM, Erik Skultety wrote:
Commit 640b58ab broke the mingw build because it referenced
'current_ident'
as well as 'openlog' symbols both of which are declared conditionally within
HAVE_SYSLOG_H directive. This patch fixes the broken build. Additional changes
like moving all variable declarations in virLogDefineOutputs into the
conditional block were necessary to avoid 'unused variable' errors from mingw.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
I could've pushed it under build breaker rule but I'd rather be safe than sorry
that I missed anything else.
Erik
src/util/virlog.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
Can the syslog specific hunk just be moved into a #if HAVE_SYSLOG
specific section of code as a virLogFindSyslogOutputs(outputs,
noutputs), then called inside an #if HAVE_SYSLOG_H (similar to
virLogNewOutputToSyslog in virLogParseOutput)
While the following works - it intersperses new variable definitions
inside the #if's and doesn't seem "as clean"
John
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 14ee701..f52d9d8 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1362,16 +1362,15 @@ virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
int
virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
{
- int ret = -1;
- int id;
+ if (virLogInitialize() < 0)
+ return -1;
+
+ virLogLock();
+ virLogResetOutputs();
+
+#if HAVE_SYSLOG_H
+ int id = -1;
char *tmp = NULL;
-
- if (virLogInitialize() < 0)
- return -1;
-
- virLogLock();
- virLogResetOutputs();
-
/* syslog needs to be special-cased, since it keeps the fd in private */
if ((id = virLogFindOutput(outputs, noutputs, VIR_LOG_TO_SYSLOG,
current_ident)) != -1) {
@@ -1379,20 +1378,21 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
* holding the lock so it's safe to call openlog and change the message
* tag
*/
- if (VIR_STRDUP_QUIET(tmp, outputs[id]->name) < 0)
- goto cleanup;
+ if (VIR_STRDUP_QUIET(tmp, outputs[id]->name) < 0) {
+ virLogUnlock();
+ return -1;
+ }
VIR_FREE(current_ident);
current_ident = tmp;
openlog(current_ident, 0, 0);
}
+#endif
virLogOutputs = outputs;
virLogNbOutputs = noutputs;
- ret = 0;
- cleanup:
virLogUnlock();
- return ret;
+ return 0;
}