From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSC9s-0004E0-Ba for qemu-devel@nongnu.org; Thu, 02 Jun 2011 13:58:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSC9q-0007mj-KF for qemu-devel@nongnu.org; Thu, 02 Jun 2011 13:58:12 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:57645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSC9p-0007mD-Ul for qemu-devel@nongnu.org; Thu, 02 Jun 2011 13:58:10 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 2 Jun 2011 19:58:06 +0200 Message-Id: <1307037486-8209-1-git-send-email-andreas.faerber@web.de> In-Reply-To: <20101011092342.GA3752@stefan-thinkpad.transitives.com> References: <20101011092342.GA3752@stefan-thinkpad.transitives.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: andreas.faerber@web.de Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v3] Introduce format string for pid_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: haikuports-devs@lists.ports.haiku-files.org, Gleb Natapov , Stefan Hajnoczi , Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Ingo Weinhold BeOS and Haiku on i386 use long for 32-bit types, including pid_t. Using %d with pid_t therefore results in a warning. Unfortunately POSIX:2008 does not define a PRId* string for pid_t. In some places pid_t was previously casted to long and %ld hardcoded. The predecessor of this patch added another upcast for the simpletrace filename but was not applied to date. Since new uses of pid_t with %d keep creeping in, let's instead define an OS-dependent format string and use that consistently. Cc: Stefan Hajnoczi Cc: Blue Swirl Cc: Ingo Weinhold Cc: Gleb Natapov Signed-off-by: Andreas F=C3=A4rber --- v2: Use %ld and long instead of %lu for Haiku for x86_64 compatibility. =20 configure | 2 +- os-posix.c | 2 +- os-win32.c | 2 +- osdep.h | 6 ++++++ vl.c | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/configure b/configure index a318d37..0f2b6bf 100755 --- a/configure +++ b/configure @@ -3037,7 +3037,7 @@ if test "$trace_backend" =3D "simple"; then fi # Set the appropriate trace file. if test "$trace_backend" =3D "simple"; then - trace_file=3D"\"$trace_file-%u\"" + trace_file=3D"\"$trace_file-\" FMT_pid" fi if test "$trace_backend" =3D "dtrace" -a "$trace_backend_stap" =3D "yes"= ; then echo "CONFIG_SYSTEMTAP_TRACE=3Dy" >> $config_host_mak diff --git a/os-posix.c b/os-posix.c index 3204197..7dfb278 100644 --- a/os-posix.c +++ b/os-posix.c @@ -368,7 +368,7 @@ int qemu_create_pidfile(const char *filename) if (lockf(fd, F_TLOCK, 0) =3D=3D -1) { return -1; } - len =3D snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid()); + len =3D snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid()); if (write(fd, buffer, len) !=3D len) { return -1; } diff --git a/os-win32.c b/os-win32.c index d6d54c6..b6652af 100644 --- a/os-win32.c +++ b/os-win32.c @@ -258,7 +258,7 @@ int qemu_create_pidfile(const char *filename) if (file =3D=3D INVALID_HANDLE_VALUE) { return -1; } - len =3D snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid()); + len =3D snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid()); ret =3D WriteFileEx(file, (LPCVOID)buffer, (DWORD)len, &overlap, NULL); if (ret =3D=3D 0) { diff --git a/osdep.h b/osdep.h index 970d767..97d167a 100644 --- a/osdep.h +++ b/osdep.h @@ -127,6 +127,12 @@ void qemu_vfree(void *ptr); =20 int qemu_madvise(void *addr, size_t len, int advice); =20 +#if defined(__HAIKU__) && defined(__i386__) +#define FMT_pid "%ld" +#else +#define FMT_pid "%d" +#endif + int qemu_create_pidfile(const char *filename); int qemu_get_thread_id(void); =20 diff --git a/vl.c b/vl.c index b362871..b7b98f0 100644 --- a/vl.c +++ b/vl.c @@ -1191,7 +1191,7 @@ void qemu_kill_report(void) */ fputc('\n', stderr); } else { - fprintf(stderr, " from pid %d\n", shutdown_pid); + fprintf(stderr, " from pid " FMT_pid "\n", shutdown_pid); } shutdown_signal =3D -1; } --=20 1.7.5.2.317.g391b14