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

Re: [libvirt] [PATCH] virthreadpthread: don't try to cast pthread_t to void*



On Thu, May 02, 2013 at 07:54:47AM -0600, Eric Blake wrote:
> On 05/02/2013 06:05 AM, Guido Günther wrote:
> > This fixes the build on kFreeBSD that otherwise fails with:
> > 
> > util/virthreadpthread.c: In function 'virThreadSelfID':
> > util/virthreadpthread.c:222:27: error: cast from function call of type 'pthread_t' to non-matching type 'void *' [-Werror=bad-function-cast]
> > ---
> > I'm unsure why we'd need the cast to (void*) first.
> 
> EVERYTHING should be castable to void*.  That's lame that your compiler
> is refusing to cast pthread_t.
> 
> I'm thinking that the solution will require writing a union, assign to
> the pthread_t member of the union, and read out the int member, as the
> only way we're going to shut up compilers.  We KNOW that casting
> pthread_t isn't portable; but all we really want is a few bits that are
> hopefully likely enough to be unique to make the use of virThreadSelfID
> useful in debug messages.  We aren't relying on the conversion being a
> 1:1 mapping nor on trying to reverse the mapping.

Yeah, using a union here sounds like a good idea.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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