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 Thu, May 02, 2013 at 02:05:19PM +0200, 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.
>  -- Guido
> 
>  src/util/virthreadpthread.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virthreadpthread.c b/src/util/virthreadpthread.c
> index b42b333..8d5e197 100644
> --- a/src/util/virthreadpthread.c
> +++ b/src/util/virthreadpthread.c
> @@ -219,7 +219,7 @@ int virThreadSelfID(void)
>      tid = syscall(SYS_gettid);
>      return (int)tid;
>  #else
> -    return (int)(intptr_t)(void *)pthread_self();
> +    return (int)(intptr_t)pthread_self();
>  #endif

This was introduced in

commit 4d970fd2938a0558444cddb4f5f5e63b910b5527
Author: Eric Blake <eblake@xxxxxxxxxx>
Date:   Fri Nov 4 16:32:30 2011 -0600

    build: silence compiler warning on BSD
    
    Building on 64-bit FreeBSD 8.2 complained about a cast between
    a pointer and a smaller integer.  Going through an intermediate
    cast shuts up the compiler.
    
    * src/util/threads-pthread.c (virThreadSelfID): Silence a warning.

diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 82ce5c6..5b8fd5b 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -216,7 +216,7 @@ int virThreadSelfID(void)
     tid = syscall(SYS_gettid);
     return (int)tid;
 #else
-    return (int)(void *)pthread_self();
+    return (int)(intptr_t)(void *)pthread_self();


Before removing the 'void *' we need to check it won't break
FreeBSD again.


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

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