[gnupg-devel] gnupg-2.0.19: common/estream.c mixes void and int

Werner Koch wk at gnupg.org
Fri Mar 30 15:18:08 CEST 2012


On Wed, 28 Mar 2012 18:06, beebe at math.utah.edu said:

> The cause appears to be mixing of void and int in the file
> common/estream.c in the definitions of the macros
> ESTREAM_MUTEX_LOCK() .. ESTREAM_MUTEX_INITIALIZE() in
> lines 177--188.

okay, the fix is:

 # define ESTREAM_MUTEX_LOCK(mutex)                              \
   (estream_pth_killed ? dummy_mutex_call_void ((mutex))         \
-   : pth_mutex_acquire (&(mutex), 0, NULL))
+   : (void)pth_mutex_acquire (&(mutex), 0, NULL))

> In function es_ftrylockfile() at line 2619, the value of
> ESTREAM_TRYLOCK() is returned as an int, but a void cannot
> be cast to an int.

Hmmm, I can see the problem.  We have:
  
  # define ESTREAM_MUTEX_TRYLOCK(mutex)                                   \
    (estream_pth_killed ? dummy_mutex_call_int ((mutex))                  \
     : ((pth_mutex_acquire (&(mutex), 1, NULL) == TRUE)? 0:-1))
    
  #define ESTREAM_TRYLOCK(stream) ESTREAM_MUTEX_TRYLOCK (stream->intern->lock)
  
  int
  es_ftrylockfile (estream_t stream)
  {
    return ESTREAM_TRYLOCK (stream);
  }
  
Thus, we either call a dummy functions which returns an int
(dummy_mutex_call_int) or the result of the condition which is eitehr o
or -1.

> % ./configure --help | grep pth
>   --with-pth-prefix=PFX   prefix where GNU Pth is installed (optional)
>
> says that Pth is optional.  Either it is optional, or it is
> required, but only one can be true.

The help string is wrong.  We need Pth.


Shalom-Salam,

   Werner

-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gnupg-devel mailing list