From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33796 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pyrgp-0001iY-Hx for qemu-devel@nongnu.org; Sun, 13 Mar 2011 16:15:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pyrgo-0004qZ-DS for qemu-devel@nongnu.org; Sun, 13 Mar 2011 16:14:59 -0400 Received: from mtagate6.uk.ibm.com ([194.196.100.166]:42401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pyrgo-0004q3-6O for qemu-devel@nongnu.org; Sun, 13 Mar 2011 16:14:58 -0400 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate6.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p2DKEsRP016980 for ; Sun, 13 Mar 2011 20:14:54 GMT Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2DKFC0T1704136 for ; Sun, 13 Mar 2011 20:15:12 GMT Received: from d06av11.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2DKEs5t030425 for ; Sun, 13 Mar 2011 14:14:54 -0600 From: Stefan Hajnoczi Date: Sun, 13 Mar 2011 20:14:30 +0000 Message-Id: <1300047270-22889-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] simpletrace: Move st_init() error reporting List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Stefan Hajnoczi User emulator builds do not have error_report() so it should not be used by simpletrace.c. In fact, error reporting inside simpletrace.c is inappropriate and should be done by the caller instead. This patch moves st_init() error reporting out to its caller, vl.c:main(). Reported-by: Blue Swirl Signed-off-by: Stefan Hajnoczi --- simpletrace.c | 7 +++---- simpletrace.h | 6 +++--- vl.c | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/simpletrace.c b/simpletrace.c index 9926ab3..f1dbb5e 100644 --- a/simpletrace.c +++ b/simpletrace.c @@ -14,7 +14,6 @@ #include #include #include -#include "qerror.h" #include "qemu-timer.h" #include "trace.h" @@ -331,7 +330,7 @@ void st_flush_trace_buffer(void) flush_trace_file(true); } -void st_init(const char *file) +bool st_init(const char *file) { pthread_t thread; pthread_attr_t attr; @@ -347,10 +346,10 @@ void st_init(const char *file) pthread_sigmask(SIG_SETMASK, &oldset, NULL); if (ret != 0) { - error_report("warning: unable to create trace file thread\n"); - return; + return false; } atexit(st_flush_trace_buffer); st_set_trace_file(file); + return true; } diff --git a/simpletrace.h b/simpletrace.h index 3a5bd9f..8d893bd 100644 --- a/simpletrace.h +++ b/simpletrace.h @@ -37,11 +37,11 @@ void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf); void st_set_trace_file_enabled(bool enable); bool st_set_trace_file(const char *file); void st_flush_trace_buffer(void); -void st_init(const char *file); +bool st_init(const char *file); #else -static inline void st_init(const char *file) +static inline bool st_init(const char *file) { - /* Do nothing */ + return true; } #endif /* !CONFIG_SIMPLE_TRACE */ diff --git a/vl.c b/vl.c index f500c4c..6e6a1ff 100644 --- a/vl.c +++ b/vl.c @@ -2748,7 +2748,9 @@ int main(int argc, char **argv, char **envp) } loc_set_none(); - st_init(trace_file); + if (!st_init(trace_file)) { + fprintf(stderr, "warning: unable to initialize simple trace backend\n"); + } /* If no data_dir is specified then try to find it relative to the executable path. */ -- 1.7.2.3