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

Eric Blake eblake at redhat.com
Thu May 2 13:54:47 UTC 2013


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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130502/0d7e9e61/attachment-0001.sig>


More information about the libvir-list mailing list