Bug#362422: FTBFS with GCC 4.2: the address of 'hwparams' will always evaluate as 'true'

Martin Michlmayr tbm at cyrius.com
Tue May 16 14:03:57 UTC 2006


I'm CCing Ben Elliston who I think introduced this warning in GCC and
Roger Sayle who is a GCC developer and who made a comment regarding
this warning according to Google.

* Samuel Mimram <smimram at debian.org> [2006-05-15 20:20]:
> > > cc1: warnings being treated as errors
> > > alsa.c: In function 'alsa_set_params':
> > > alsa.c:55: warning: the address of 'hwparams', will always evaluate as 'true'
> > > alsa.c:128: warning: the address of 'swparams', will always evaluate as 'true'
> > > make[5]: *** [alsa.lo] Error 1
> 
> The relevant part of alsa.c in linphone is:
> 
> snd_pcm_hw_params_t *hwparams=NULL;
> snd_pcm_hw_params_alloca(&hwparams);
> 
> The function snd_pcm_hw_params_alloca is defined by alsa
> (libasound2-dev) in pcm.h by:
> 
> #define snd_pcm_hw_params_alloca(ptr) do { assert(ptr); *ptr =
> (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); memset(*ptr,
> 0, snd_pcm_hw_params_sizeof()); } while (0)
> 
> So, I guess the warning comes from the assert(ptr) where ptr will always
> be != 0. In my opinion, an assert(true) should not raise a warning...
> 
> It seems to be confirmed by the following test:
> 
> $ cat test.c
> #include <alsa/asoundlib.h>
> 
> int main()
> {
>         snd_pcm_hw_params_t *hwparams=NULL;
>         assert(&hwparams);
>         return 0;
> }
> 
> $ gcc -Werror -Wall test.c -o test
> cc1: warnings being treated as errors
> test.c: In function 'main':
> test.c:6: warning: the address of 'hwparams', will always evaluate as 'true'
> 
> Should I reassign this to gcc, or is it a bug in linphone (should I remove
> the -Werror)?

GCC folks, can you comment?
-- 
Martin Michlmayr
http://www.cyrius.com/




More information about the Pkg-voip-maintainers mailing list