[patch] Missing casts in gcrypt.h

Andreas Metzler ametzler at downhill.at.eu.org
Sat Jul 8 18:08:45 CEST 2006


Hej,
this is http://bugs.debian.org/362636 reported by Erik Meusel.
| when I try to use GCRY_THREAD_OPTION_PTHREAD_IMPL from
| /usr/include/gcrypt.h with g++, there are compilation problems due to
| missing casts from void * to pthread_mutex_t * and back. The following
| version works for me quite well:

suggested simple patch (by Erik) is attached. This applies to both
1.2.2 and svn trunk.
  thanks, cu andreas
-- 
The 'Galactic Cleaning' policy undertaken by Emperor Zhark is a personal
vision of the emperor's, and its inclusion in this work does not constitute
tacit approval by the author or the publisher for any such projects,
howsoever undertaken.                                (c) Jasper Ffforde
-------------- next part --------------
diff -Nur libgcrypt11-1.2.2/src/gcrypt.h libgcrypt11-1.2.2.new/src/gcrypt.h
--- libgcrypt11-1.2.2/src/gcrypt.h	2005-10-05 09:44:00.000000000 +0100
+++ libgcrypt11-1.2.2.new/src/gcrypt.h	2006-06-08 16:55:37.000000000 +0100
@@ -257,7 +257,7 @@
 static int gcry_pthread_mutex_init (void **priv)			      \
 {									      \
   int err = 0;								      \
-  pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t));		      \
+  pthread_mutex_t *lock = (pthread_mutex_t*) malloc (sizeof (pthread_mutex_t));		      \
 									      \
   if (!lock)								      \
     err = ENOMEM;							      \
@@ -272,11 +272,11 @@
   return err;								      \
 }									      \
 static int gcry_pthread_mutex_destroy (void **lock)			      \
-  { int err = pthread_mutex_destroy (*lock);  free (*lock); return err; }     \
+  { int err = pthread_mutex_destroy ((pthread_mutex_t*) *lock);  free (*lock); return err; }     \
 static int gcry_pthread_mutex_lock (void **lock)			      \
-  { return pthread_mutex_lock (*lock); }				      \
+  { return pthread_mutex_lock ((pthread_mutex_t*) *lock); }				      \
 static int gcry_pthread_mutex_unlock (void **lock)			      \
-  { return pthread_mutex_unlock (*lock); }				      \
+  { return pthread_mutex_unlock ((pthread_mutex_t*) *lock); }				      \
 									      \
 static struct gcry_thread_cbs gcry_threads_pthread =			      \
 { GCRY_THREAD_OPTION_PTHREAD, NULL,					      \


More information about the Gcrypt-devel mailing list