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

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]