diff mbox

qemu-kvm: fix pulseaudio detection in configure

Message ID BANLkTim7utDK7kQn-zKUGyF8QTMMF4Sqog@mail.gmail.com
State New
Headers show

Commit Message

Marc-Antoine Perennou April 29, 2011, 3:59 p.m. UTC
pulse/simple.h does not include stdlib.h
We cannot use NULL since it may not be defined
Use 0 instead

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Marc-Antoine Perennou May 27, 2011, 9 a.m. UTC | #1
Any chance to get this reviewed/applied any time soon ? It currently
does not build without it with gcc 4.6.0

On 29 April 2011 17:59, Marc-Antoine Perennou <Marc-Antoine@perennou.com> wrote:
> pulse/simple.h does not include stdlib.h
> We cannot use NULL since it may not be defined
> Use 0 instead
>
> Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
> ---
>  configure |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index ea8b676..d67c3ce 100755
> --- a/configure
> +++ b/configure
> @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
>
>     pa)
>     audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
> -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
> +        "pa_simple *s = 0; pa_simple_free(s); return 0;"
>     libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
>     audio_pt_int="yes"
>     ;;
> --
> 1.7.5.52.ge839f.dirty
>
Aurelien Jarno June 3, 2011, 8:33 p.m. UTC | #2
On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
> pulse/simple.h does not include stdlib.h
> We cannot use NULL since it may not be defined
> Use 0 instead

I am unable to reproduce this issue, even with gcc-4.6. Also please note
that NULL is defined in <stddef.h>, not <stdlib.h>. <stddef.h> is 
included from <sys/types.h> which is included from <pulse/simple.h>.

Do you have more information about the issue.

> Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
> ---
>  configure |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/configure b/configure
> index ea8b676..d67c3ce 100755
> --- a/configure
> +++ b/configure
> @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
> 
>      pa)
>      audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
> -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
> +        "pa_simple *s = 0; pa_simple_free(s); return 0;"

It should be ((void*)0) instead of simply 0.

>      libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
>      audio_pt_int="yes"
>      ;;
> -- 
> 1.7.5.52.ge839f.dirty
> 
>
malc June 3, 2011, 9:57 p.m. UTC | #3
On Fri, 3 Jun 2011, Aurelien Jarno wrote:

> On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
> > pulse/simple.h does not include stdlib.h
> > We cannot use NULL since it may not be defined
> > Use 0 instead
> 
> I am unable to reproduce this issue, even with gcc-4.6. Also please note
> that NULL is defined in <stddef.h>, not <stdlib.h>. <stddef.h> is 
> included from <sys/types.h> which is included from <pulse/simple.h>.
> 
> Do you have more information about the issue.
> 
> > Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
> > ---
> >  configure |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/configure b/configure
> > index ea8b676..d67c3ce 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
> > 
> >      pa)
> >      audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
> > -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
> > +        "pa_simple *s = 0; pa_simple_free(s); return 0;"
> 
> It should be ((void*)0) instead of simply 0.

No it shouldn't.

> 
> >      libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
> >      audio_pt_int="yes"
> >      ;;
> > -- 
> > 1.7.5.52.ge839f.dirty
> > 
> > 
> 
>
Aurelien Jarno June 3, 2011, 10:17 p.m. UTC | #4
On Sat, Jun 04, 2011 at 01:57:23AM +0400, malc wrote:
> On Fri, 3 Jun 2011, Aurelien Jarno wrote:
> 
> > On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
> > > pulse/simple.h does not include stdlib.h
> > > We cannot use NULL since it may not be defined
> > > Use 0 instead
> > 
> > I am unable to reproduce this issue, even with gcc-4.6. Also please note
> > that NULL is defined in <stddef.h>, not <stdlib.h>. <stddef.h> is 
> > included from <sys/types.h> which is included from <pulse/simple.h>.
> > 
> > Do you have more information about the issue.
> > 
> > > Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
> > > ---
> > >  configure |    2 +-
> > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/configure b/configure
> > > index ea8b676..d67c3ce 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
> > > 
> > >      pa)
> > >      audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
> > > -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
> > > +        "pa_simple *s = 0; pa_simple_free(s); return 0;"
> > 
> > It should be ((void*)0) instead of simply 0.
> 
> No it shouldn't.
> 

If we want to replace #include <stddef.h>, which should use the same
code, that is:

