All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log
@ 2011-12-17  8:27 Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 01/11] configure: Fix compiler warnings in config.log (always return a value from main) Stefan Weil
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

Recently some patches were sent from Peter Maydell to improve
the output in config.log.

This new patch series also improves that output by eliminating
some compiler warnings.

Here is the result of a typical QEMU configuration:

without patch series
296 lines in config.log with 78 compilations, 69 errors and 107 warnings

with patch series applied
152 lines in config.log with 75 compilations, 24 errors and 30 warnings

It is possible to apply only some of the patches (they don't depend
on each other).

Regards,
Stefan Weil

[PATCH 01/11] configure: Fix compiler warnings in config.log (always return a value from main)
[PATCH 02/11] configure: Fix compiler warnings in config.log (old-style function definition)
[PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer)
[PATCH 04/11] configure: Fix compiler warnings in config.log (null arguments)
[PATCH 05/11] configure: Fix compiler warning in config.log (unused variable)
[PATCH 06/11] configure: Fix compiler warning in config.log (macro redefined)
[PATCH 07/11] configure: Fix compiler warnings in config.log (uninitialized variable)
[PATCH 08/11] configure: Fix compiler warning in config.log (undefined NULL)
[PATCH 09/11] configure: Fix compiler warning in config.log (value was never used)
[PATCH 10/11] configure: Fix compiler warnings in config.log (statement without effect)
[PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 01/11] configure: Fix compiler warnings in config.log (always return a value from main)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 02/11] configure: Fix compiler warnings in config.log (old-style function definition) Stefan Weil
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

Fix several "warning: control reaches end of non-void function".

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 6fd580e..03b8f35 100755
--- a/configure
+++ b/configure
@@ -1082,7 +1082,7 @@ fi
 
 # check that the C compiler works.
 cat > $TMPC <<EOF
-int main(void) {}
+int main(void) { return 0; }
 EOF
 
 if compile_object ; then
@@ -2651,7 +2651,7 @@ ucontext_coroutine=no
 if test "$darwin" != "yes"; then
   cat > $TMPC << EOF
 #include <ucontext.h>
-int main(void) { makecontext(0, 0, 0); }
+int main(void) { makecontext(0, 0, 0); return 0; }
 EOF
   if compile_prog "" "" ; then
       ucontext_coroutine=yes
@@ -2664,7 +2664,7 @@ fi
 open_by_hande_at=no
 cat > $TMPC << EOF
 #include <fcntl.h>
-int main(void) { struct file_handle fh; open_by_handle_at(0, &fh, 0); }
+int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
 EOF
 if compile_prog "" "" ; then
     open_by_handle_at=yes
@@ -2677,6 +2677,7 @@ linux_magic_h=no
 cat > $TMPC << EOF
 #include <linux/magic.h>
 int main(void) {
+  return 0;
 }
 EOF
 if compile_prog "" "" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 02/11] configure: Fix compiler warnings in config.log (old-style function definition)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 01/11] configure: Fix compiler warnings in config.log (always return a value from main) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer) Stefan Weil
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: function declaration isn’t a prototype
In function ‘foo’:
warning: old-style function definition

The function name was changed, too, to avoid an additional warning.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 03b8f35..93c6cbe 100755
--- a/configure
+++ b/configure
@@ -1274,11 +1274,11 @@ if test "$nptl" != "no" ; then
   cat > $TMPC <<EOF
 #include <sched.h>
 #include <linux/futex.h>
