[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 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

Attachment: signature.asc
Description: OpenPGP digital signature


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