| #ifndef __cplusplus
| #define NULL ((void *)0)
| #else   /* C++ */
| #define NULL 0
| #endif  /* C++ */

Given we are writing C code and not C++ code, NULL is defined as 
((void *)0).
malc June 3, 2011, 10:54 p.m. UTC | #5
On Sat, 4 Jun 2011, Aurelien Jarno wrote:

> On Sat, Jun 04, 2011 at 01:57:23AM +0400, malc wrote:
> > On Fri, 3 Jun 2011, Aurelien Jarno wrote:
> > 
> > > On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
> > > > pulse/simple.h does not include stdlib.h
> > > > We cannot use NULL since it may not be defined
> > > > Use 0 instead
> > > 
> > > I am unable to reproduce this issue, even with gcc-4.6. Also please note
> > > that NULL is defined in <stddef.h>, not <stdlib.h>. <stddef.h> is 
> > > included from <sys/types.h> which is included from <pulse/simple.h>.
> > > 
> > > Do you have more information about the issue.
> > > 
> > > > Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
> > > > ---
> > > >  configure |    2 +-
> > > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > > > 
> > > > diff --git a/configure b/configure
> > > > index ea8b676..d67c3ce 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
> > > > 
> > > >      pa)
> > > >      audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
> > > > -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
> > > > +        "pa_simple *s = 0; pa_simple_free(s); return 0;"
> > > 
> > > It should be ((void*)0) instead of simply 0.
> > 
> > No it shouldn't.
> > 
> 
> If we want to replace #include <stddef.h>, which should use the same
> code, that is:
> 
> | #ifndef __cplusplus
> | #define NULL ((void *)0)
> | #else   /* C++ */
> | #define NULL 0
> | #endif  /* C++ */
> 
> Given we are writing C code and not C++ code, NULL is defined as 
> ((void *)0).

Doesn't make a dent of a differnce how particular implementation defines
NULL, 6.2.3.3#3 covers it, what i'm trying to get across is that your
strong "should" is wrong.
Marc-Antoine Perennou June 9, 2011, 3:52 p.m. UTC | #6
On 4 June 2011 00:54, malc <av1474@comtv.ru> wrote:
> On Sat, 4 Jun 2011, Aurelien Jarno wrote:
>
>> On Sat, Jun 04, 2011 at 01:57:23AM +0400, malc wrote:
>> > On Fri, 3 Jun 2011, Aurelien Jarno wrote:
>> >
>> > > On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
>> > > > pulse/simple.h does not include stdlib.h
>> > > > We cannot use NULL since it may not be defined
>> > > > Use 0 instead
>> > >
>> > > I am unable to reproduce this issue, even with gcc-4.6. Also please note
>> > > that NULL is defined in <stddef.h>, not <stdlib.h>. <stddef.h> is
>> > > included from <sys/types.h> which is included from <pulse/simple.h>.
>> > >
>> > > Do you have more information about the issue.
>> > >
>> > > > Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
>> > > > ---
>> > > >  configure |    2 +-
>> > > >  1 files changed, 1 insertions(+), 1 deletions(-)
>> > > >
>> > > > diff --git a/configure b/configure
>> > > > index ea8b676..d67c3ce 100755
>> > > > --- a/configure
>> > > > +++ b/configure
>> > > > @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
>> > > >
>> > > >      pa)
>> > > >      audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
>> > > > -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
>> > > > +        "pa_simple *s = 0; pa_simple_free(s); return 0;"
>> > >
>> > > It should be ((void*)0) instead of simply 0.
>> >
>> > No it shouldn't.
>> >
>>
>> If we want to replace #include <stddef.h>, which should use the same
>> code, that is:
>>
>> | #ifndef __cplusplus
>> | #define NULL ((void *)0)
>> | #else   /* C++ */
>> | #define NULL 0
>> | #endif  /* C++ */
>>
>> Given we are writing C code and not C++ code, NULL is defined as
>> ((void *)0).
>
> Doesn't make a dent of a differnce how particular implementation defines
> NULL, 6.2.3.3#3 covers it, what i'm trying to get across is that your
> strong "should" is wrong.
>
> --
> mailto:av1474@comtv.ru

It's kinda weird actually, just wrote a small program to test:

#include <stddef.h>
int main() {
    int * i = NULL;
    return 0;
}

It builds fine
Now if I replace "stddef.h" by "sys/types.h"
‘NULL’ undeclared

I'm running Gentoo GNU/Linux, and everyone using it in my friends get
the same problem, and there is no problem at all with the whole system
which is around.
(Only gcc 4.6 is installed fyi)