-void foo()
-{
+int main(void) {
 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
 #error bork
 #endif
+  return 0;
 }
 EOF
 
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 01/11] configure: Fix compiler warnings in config.log (always return a value from main) Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 02/11] configure: Fix compiler warnings in config.log (old-style function definition) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17 11:29   ` Peter Maydell
  2011-12-17 16:46   ` [Qemu-devel] [PATCH v2 " Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 04/11] configure: Fix compiler warnings in config.log (null arguments) Stefan Weil
                   ` (8 subsequent siblings)
  11 siblings, 2 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: return makes integer from pointer without a cast

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 93c6cbe..8dee237 100755
--- a/configure
+++ b/configure
@@ -1841,7 +1841,11 @@ if test "$curses" != "no" ; then
 #ifdef __OpenBSD__
 #define resize_term resizeterm
 #endif
-int main(void) { resize_term(0, 0); return curses_version(); }
+int main(void) {
+  const char *s = curses_version();
+  resize_term(0, 0);
+  return s != (const char *)0;
+}
 EOF
   for curses_lib in $curses_list; do
     if compile_prog "" "$curses_lib" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 04/11] configure: Fix compiler warnings in config.log (null arguments)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (2 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 05/11] configure: Fix compiler warning in config.log (unused variable) Stefan Weil
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: null argument where non-null required (argument 1)
warning: null argument where non-null required (argument 3)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 8dee237..5d860a7 100755
--- a/configure
+++ b/configure
@@ -1951,7 +1951,12 @@ PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
 pthread=no
 cat > $TMPC << EOF
 #include <pthread.h>
-int main(void) { pthread_create(0,0,0,0); return 0; }
+static void *f(void *p) { return NULL; }
+int main(void) {
+  pthread_t thread;
+  pthread_create(&thread, 0, f, 0);
+  return 0;
+}
 EOF
 if compile_prog "" "" ; then
   pthread=yes
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 05/11] configure: Fix compiler warning in config.log (unused variable)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (3 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 04/11] configure: Fix compiler warnings in config.log (null arguments) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 06/11] configure: Fix compiler warning in config.log (macro redefined) Stefan Weil
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: unused variable ‘iov’

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 5d860a7..efc7b6b 100755
--- a/configure
+++ b/configure
@@ -2060,7 +2060,7 @@ cat > $TMPC <<EOF
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <unistd.h>
-int main(void) { struct iovec iov; return 0; }
+int main(void) { return sizeof(struct iovec); }
 EOF
 iovec=no
 if compile_prog "" "" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 06/11] configure: Fix compiler warning in config.log (macro redefined)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (4 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 05/11] configure: Fix compiler warning in config.log (unused variable) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 07/11] configure: Fix compiler warnings in config.log (uninitialized variable) Stefan Weil
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: "_GNU_SOURCE" redefined

The macro is already defined on the command line.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index efc7b6b..b799212 100755
--- a/configure
+++ b/configure
@@ -2251,7 +2251,6 @@ fi
 # signalfd probe
 signalfd="no"
 cat > $TMPC << EOF
-#define _GNU_SOURCE
 #include <unistd.h>
 #include <sys/syscall.h>
 #include <signal.h>
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 07/11] configure: Fix compiler warnings in config.log (uninitialized variable)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (5 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 06/11] configure: Fix compiler warning in config.log (macro redefined) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 08/11] configure: Fix compiler warning in config.log (undefined NULL) Stefan Weil
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: ‘fd’ is used uninitialized in this function
warning: ‘id’ is used uninitialized in this function

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b799212..b755ad1 100755
--- a/configure
+++ b/configure
@@ -2237,7 +2237,7 @@ cat > $TMPC << EOF
 
 int main(void)
 {
-    int len, fd;
+    int len, fd = 0;
     len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
     splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
     return 0;
@@ -2449,7 +2449,7 @@ fi
 cat > $TMPC <<EOF
 #include <signal.h>
 #include <time.h>
-int main(void) { clockid_t id; return clock_gettime(id, NULL); }
+int main(void) { return clock_gettime(CLOCK_REALTIME, NULL); }
 EOF
 
 if compile_prog "" "" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 08/11] configure: Fix compiler warning in config.log (undefined NULL)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (6 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 07/11] configure: Fix compiler warnings in config.log (uninitialized variable) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 09/11] configure: Fix compiler warning in config.log (value was never used) Stefan Weil
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

Avoid the warning when probing for xfs.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index b755ad1..31ea3ff 100755
--- a/configure
+++ b/configure
@@ -1670,6 +1670,7 @@ fi
 # xfsctl() probe, used for raw-posix
 if test "$xfs" != "no" ; then
   cat > $TMPC << EOF
+#include <stddef.h>  /* NULL */
 #include <xfs/xfs.h>
 int main(void)
 {
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 09/11] configure: Fix compiler warning in config.log (value was never used)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (7 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 08/11] configure: Fix compiler warning in config.log (undefined NULL) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 10/11] configure: Fix compiler warnings in config.log (statement without effect) Stefan Weil
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 31ea3ff..0c791b5 100755
--- a/configure
+++ b/configure
@@ -2269,8 +2269,7 @@ cat > $TMPC << EOF
 
 int main(void)
 {
-    int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
-    return 0;
+    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
 }
 EOF
 if compile_prog "" "" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 10/11] configure: Fix compiler warnings in config.log (statement without effect)
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (8 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 09/11] configure: Fix compiler warning in config.log (value was never used) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen Stefan Weil
  2011-12-17 11:43 ` [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Peter Maydell
  11 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 0c791b5..1ae380f 100755
--- a/configure
+++ b/configure
@@ -2074,7 +2074,7 @@ cat > $TMPC <<EOF
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <unistd.h>
-int main(void) { preadv; }
+int main(void) { return preadv == preadv; }
 EOF
 preadv=no
 if compile_prog "" "" ; then
@@ -2107,7 +2107,7 @@ if test "$opengl" != "no" ; then
 #include <X11/Xlib.h>
 #include <GL/gl.h>
 #include <GL/glx.h>
-int main(void) { GL_VERSION; return 0; }
+int main(void) { return GL_VERSION != 0; }
 EOF
   if compile_prog "" "-lGL" ; then
     opengl=yes
@@ -2369,8 +2369,7 @@ int main(void)
      * warning but not an error, and will proceed to fail the
      * qemu compile where we compile with -Werror.)
      */
-    epoll_create1;
-    return 0;
+    return epoll_create1 == epoll_create1;
 }
 EOF
 if compile_prog "$ARCH_CFLAGS" "" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (9 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 10/11] configure: Fix compiler warnings in config.log (statement without effect) Stefan Weil
