Daniel P. Berrange wrote: > 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. This change indeed brings a warning on FreeBSD: In file included from util/virthread.c:31: util/virthreadpthread.c: In function 'virThreadSelfID': util/virthreadpthread.c:222: warning: cast from function call of type 'pthread_t' to non-matching type 'long int' [-Wbad-function-cast] Roman Bogorodskiy
Attachment:
pgpbu15WS6MQt.pgp
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list