]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: fix output of pid values
authorEric Blake <eblake@redhat.com>
Fri, 10 Feb 2012 23:52:01 +0000 (16:52 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 2 Mar 2012 13:57:57 +0000 (06:57 -0700)
Nuke the last vestiges of printing pid_t values with the wrong
types, at least in code compiled on mingw64.  There may be other
places, but for now they are only compiled on systems where the
existing %d doesn't trigger gcc warnings.

* src/rpc/virnetsocket.c (virNetSocketNew): Use %lld and casting,
rather than assuming any particular int type for pid_t.
* src/util/command.c (virCommandRunAsync, virPidWait)
(virPidAbort): Likewise.
(verify): Drop a now stale assertion.

src/rpc/virnetsocket.c
src/util/command.c

index 67d33b7fc07a0444d562d3e1c7fa5098644a23bc..af3f9ac4b5fb226a002abbd51ce2fbb723aaa21c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virnetsocket.c: generic network socket handling
  *
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -114,9 +114,9 @@ static virNetSocketPtr virNetSocketNew(virSocketAddrPtr localAddr,
     virNetSocketPtr sock;
     int no_slow_start = 1;
 
-    VIR_DEBUG("localAddr=%p remoteAddr=%p fd=%d errfd=%d pid=%d",
+    VIR_DEBUG("localAddr=%p remoteAddr=%p fd=%d errfd=%d pid=%lld",
               localAddr, remoteAddr,
-              fd, errfd, pid);
+              fd, errfd, (long long) pid);
 
     if (virSetCloseExec(fd) < 0) {
         virReportSystemError(errno, "%s",
@@ -174,9 +174,9 @@ static virNetSocketPtr virNetSocketNew(virSocketAddrPtr localAddr,
     sock->client = isClient;
 
     PROBE(RPC_SOCKET_NEW,
-          "sock=%p refs=%d fd=%d errfd=%d pid=%d localAddr=%s, remoteAddr=%s",
-          sock, sock->refs, fd, errfd,
-          pid, NULLSTR(sock->localAddrStr), NULLSTR(sock->remoteAddrStr));
+          "sock=%p refs=%d fd=%d errfd=%d pid=%lld localAddr=%s, remoteAddr=%s",
+          sock, sock->refs, fd, errfd, (long long) pid,
+          NULLSTR(sock->localAddrStr), NULLSTR(sock->remoteAddrStr));
 
     return sock;
 
index a2d5f842d4e4134b2a219a2424b95b42afbae10e..b752b2a23a5b2bb2e11dd2eb484b4925a6779bd2 100644 (file)
@@ -42,7 +42,6 @@
 #include "virpidfile.h"
 #include "buf.h"
 #include "ignore-value.h"
-#include "verify.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -50,9 +49,6 @@
     virReportErrorHelper(VIR_FROM_NONE, code, __FILE__,                 \
                          __FUNCTION__, __LINE__, __VA_ARGS__)
 
-/* We have quite a bit of changes to make if this doesn't hold.  */
-verify(sizeof(pid_t) <= sizeof(int));
-
 /* Flags for virExecWithHook */
 enum {
     VIR_EXEC_NONE   = 0,
@@ -2152,8 +2148,8 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
 
     if (cmd->pid != -1) {
         virCommandError(VIR_ERR_INTERNAL_ERROR,
-                        _("command is already running as pid %d"),
-                        cmd->pid);
+                        _("command is already running as pid %lld"),
+                        (long long) cmd->pid);
         return -1;
     }
 
@@ -2228,7 +2224,8 @@ virPidWait(pid_t pid, int *exitstatus)
     int status;
 
     if (pid <= 0) {
-        virReportSystemError(EINVAL, _("unable to wait for process %d"), pid);
+        virReportSystemError(EINVAL, _("unable to wait for process %lld"),
+                             (long long) pid);
         return -1;
     }
 
@@ -2237,7 +2234,8 @@ virPidWait(pid_t pid, int *exitstatus)
            errno == EINTR);
 
     if (ret == -1) {
-        virReportSystemError(errno, _("unable to wait for process %d"), pid);
+        virReportSystemError(errno, _("unable to wait for process %lld"),
+                             (long long) pid);
         return -1;
     }
 
@@ -2245,8 +2243,8 @@ virPidWait(pid_t pid, int *exitstatus)
         if (status != 0) {
             char *st = virCommandTranslateStatus(status);
             virCommandError(VIR_ERR_INTERNAL_ERROR,
-                            _("Child process (%d) status unexpected: %s"),
-                            pid, NULLSTR(st));
+                            _("Child process (%lld) status unexpected: %s"),
+                            (long long) pid, NULLSTR(st));
             VIR_FREE(st);
             return -1;
         }
@@ -2371,7 +2369,7 @@ virPidAbort(pid_t pid)
             }
         }
     }
-    VIR_DEBUG("failed to reap child %d, abandoning it", pid);
+    VIR_DEBUG("failed to reap child %lld, abandoning it", (long long) pid);
 
 cleanup:
     VIR_FREE(tmp);