]> xenbits.xensource.com Git - libvirt.git/commitdiff
virLogDefineOutputs: Fix build without syslog.h
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 14 Oct 2016 02:09:03 +0000 (10:09 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 14 Oct 2016 02:12:49 +0000 (10:12 +0800)
Not every system out there has syslog, that's why we check for it
in our configure script. However, in 640b58abdf while fixing
another issue, some variables and functions are called that are
defined only when syslog.h is present. But these function
calls/variables were not guarded by #ifdef-s.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virlog.c

index 52b0eea30b27c2ff2cf07e05a55d3c3d060cdbef..8f831fc2b6c19b00c9f6b4cb2b82cf65615c55b6 100644 (file)
@@ -1362,9 +1362,10 @@ virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
 int
 virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
 {
-    int ret = -1;
+#if HAVE_SYSLOG_H
     int id;
     char *tmp = NULL;
+#endif /* HAVE_SYSLOG_H */
 
     if (virLogInitialize() < 0)
         return -1;
@@ -1372,6 +1373,7 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
     virLogLock();
     virLogResetOutputs();
 
+#if HAVE_SYSLOG_H
     /* 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 +1381,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 /* HAVE_SYSLOG_H */
 
     virLogOutputs = outputs;
     virLogNbOutputs = noutputs;
 
-    ret = 0;
- cleanup:
     virLogUnlock();
-    return ret;
+    return 0;
 }