@ 2011-12-17  8:27 ` Stefan Weil
  2012-01-04 17:00   ` Stefano Stabellini
  2011-12-17 11:43 ` [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Peter Maydell
  11 siblings, 1 reply; 20+ messages in thread
From: Stefan Weil @ 2011-12-17  8:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Stefano Stabellini

With this patch, it only takes one test (instead of four)
to detect that there is no Xen support at all.

For most build hosts, this will reduce the time configure needs.
It will also reduce noisy output in config.log.

Build hosts with Xen now need up to five (instead of up to four)
tests. They get improved diagnostics when Xen support fails.

Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 1ae380f..b8ec19a 100755
--- a/configure
+++ b/configure
@@ -1317,10 +1317,30 @@ fi
 if test "$xen" != "no" ; then
   xen_libs="-lxenstore -lxenctrl -lxenguest"
 
-  # Xen unstable
+  # First we test whether Xen headers and libraries are available.
+  # If no, we are done and there is no Xen support.
+  # If yes, more tests are run to detect the Xen version.
+
+  # Xen (any)
   cat > $TMPC <<EOF
 #include <xenctrl.h>
 #include <xs.h>
+int main(void) {
+  return 0;
+}
+EOF
+  if ! compile_prog "" "$xen_libs" ; then
+    # Xen not found
+    if test "$xen" = "yes" ; then
+      feature_not_found "xen"
+    fi
+    xen=no
+
+  # Xen unstable
+  elif (
+      cat > $TMPC <<EOF
+#include <xenctrl.h>
+#include <xs.h>
 #include <stdint.h>
 #include <xen/hvm/hvm_info_table.h>
 #if !defined(HVM_MAX_VCPUS)
@@ -1336,7 +1356,8 @@ int main(void) {
   return 0;
 }
 EOF
-  if compile_prog "" "$xen_libs" ; then
+      compile_prog "" "$xen_libs"
+    ) ; then
     xen_ctrl_version=410
     xen=yes
 
@@ -1407,10 +1428,10 @@ EOF
     xen_ctrl_version=330
     xen=yes
 
-  # Xen not found or unsupported
+  # Xen version unsupported
   else
     if test "$xen" = "yes" ; then
-      feature_not_found "xen"
+      feature_not_found "xen (unsupported version)"
     fi
     xen=no
   fi
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer) Stefan Weil
@ 2011-12-17 11:29   ` Peter Maydell
  2011-12-17 12:11     ` Stefan Weil
  2011-12-17 16:46   ` [Qemu-devel] [PATCH v2 " Stefan Weil
  1 sibling, 1 reply; 20+ messages in thread
From: Peter Maydell @ 2011-12-17 11:29 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

On 17 December 2011 08:27, Stefan Weil <sw@weilnetz.de> wrote:
> warning: return makes integer from pointer without a cast
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  configure |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 93c6cbe..8dee237 100755
> --- a/configure
> +++ b/configure
> @@ -1841,7 +1841,11 @@ if test "$curses" != "no" ; then
>  #ifdef __OpenBSD__
>  #define resize_term resizeterm
>  #endif
> -int main(void) { resize_term(0, 0); return curses_version(); }
> +int main(void) {
> +  const char *s = curses_version();
> +  resize_term(0, 0);
> +  return s != (const char *)0;

You don't need this cast, I think.

> +}
>  EOF
>   for curses_lib in $curses_list; do
>     if compile_prog "" "$curses_lib" ; then
> --
> 1.7.2.5

-- PMM

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log
  2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
                   ` (10 preceding siblings ...)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen Stefan Weil
@ 2011-12-17 11:43 ` Peter Maydell
  11 siblings, 0 replies; 20+ messages in thread
From: Peter Maydell @ 2011-12-17 11:43 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

On 17 December 2011 08:27, Stefan Weil <sw@weilnetz.de> wrote:
> Recently some patches were sent from Peter Maydell to improve
> the output in config.log.
>
> This new patch series also improves that output by eliminating
> some compiler warnings.

All except 03/11:
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17 11:29   ` Peter Maydell
@ 2011-12-17 12:11     ` Stefan Weil
  2011-12-17 14:09       ` Peter Maydell
  0 siblings, 1 reply; 20+ messages in thread
From: Stefan Weil @ 2011-12-17 12:11 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-trivial, qemu-devel

Am 17.12.2011 12:29, schrieb Peter Maydell:
> On 17 December 2011 08:27, Stefan Weil <sw@weilnetz.de> wrote:
>> warning: return makes integer from pointer without a cast
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>  configure |    6 +++++-
>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 93c6cbe..8dee237 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1841,7 +1841,11 @@ if test "$curses" != "no" ; then
>>  #ifdef __OpenBSD__
>>  #define resize_term resizeterm
>>  #endif
>> -int main(void) { resize_term(0, 0); return curses_version(); }
>> +int main(void) {
>> +  const char *s = curses_version();
>> +  resize_term(0, 0);
>> +  return s != (const char *)0;
>
> You don't need this cast, I think.

Indeed, a quick test with gcc-4.4.5 shows no new warning when
I remove the type cast. Are you sure that this works with all
supported versions of gcc and any set of warning options?

Normally NULL is used for this kind of code, but it needs
stddef.h. Typically NULL is defined to be ((void *)0 for C
(that's the reason why I used a type cast, too). Only for
C++ it is defined without a type cast.

The type cast won't harm and is not in "normal" code,
so it can be committed as it is. I also don't mind if it is
removed by whoever commits it. If it is preferred that
I send an updated patch, I'd use NULL with stddef.h
(just to be safe).

Regards,
Stefan Weil

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17 12:11     ` Stefan Weil
@ 2011-12-17 14:09       ` Peter Maydell
  2011-12-17 14:18         ` Eric Blake
  0 siblings, 1 reply; 20+ messages in thread
From: Peter Maydell @ 2011-12-17 14:09 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

On 17 December 2011 12:11, Stefan Weil <sw@weilnetz.de> wrote:
> Am 17.12.2011 12:29, schrieb Peter Maydell:
>>> +  return s != (const char *)0;
>>
>> You don't need this cast, I think.
>
> Indeed, a quick test with gcc-4.4.5 shows no new warning when
> I remove the type cast. Are you sure that this works with all
> supported versions of gcc and any set of warning options?

Yes. Both 0 and (void*)0 are null pointer constants;
comparing explicitly for "if (ptr != 0)" is equivalent to
"if (ptr)"; qemu style prefers the latter but there are
a few of the former in the codebase, so practically speaking
we know it compiles fine.

> Normally NULL is used for this kind of code, but it needs
> stddef.h.

Only in some coding styles. NULL is just a convenience
macro if you like that kind of thing.

> Typically NULL is defined to be ((void *)0 for C
> (that's the reason why I used a type cast, too). Only for
> C++ it is defined without a type cast.

The C standard permits plain "0" as a definition of NULL.

> The type cast won't harm and is not in "normal" code,
> so it can be committed as it is. I also don't mind if it is
> removed by whoever commits it. If it is preferred that
> I send an updated patch, I'd use NULL with stddef.h
> (just to be safe).

We use plain 0 for a null pointer constant in various
existing tests in configure; this is simpler and avoids
dragging in stddef.h. I would prefer that.

-- PMM

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17 14:09       ` Peter Maydell
@ 2011-12-17 14:18         ` Eric Blake
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Blake @ 2011-12-17 14:18 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-trivial, Stefan Weil, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

On 12/17/2011 07:09 AM, Peter Maydell wrote:
>> Typically NULL is defined to be ((void *)0 for C
>> (that's the reason why I used a type cast, too). Only for
>> C++ it is defined without a type cast.
> 
> The C standard permits plain "0" as a definition of NULL.

POSIX concurs with the C standard that a plain "0" can be used for
representing a null pointer, but requires that the macro NULL be defined
as ((void*)0) as a tighter requirement than C.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_244
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html#tag_13_47

> We use plain 0 for a null pointer constant in various
> existing tests in configure; this is simpler and avoids
> dragging in stddef.h. I would prefer that.

I agree that configure tests should be as small as possible while still
being correct, and use of a 0 constant without a cast, rather than NULL,
is appropriate in that context.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer) Stefan Weil
  2011-12-17 11:29   ` Peter Maydell
@ 2011-12-17 16:46   ` Stefan Weil
  2011-12-17 16:57     ` Peter Maydell
  1 sibling, 1 reply; 20+ messages in thread
From: Stefan Weil @ 2011-12-17 16:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

warning: return makes integer from pointer without a cast

v2: Removed type cast.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 93c6cbe..773df6a 100755
--- a/configure
+++ b/configure
@@ -1841,7 +1841,11 @@ if test "$curses" != "no" ; then
 #ifdef __OpenBSD__
 #define resize_term resizeterm
 #endif
-int main(void) { resize_term(0, 0); return curses_version(); }
+int main(void) {
+  const char *s = curses_version();
+  resize_term(0, 0);
+  return s != 0;
+}
 EOF
   for curses_lib in $curses_list; do
     if compile_prog "" "$curses_lib" ; then
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 03/11] configure: Fix compiler warning in config.log (integer from pointer)
  2011-12-17 16:46   ` [Qemu-devel] [PATCH v2 " Stefan Weil
@ 2011-12-17 16:57     ` Peter Maydell
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Maydell @ 2011-12-17 16:57 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

On 17 December 2011 16:46, Stefan Weil <sw@weilnetz.de> wrote:
> warning: return makes integer from pointer without a cast
>
> v2: Removed type cast.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

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

> ---
>  configure |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 93c6cbe..773df6a 100755
> --- a/configure
> +++ b/configure
> @@ -1841,7 +1841,11 @@ if test "$curses" != "no" ; then
>  #ifdef __OpenBSD__
>  #define resize_term resizeterm
>  #endif
> -int main(void) { resize_term(0, 0); return curses_version(); }
> +int main(void) {
> +  const char *s = curses_version();
> +  resize_term(0, 0);
> +  return s != 0;
> +}
>  EOF
>   for curses_lib in $curses_list; do
>     if compile_prog "" "$curses_lib" ; then
> --
> 1.7.2.5
>
>



-- 
12345678901234567890123456789012345678901234567890123456789012345678901234567890
         1         2         3         4         5         6         7         8

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen
  2011-12-17  8:27 ` [Qemu-devel] [PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen Stefan Weil
@ 2012-01-04 17:00   ` Stefano Stabellini
  0 siblings, 0 replies; 20+ messages in thread
From: Stefano Stabellini @ 2012-01-04 17:00 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, Stefano Stabellini

On Sat, 17 Dec 2011, Stefan Weil wrote:
> With this patch, it only takes one test (instead of four)
> to detect that there is no Xen support at all.
> 
> For most build hosts, this will reduce the time configure needs.
> It will also reduce noisy output in config.log.
> 
> Build hosts with Xen now need up to five (instead of up to four)
> tests. They get improved diagnostics when Xen support fails.

good idea, thanks for the patch

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-01-04 17:01 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17  8:27 [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 01/11] configure: Fix compiler warnings in config.log (always return a value from main) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 02/11] configure: Fix compiler warnings in config.log (old-style function definition) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 03/11] configure: Fix compiler warning in config.log (integer from pointer) Stefan Weil
2011-12-17 11:29   ` Peter Maydell
2011-12-17 12:11     ` Stefan Weil
2011-12-17 14:09       ` Peter Maydell
2011-12-17 14:18         ` Eric Blake
2011-12-17 16:46   ` [Qemu-devel] [PATCH v2 " Stefan Weil
2011-12-17 16:57     ` Peter Maydell
2011-12-17  8:27 ` [Qemu-devel] [PATCH 04/11] configure: Fix compiler warnings in config.log (null arguments) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 05/11] configure: Fix compiler warning in config.log (unused variable) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 06/11] configure: Fix compiler warning in config.log (macro redefined) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 07/11] configure: Fix compiler warnings in config.log (uninitialized variable) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 08/11] configure: Fix compiler warning in config.log (undefined NULL) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 09/11] configure: Fix compiler warning in config.log (value was never used) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 10/11] configure: Fix compiler warnings in config.log (statement without effect) Stefan Weil
2011-12-17  8:27 ` [Qemu-devel] [PATCH 11/11] configure: Improve Xen autodetection for hosts without Xen Stefan Weil
2012-01-04 17:00   ` Stefano Stabellini
2011-12-17 11:43 ` [Qemu-devel] [PATCH 00/11] configure: Fix compiler warnings in config.log Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.