summaryrefslogtreecommitdiffstats
path: root/trace
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2012-08-13 21:51:16 +0200
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-08-14 13:19:57 +0100
commit4552e41025af4694c55854448c3ae4d95e72c7f6 (patch)
treec8af479920fd9a04cbeb6dba2b21d1eddf0c3c67 /trace
parent964d0a7b2bab935d48d3b2c4d6ab9b0efc74ce8b (diff)
downloadhqemu-4552e41025af4694c55854448c3ae4d95e72c7f6.zip
hqemu-4552e41025af4694c55854448c3ae4d95e72c7f6.tar.gz
trace/simple: Replace asprintf by g_strdup_printf
asprintf is not available for all hosts. g_strdup_printf is more portable and simplifies the code because if does not need error handling. The static variable does not need an explicit assignment to be NULL. Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'trace')
-rw-r--r--trace/simple.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/trace/simple.c b/trace/simple.c
index 8e175ec..d83681b 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -55,7 +55,7 @@ static unsigned int trace_idx;
static unsigned int writeout_idx;
static uint64_t dropped_events;
static FILE *trace_fp;
-static char *trace_file_name = NULL;
+static char *trace_file_name;
/* * Trace buffer entry */
typedef struct {
@@ -329,18 +329,12 @@ bool st_set_trace_file(const char *file)
{
st_set_trace_file_enabled(false);
- free(trace_file_name);
+ g_free(trace_file_name);
if (!file) {
- if (asprintf(&trace_file_name, CONFIG_TRACE_FILE, getpid()) < 0) {
- trace_file_name = NULL;
- return false;
- }
+ trace_file_name = g_strdup_printf(CONFIG_TRACE_FILE, getpid());
} else {
- if (asprintf(&trace_file_name, "%s", file) < 0) {
- trace_file_name = NULL;
- return false;
- }
+ trace_file_name = g_strdup_printf("%s", file);
}
st_set_trace_file_enabled(true);
OpenPOWER on IntegriCloud