qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-1.4 1/2] trace: use glib atomic int types


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH for-1.4 1/2] trace: use glib atomic int types
Date: Wed, 13 Feb 2013 13:29:40 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Feb 13, 2013 at 01:25:02PM +0100, Juan Quintela wrote:
> Markus Armbruster <address@hidden> wrote:
> > Stefan Hajnoczi <address@hidden> writes:
> >
> >> 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
> >
> > Meh.  Contrary to documentation and how current GLib versions behave, in
> > other words a bug in need of a workaround.
> >
> >> These variables are only accessed with glib atomic int functions so
> >> let's play it by the book and use volatile gint.
> >
> > gint is a silly alias for int, and used completely interchangeably, even
> > within GLib APIs.  Any pretentions of treating it as something more
> > abstract break down at the first printf(), if not earlier.  But if you
> > think it helps...
> 
> >> -static unsigned int trace_idx;
> >> +static volatile gint trace_idx;
> 
> Problem was this bit.  int vs unsigned.

We only access the variable through the glib API, never directly.  So in
this case I don't see much benefit in using nicer types, better to
conform precisely to the function declaration.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]