Manually including stddef.h or replacing NULL by 0 or (void*)0 makes it work.

Hope I provided enough informations to justify this thread
Andreas Färber June 9, 2011, 5:44 p.m. UTC | #7
Am 09.06.2011 um 17:52 schrieb Marc-Antoine Perennou:

> On 4 June 2011 00:54, malc <av1474@comtv.ru> wrote:
>> On Sat, 4 Jun 2011, Aurelien Jarno wrote:
>>
>>> On Sat, Jun 04, 2011 at 01:57:23AM +0400, malc wrote:
>>>> On Fri, 3 Jun 2011, Aurelien Jarno wrote:
>>>>
>>>>> On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou  
>>>>> wrote:
>>>>>> diff --git a/configure b/configure
>>>>>> index ea8b676..d67c3ce 100755
>>>>>> --- a/configure
>>>>>> +++ b/configure
>>>>>> @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
>>>>>>
>>>>>>      pa)
>>>>>>      audio_drv_probe $drv pulse/simple.h "-lpulse-simple - 
>>>>>> lpulse" \
>>>>>> -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
>>>>>> +        "pa_simple *s = 0; pa_simple_free(s); return 0;"

> It's kinda weird actually, just wrote a small program to test:
>
> #include <stddef.h>
> int main() {
>    int * i = NULL;
>    return 0;
> }
>
> It builds fine
> Now if I replace "stddef.h" by "sys/types.h"
> ‘NULL’ undeclared
>
> I'm running Gentoo GNU/Linux [...]
>
> Manually including stddef.h or replacing NULL by 0 or (void*)0 makes  
> it work.

Then please submit a new patch that explicit includes that header with  
a comment explaining why, so that it doesn't get removed by accident.

Andreas
Markus Armbruster June 9, 2011, 6:25 p.m. UTC | #8
Aurelien Jarno <aurelien@aurel32.net> writes:

> On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
>> pulse/simple.h does not include stdlib.h
>> We cannot use NULL since it may not be defined
>> Use 0 instead
>
> I am unable to reproduce this issue, even with gcc-4.6. Also please note
> that NULL is defined in <stddef.h>, not <stdlib.h>.

NULL is defined in stddef.h (ISO/IEC 9899:1999 7.17), locale.h (ibid
7.11), stdio.h (ibid 7.19.1), stdlib.h (ibid 7.20), string.h (ibid
7.21.1), time.h (ibid 7.23.1), wchar.h (ibid 7.24.1).

>                                                     <stddef.h> is 
> included from <sys/types.h> which is included from <pulse/simple.h>.

I don't think POSIX specifies sys/types.h defines NULL, let alone
includes stddef.h.

> Do you have more information about the issue.
>
>> Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
>> ---
>>  configure |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>> 
>> diff --git a/configure b/configure
>> index ea8b676..d67c3ce 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do
>> 
>>      pa)
>>      audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
>> -        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
>> +        "pa_simple *s = 0; pa_simple_free(s); return 0;"
>
> It should be ((void*)0) instead of simply 0.

Matter of taste.

>>      libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
>>      audio_pt_int="yes"
>>      ;;
Peter Maydell June 9, 2011, 7:07 p.m. UTC | #9
On 9 June 2011 18:44, Andreas Färber <andreas.faerber@web.de> wrote:
> Am 09.06.2011 um 17:52 schrieb Marc-Antoine Perennou:
>> Manually including stddef.h or replacing NULL by 0 or (void*)0 makes it
>> work.
>
> Then please submit a new patch that explicit includes that header with a
> comment explaining why, so that it doesn't get removed by accident.

I think the original patch is fine. This configure test isn't
trying to test whether we correctly found some definition of
NULL, it's testing pulseaudio presence. The test code should
be the simplest and most stand-alone code that achieves that.
There's no need to go dragging in extra headers when we don't
even need to be using NULL here anyhow.

We already have configure tests which use unadorned 0 for
pointers (eg the pthread test), it's legal C, and it works.
I think we should call this a trivial patch and just apply it.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
Markus Armbruster June 10, 2011, 7:14 a.m. UTC | #10
Peter Maydell <peter.maydell@linaro.org> writes:

