From: Blue Swirl <blauwirbel@gmail.com>
To: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] simpletrace: Move st_init() error reporting
Date: Tue, 15 Mar 2011 20:15:06 +0200 [thread overview]
Message-ID: <AANLkTin34bCpHH=ktxtVG6W+msV2xf1Xb0xJY6cv+r_d@mail.gmail.com> (raw)
In-Reply-To: <1300047270-22889-1-git-send-email-stefanha@linux.vnet.ibm.com>
Thanks, applied.
On Sun, Mar 13, 2011 at 10:14 PM, Stefan Hajnoczi
<stefanha@linux.vnet.ibm.com> wrote:
> 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 <blauwirbel@gmail.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
> 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 <time.h>
> #include <signal.h>
> #include <pthread.h>
> -#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
>
>
prev parent reply other threads:[~2011-03-15 18:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-13 20:14 [Qemu-devel] [PATCH] simpletrace: Move st_init() error reporting Stefan Hajnoczi
2011-03-15 18:15 ` Blue Swirl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTin34bCpHH=ktxtVG6W+msV2xf1Xb0xJY6cv+r_d@mail.gmail.com' \
--to=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).