Patchwork [v2] trace: Adapt trace file name for Haiku

login
register
mail settings
Submitter Andreas Färber
Date Oct. 10, 2010, 11:45 a.m.
Message ID <1286711116-431-1-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/67347/
State New
Headers show

Comments

Andreas Färber - Oct. 10, 2010, 11:45 a.m.
Cast the getpid() return value and adapt the format string.
Avoids the following warning:

  CC    simpletrace.o
/Data/QEMU/qemu/simpletrace.c: In function 'st_set_trace_file':
/Data/QEMU/qemu/simpletrace.c:77: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'pid_t'

v2:
* Don't use %lu for getpid() on Haiku since on x86_64 it returns an int.
  Always cast to long (largest allowed pid_t type) and use %ld instead.
  Suggested by Ingo Weinhold.

Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Ingo Weinhold <ingo_weinhold@gmx.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 configure     |    2 +-
 simpletrace.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Stefan Hajnoczi - Oct. 11, 2010, 9:23 a.m.
Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Patch

diff --git a/configure b/configure
index d303061..457d98c 100755
--- a/configure
+++ b/configure
@@ -2609,7 +2609,7 @@  if test "$trace_backend" = "simple"; then
 fi
 # Set the appropriate trace file.
 if test "$trace_backend" = "simple"; then
-  trace_file="\"$trace_file-%u\""
+  trace_file="\"$trace_file-%ld\""
 fi
 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
 
diff --git a/simpletrace.c b/simpletrace.c
index f849e42..9ee5c3b 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -74,7 +74,7 @@  bool st_set_trace_file(const char *file)
     free(trace_file_name);
 
     if (!file) {
-        if (asprintf(&trace_file_name, CONFIG_TRACE_FILE, getpid()) < 0) {
+        if (asprintf(&trace_file_name, CONFIG_TRACE_FILE, (long)getpid()) < 0) {
             trace_file_name = NULL;
             return false;
         }