> On 9 June 2011 18:44, Andreas Färber <andreas.faerber@web.de> wrote:
>> Am 09.06.2011 um 17:52 schrieb Marc-Antoine Perennou:
>>> Manually including stddef.h or replacing NULL by 0 or (void*)0 makes it
>>> work.
>>
>> Then please submit a new patch that explicit includes that header with a
>> comment explaining why, so that it doesn't get removed by accident.
>
> I think the original patch is fine. This configure test isn't
> trying to test whether we correctly found some definition of
> NULL, it's testing pulseaudio presence. The test code should
> be the simplest and most stand-alone code that achieves that.
> There's no need to go dragging in extra headers when we don't
> even need to be using NULL here anyhow.
>
> We already have configure tests which use unadorned 0 for
> pointers (eg the pthread test), it's legal C, and it works.
> I think we should call this a trivial patch and just apply it.
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

I agree with your reasoning.
Marc-Antoine Perennou June 24, 2011, 1:31 p.m. UTC | #11
On 10 June 2011 09:14, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On 9 June 2011 18:44, Andreas Färber <andreas.faerber@web.de> wrote:
>>> Am 09.06.2011 um 17:52 schrieb Marc-Antoine Perennou:
>>>> Manually including stddef.h or replacing NULL by 0 or (void*)0 makes it
>>>> work.
>>>
>>> Then please submit a new patch that explicit includes that header with a
>>> comment explaining why, so that it doesn't get removed by accident.
>>
>> I think the original patch is fine. This configure test isn't
>> trying to test whether we correctly found some definition of
>> NULL, it's testing pulseaudio presence. The test code should
>> be the simplest and most stand-alone code that achieves that.
>> There's no need to go dragging in extra headers when we don't
>> even need to be using NULL here anyhow.
>>
>> We already have configure tests which use unadorned 0 for
>> pointers (eg the pthread test), it's legal C, and it works.
>> I think we should call this a trivial patch and just apply it.
>>
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> I agree with your reasoning.
>

If you want me to provide a patch with the extra include instead, I
can, otherwise, could this trivial one get merged so qemu-kvm can be
built on several systems on which it actually can't ?
Stefan Hajnoczi June 24, 2011, 2:49 p.m. UTC | #12
On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote:
> pulse/simple.h does not include stdlib.h
> We cannot use NULL since it may not be defined
> Use 0 instead
> 
> Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
> ---
>  configure |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

There has been discussion but I hope we've arrived at consensus based on
the fact that 0 is already used for pthreads and it's valid C.

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Stefan
Stefan Hajnoczi June 24, 2011, 4:52 p.m. UTC | #13
On Fri, Jun 24, 2011 at 2:31 PM, Marc-Antoine Perennou
<Marc-Antoine@perennou.com> wrote:
> On 10 June 2011 09:14, Markus Armbruster <armbru@redhat.com> wrote:
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>>> On 9 June 2011 18:44, Andreas Färber <andreas.faerber@web.de> wrote:
>>>> Am 09.06.2011 um 17:52 schrieb Marc-Antoine Perennou:
>>>>> Manually including stddef.h or replacing NULL by 0 or (void*)0 makes it
>>>>> work.
>>>>
>>>> Then please submit a new patch that explicit includes that header with a
>>>> comment explaining why, so that it doesn't get removed by accident.
>>>
>>> I think the original patch is fine. This configure test isn't
>>> trying to test whether we correctly found some definition of
>>> NULL, it's testing pulseaudio presence. The test code should
>>> be the simplest and most stand-alone code that achieves that.
>>> There's no need to go dragging in extra headers when we don't
>>> even need to be using NULL here anyhow.
>>>
>>> We already have configure tests which use unadorned 0 for
>>> pointers (eg the pthread test), it's legal C, and it works.
>>> I think we should call this a trivial patch and just apply it.
>>>
>>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>>
>> I agree with your reasoning.
>>
>
> If you want me to provide a patch with the extra include instead, I
> can, otherwise, could this trivial one get merged so qemu-kvm can be
> built on several systems on which it actually can't ?

It is in the trivial-patches tree now.  qemu.git will pick it up next
and then qemu-kvm.git will pull it in when it syncs up with qemu.git.

Stefan
diff mbox

Patch

diff --git a/configure b/configure
index ea8b676..d67c3ce 100755
--- a/configure
+++ b/configure
@@ -1567,7 +1567,7 @@  for drv in $audio_drv_list; do

     pa)
     audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
-        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
+        "pa_simple *s = 0; pa_simple_free(s); return 0;"
     libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
     audio_pt_int="yes"
     ;;