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

Eric Blake eblake at redhat.com
Thu May 2 14:49:31 UTC 2013


On 05/02/2013 08:42 AM, Claudio Bley wrote:
> Since the warning only ever refers to directly casting a function
> return value, wouldn't it suffice to introduce a (properly typed)
> variable first assigning the function result?
> 
> pthread_t self = pthread_self();
> return (int)(intptr_t)self;

You _still_ need a (void*) in the mix; pthread_t and intptr_t are not
necessarily compatible, but everything should be compatible with void*.

But a union is still nicer than three casts in a row.

-- 
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/0680b579/attachment-0001.sig>


More information about the libvir-list mailing list