[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt PATCH 07/19] Move debug statements after declarations



Many of our functions start with a DEBUG statement.
Move the statements after declarations to appease
our coding style.

Signed-off-by: Ján Tomko <jtomko redhat com>
---
 src/lxc/lxc_container.c                   |  4 +++-
 src/nwfilter/nwfilter_ebiptables_driver.c |  8 ++++++--
 src/qemu/qemu_domain.c                    |  6 ++++--
 src/qemu/qemu_monitor.c                   |  9 ++++++---
 src/remote/remote_daemon_dispatch.c       |  6 +++---
 src/remote/remote_daemon_stream.c         | 13 ++++++++-----
 src/remote/remote_driver.c                | 21 ++++++++++++---------
 src/rpc/virnetclient.c                    |  4 +++-
 src/storage/storage_backend_disk.c        |  2 +-
 src/storage/storage_file_fs.c             |  3 ++-
 src/util/virdbus.c                        |  2 +-
 src/util/virfirewall.c                    |  3 ++-
 src/util/virnetdevip.c                    |  4 +++-
 src/util/virobject.c                      |  5 +++--
 src/util/virprocess.c                     |  3 ++-
 src/util/virstoragefile.c                 |  8 ++++----
 16 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 6e98f133a9..ede419c275 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -291,8 +291,10 @@ static int lxcContainerSetupFDs(int *ttyfd,
          */
         for (j = i + 1; j < npassFDs; j++) {
             if (passFDs[j] == wantfd) {
-                VIR_DEBUG("Clash %zu", j);
                 int newfd = dup(passFDs[j]);
+
+                VIR_DEBUG("Clash %zu", j);
+
                 if (newfd < 0) {
                     virReportSystemError(errno,
                                          _("Cannot move fd %d out of the way"),
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 6aefbe226b..e73aa82eb4 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -2655,8 +2655,10 @@ ebtablesRemoveSubChainsQuery(virFirewallPtr fw,
     const char *chainprefixes = opaque;
 
     for (i = 0; lines[i] != NULL; i++) {
-        VIR_DEBUG("Considering '%s'", lines[i]);
         char *tmp = strstr(lines[i], "-j ");
+
+        VIR_DEBUG("Considering '%s'", lines[i]);
+
         if (!tmp)
             continue;
         tmp = tmp + 3;
@@ -2757,8 +2759,10 @@ ebtablesRenameTmpSubAndRootChainsQuery(virFirewallPtr fw,
     char newchain[MAX_CHAINNAME_LENGTH];
 
     for (i = 0; lines[i] != NULL; i++) {
-        VIR_DEBUG("Considering '%s'", lines[i]);
         char *tmp = strstr(lines[i], "-j ");
+
+        VIR_DEBUG("Considering '%s'", lines[i]);
+
         if (!tmp)
             continue;
         tmp = tmp + 3;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e5d6430a89..56999c2c46 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6222,12 +6222,14 @@ int qemuDomainLogContextWrite(qemuDomainLogContextPtr ctxt,
 ssize_t qemuDomainLogContextRead(qemuDomainLogContextPtr ctxt,
                                  char **msg)
 {
+    char *buf;
+    size_t buflen;
+
     VIR_DEBUG("Context read %p manager=%p inode=%llu pos=%llu",
               ctxt, ctxt->manager,
               (unsigned long long)ctxt->inode,
               (unsigned long long)ctxt->pos);
-    char *buf;
-    size_t buflen;
+
     if (ctxt->manager) {
         buf = virLogManagerDomainReadLogFile(ctxt->manager,
                                              ctxt->path,
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 637361d24d..718ac50c08 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2838,8 +2838,9 @@ qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
                            int fd,
                            const char *fdname)
 {
+    int ret;
+
     VIR_DEBUG("device=%s fd=%d fdname=%s", devicestr, fd, NULLSTR(fdname));
-    int ret;
 
     QEMU_CHECK_MONITOR(mon);
 
@@ -3458,9 +3459,10 @@ qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                         const char *fdname,
                         bool skipauth)
 {
+    int ret;
+
     VIR_DEBUG("protocol=%s fd=%d fdname=%s skipauth=%d",
               protocol, fd, NULLSTR(fdname), skipauth);
-    int ret;
 
     QEMU_CHECK_MONITOR(mon);
 
@@ -4168,8 +4170,9 @@ int
 qemuMonitorGetMemoryDeviceInfo(qemuMonitorPtr mon,
                                virHashTablePtr *info)
 {
+    int ret;
+
     VIR_DEBUG("info=%p", info);
-    int ret;
 
     *info = NULL;
 
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index c91b5d3293..404712e7c8 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1621,10 +1621,10 @@ static
 void remoteRelayConnectionClosedEvent(virConnectPtr conn G_GNUC_UNUSED, int reason, void *opaque)
 {
     virNetServerClientPtr client = opaque;
-
-    VIR_DEBUG("Relaying connection closed event, reason %d", reason);
-
     remote_connect_event_connection_closed_msg msg = { reason };
+
+    VIR_DEBUG("Relaying connection closed event, reason %d", reason);
+
     remoteDispatchObjectEventSend(client, remoteProgram,
                                   REMOTE_PROC_CONNECT_EVENT_CONNECTION_CLOSED,
                                   (xdrproc_t)xdr_remote_connect_event_connection_closed_msg,
diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 73e4d7befb..9a62189cd6 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -434,9 +434,10 @@ int daemonAddClientStream(virNetServerClientPtr client,
                           daemonClientStream *stream,
                           bool transmit)
 {
+    daemonClientPrivatePtr priv = virNetServerClientGetPrivateData(client);
+
     VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p, transmit=%d",
               client, stream->procedure, stream->serial, stream->st, transmit);
-    daemonClientPrivatePtr priv = virNetServerClientGetPrivateData(client);
 
     if (stream->filterID != -1) {
         VIR_WARN("Filter already added to client %p", client);
@@ -484,12 +485,13 @@ int
 daemonRemoveClientStream(virNetServerClientPtr client,
                          daemonClientStream *stream)
 {
-    VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p",
-              client, stream->procedure, stream->serial, stream->st);
     daemonClientPrivatePtr priv = virNetServerClientGetPrivateData(client);
     daemonClientStream *curr = priv->streams;
     daemonClientStream *prev = NULL;
 
+    VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p",
+              client, stream->procedure, stream->serial, stream->st);
+
     if (stream->filterID != -1) {
         virNetServerClientRemoveFilter(client,
                                        stream->filterID);
@@ -648,11 +650,12 @@ daemonStreamHandleAbort(virNetServerClientPtr client,
                         daemonClientStream *stream,
                         virNetMessagePtr msg)
 {
-    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u",
-              client, stream, msg->header.proc, msg->header.serial);
     int ret;
     bool raise_error = false;
 
+    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u",
+              client, stream, msg->header.proc, msg->header.serial);
+
     stream->closed = true;
     virStreamEventRemoveCallback(stream->st);
     ret = virStreamAbort(stream->st);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2402f73475..8654046b8d 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5691,10 +5691,11 @@ remoteStreamSend(virStreamPtr st,
                  const char *data,
                  size_t nbytes)
 {
+    struct private_data *priv = st->conn->privateData;
+    virNetClientStreamPtr privst = st->privateData;
+    int rv;
+
     VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
-    struct private_data *priv = st->conn->privateData;
-    virNetClientStreamPtr privst = st->privateData;
-    int rv;
 
     remoteDriverLock(priv);
     priv->localUses++;
@@ -5719,11 +5720,12 @@ remoteStreamRecvFlags(virStreamPtr st,
                       size_t nbytes,
                       unsigned int flags)
 {
+    struct private_data *priv = st->conn->privateData;
+    virNetClientStreamPtr privst = st->privateData;
+    int rv;
+
     VIR_DEBUG("st=%p data=%p nbytes=%zu flags=0x%x",
               st, data, nbytes, flags);
-    struct private_data *priv = st->conn->privateData;
-    virNetClientStreamPtr privst = st->privateData;
-    int rv;
 
     virCheckFlags(VIR_STREAM_RECV_STOP_AT_HOLE, -1);
 
@@ -5760,11 +5762,12 @@ remoteStreamSendHole(virStreamPtr st,
                      long long length,
                      unsigned int flags)
 {
+    struct private_data *priv = st->conn->privateData;
+    virNetClientStreamPtr privst = st->privateData;
+    int rv;
+
     VIR_DEBUG("st=%p length=%lld flags=0x%x",
               st, length, flags);
-    struct private_data *priv = st->conn->privateData;
-    virNetClientStreamPtr privst = st->privateData;
-    int rv;
 
     remoteDriverLock(priv);
     priv->localUses++;
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 441f1502a6..42703664fe 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1556,8 +1556,10 @@ static void
 virNetClientIOEventLoopPassTheBuck(virNetClientPtr client,
                                    virNetClientCallPtr thiscall)
 {
-    VIR_DEBUG("Giving up the buck %p", thiscall);
     virNetClientCallPtr tmp = client->waitDispatch;
+
+    VIR_DEBUG("Giving up the buck %p", thiscall);
+
     /* See if someone else is still waiting
      * and if so, then pass the buck ! */
     while (tmp) {
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index eae23ec24a..a6d4e41220 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -673,10 +673,10 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
     virStoragePoolSourceDevicePtr dev = &def->source.devices[0];
     unsigned long long cylinderSize = (unsigned long long)dev->geometry.heads *
                                       dev->geometry.sectors * SECTOR_SIZE;
+    int partType = virStorageBackendDiskPartTypeToCreate(pool);
 
     VIR_DEBUG("find free area: allocation %llu, cyl size %llu", allocation,
           cylinderSize);
-    int partType = virStorageBackendDiskPartTypeToCreate(pool);
 
     /* how many extra bytes we have since we allocate
        aligned to the cylinder boundary */
diff --git a/src/storage/storage_file_fs.c b/src/storage/storage_file_fs.c
index 8aafd58992..8d9023bead 100644
--- a/src/storage/storage_file_fs.c
+++ b/src/storage/storage_file_fs.c
@@ -51,11 +51,12 @@ struct _virStorageFileBackendFsPriv {
 static void
 virStorageFileBackendFileDeinit(virStorageSourcePtr src)
 {
+    virStorageFileBackendFsPrivPtr priv = src->drv->priv;
+
     VIR_DEBUG("deinitializing FS storage file %p (%s:%s)", src,
               virStorageTypeToString(virStorageSourceGetActualType(src)),
               src->path);
 
-    virStorageFileBackendFsPrivPtr priv = src->drv->priv;
 
     VIR_FREE(priv->canonpath);
     VIR_FREE(priv);
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index f512031b42..fbfc09c949 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -862,8 +862,8 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
         dbustype *x = (dbustype *)&v.member; \
         vargtype *y; \
         if (arrayref) { \
-            VIR_DEBUG("Use arrayref"); \
             vargtype **xptrptr = arrayptr; \
+            VIR_DEBUG("Use arrayref"); \
             if (VIR_EXPAND_N(*xptrptr, *narrayptr, 1) < 0) \
                 goto cleanup; \
             y = (*xptrptr + (*narrayptr - 1)); \
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 12905165d4..22e717bce4 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -830,10 +830,11 @@ virFirewallApply(virFirewallPtr firewall)
     VIR_DEBUG("Applying groups for %p", firewall);
     for (i = 0; i < firewall->ngroups; i++) {
         if (virFirewallApplyGroup(firewall, i) < 0) {
-            VIR_DEBUG("Rolling back groups up to %zu for %p", i, firewall);
             size_t first = i;
             virErrorPtr saved_error;
 
+            VIR_DEBUG("Rolling back groups up to %zu for %p", i, firewall);
+
             virErrorPreserveLast(&saved_error);
 
             /*
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 409f062c5c..8c66baa884 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -296,8 +296,10 @@ virNetDevIPRouteAdd(const char *ifname,
 
     /* If we have no valid network address, then use the default one */
     if (!addr || !VIR_SOCKET_ADDR_VALID(addr)) {
-        VIR_DEBUG("computing default address");
         int family = VIR_SOCKET_ADDR_FAMILY(gateway);
+
+        VIR_DEBUG("computing default address");
+
         if (family == AF_INET) {
             if (virSocketAddrParseIPv4(&defaultAddr, VIR_SOCKET_ADDR_IPV4_ALL) < 0)
                 return -1;
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 3f0bcc38ea..a6305354c3 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -315,11 +315,12 @@ virObjectRWLockableNew(virClassPtr klass)
 
 static void vir_object_finalize(GObject *gobj)
 {
-    PROBE(OBJECT_DISPOSE, "obj=%p", gobj);
     virObjectPtr obj = VIR_OBJECT(gobj);
     virObjectPrivate *priv = vir_object_get_instance_private(obj);
-
     virClassPtr klass = priv->klass;
+
+    PROBE(OBJECT_DISPOSE, "obj=%p", gobj);
+
     while (klass) {
         if (klass->dispose)
             klass->dispose(obj);
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index a9afa2e665..6f03627c42 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -444,11 +444,12 @@ int virProcessKillPainfully(pid_t pid, bool force)
 int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
 {
     size_t i;
-    VIR_DEBUG("Set process affinity on %lld", (long long)pid);
     int numcpus = 1024;
     size_t masklen;
     cpu_set_t *mask;
 
+    VIR_DEBUG("Set process affinity on %lld", (long long)pid);
+
     /* Not only may the statically allocated cpu_set_t be too small,
      * but there is no way to ask the kernel what size is large enough.
      * So you have no option but to pick a size, try, catch EINVAL,
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index f529f0faf3..51037c691f 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -5335,14 +5335,14 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
                           uid_t uid, gid_t gid,
                           bool report_broken)
 {
+    virHashTablePtr cycle = NULL;
+    virStorageType actualType = virStorageSourceGetActualType(src);
+    int ret = -1;
+
     VIR_DEBUG("path=%s format=%d uid=%u gid=%u report_broken=%d",
               src->path, src->format, (unsigned int)uid, (unsigned int)gid,
               report_broken);
 
-    virHashTablePtr cycle = NULL;
-    virStorageType actualType = virStorageSourceGetActualType(src);
-    int ret = -1;
-
     if (!(cycle = virHashCreate(5, NULL)))
         return -1;
 
-- 
2.26.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]