Patchwork [v2] configure: fix double check tests with Clang

login
register
mail settings
Submitter Blue Swirl
Date Aug. 11, 2012, 3:11 p.m.
Message ID <47b52597d5bfea96270f281160ca7a2ca256f7c4.1344697837.git.blauwirbel@gmail.com>
Download mbox | patch
Permalink /patch/176691/
State New
Headers show

Comments

Blue Swirl - Aug. 11, 2012, 3:11 p.m.
Configuring with Clang compiler with -Werror would not work after
improved checks:
/tmp/qemu-conf--25992-.c:4:32: error: self-comparison always evaluates
to true [-Werror,-Wtautological-compare]
int main(void) { return preadv == preadv; }
/tmp/qemu-conf--25992-.c:13:26: error: self-comparison always
evaluates to true [-Werror,-Wtautological-compare]
    return epoll_create1 == epoll_create1;
/tmp/qemu-conf--25992-.c:3:13: error: explicitly assigning a variable
of type 'char **' to itself [-Werror,-Wself-assign]
    environ = environ;

Avoid the errors by adjusting the tests.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---

v1->v2: remove void * casts.

---
 configure |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Peter Maydell - Aug. 11, 2012, 5:44 p.m.
On 11 August 2012 16:11, Blue Swirl <blauwirbel@gmail.com> wrote:
> Configuring with Clang compiler with -Werror would not work after
> improved checks:
> /tmp/qemu-conf--25992-.c:4:32: error: self-comparison always evaluates
> to true [-Werror,-Wtautological-compare]
> int main(void) { return preadv == preadv; }
> /tmp/qemu-conf--25992-.c:13:26: error: self-comparison always
> evaluates to true [-Werror,-Wtautological-compare]
>     return epoll_create1 == epoll_create1;
> /tmp/qemu-conf--25992-.c:3:13: error: explicitly assigning a variable
> of type 'char **' to itself [-Werror,-Wself-assign]
>     environ = environ;
>
> Avoid the errors by adjusting the tests.
>
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

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

-- PMM
Blue Swirl - Aug. 11, 2012, 7:12 p.m.
On Sat, Aug 11, 2012 at 5:44 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 11 August 2012 16:11, Blue Swirl <blauwirbel@gmail.com> wrote:
>> Configuring with Clang compiler with -Werror would not work after
>> improved checks:
>> /tmp/qemu-conf--25992-.c:4:32: error: self-comparison always evaluates
>> to true [-Werror,-Wtautological-compare]
>> int main(void) { return preadv == preadv; }
>> /tmp/qemu-conf--25992-.c:13:26: error: self-comparison always
>> evaluates to true [-Werror,-Wtautological-compare]
>>     return epoll_create1 == epoll_create1;
>> /tmp/qemu-conf--25992-.c:3:13: error: explicitly assigning a variable
>> of type 'char **' to itself [-Werror,-Wself-assign]
>>     environ = environ;
>>
>> Avoid the errors by adjusting the tests.
>>
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Thanks for the review, applied.

>
> -- PMM

Patch

diff --git a/configure b/configure
index 12fdc22..f0dbc03 100755
--- a/configure
+++ b/configure
@@ -2256,7 +2256,7 @@  cat > $TMPC <<EOF
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <unistd.h>
-int main(void) { return preadv == preadv; }
+int main(void) { return preadv(0, 0, 0, 0); }
 EOF
 preadv=no
 if compile_prog "" "" ; then
@@ -2552,7 +2552,7 @@  int main(void)
      * warning but not an error, and will proceed to fail the
      * qemu compile where we compile with -Werror.)
      */
-    return epoll_create1 == epoll_create1;
+    return (int)(uintptr_t)&epoll_create1;
 }
 EOF
 if compile_prog "" "" ; then
@@ -2945,7 +2945,7 @@  has_environ=no
 cat > $TMPC << EOF
 #include <unistd.h>
 int main(void) {
-    environ = environ;
+    environ = 0;
     return 0;
 }
 EOF