From patchwork Tue Feb 12 13:34:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [for-1.4,1/2] trace: use glib atomic int types Date: Tue, 12 Feb 2013 03:34:04 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 219856 Message-Id: <1360676045-9204-2-git-send-email-stefanha@redhat.com> To: Cc: Anthony Liguori , Stefan Hajnoczi , Juan Quintela Juan reported that RHEL 6.4 hosts give compiler warnings because we use unsigned int while glib prototypes use volatile gint in trace/simple.c. trace/simple.c:223: error: pointer targets in passing argument 1 of 'g_atomic_int_compare_and_exchange' differ in signedness These variables are only accessed with glib atomic int functions so let's play it by the book and use volatile gint. Reported-by: Juan Quintela Signed-off-by: Stefan Hajnoczi --- trace/simple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trace/simple.c b/trace/simple.c index 74701e3..1d5d8e4 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -51,9 +51,9 @@ enum { }; uint8_t trace_buf[TRACE_BUF_LEN]; -static unsigned int trace_idx; +static volatile gint trace_idx; static unsigned int writeout_idx; -static int dropped_events; +static volatile gint dropped_events; static FILE *trace_fp; static char *trace_file_name; @@ -267,7 +267,7 @@ void trace_record_finish(TraceBufferRecord *rec) record.event |= TRACE_RECORD_VALID; write_to_buffer(rec->tbuf_idx, &record, sizeof(TraceRecord)); - if ((g_atomic_int_get(&trace_idx) - writeout_idx) + if (((unsigned int)g_atomic_int_get(&trace_idx) - writeout_idx) > TRACE_BUF_FLUSH_THRESHOLD) { flush_trace_file(false); }