Suppress warnings about 'warn_unused_result' attribute directive
authorBlue Swirl <blauwirbel@gmail.com>
Sun, 18 Oct 2009 16:26:06 +0000 (16:26 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 18 Oct 2009 16:26:06 +0000 (16:26 +0000)
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
configure
hw/qdev.h
qemu-common.h

index ca6d45c61242559d229a29a303f9f2f0e15fb2e2..7775b1b423ef1f7cb79e6726e9e85871f7593675 100755 (executable)
--- a/configure
+++ b/configure
@@ -1666,6 +1666,23 @@ if compile_prog "" "" ; then
     need_offsetof=no
 fi
 
+##########################################
+# check if the compiler understands attribute warn_unused_result
+#
+# This could be smarter, but gcc -Werror does not error out even when warning
+# about attribute warn_unused_result
+
+gcc_attribute_warn_unused_result=no
+cat > $TMPC << EOF
+#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
+#error gcc 3.3 or older
+#endif
+int main(void) { return 0;}
+EOF
+if compile_prog "" ""; then
+    gcc_attribute_warn_unused_result=yes
+fi
+
 ##########################################
 # check if we have fdatasync
 
@@ -1994,6 +2011,9 @@ fi
 if test "$need_offsetof" = "yes" ; then
   echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
 fi
+if test "$gcc_attribute_warn_unused_result" = "yes" ; then
+  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
+fi
 if test "$fdatasync" = "yes" ; then
   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
 fi
index 8cd843e763a0172197b38dacaaa91a4743c79ffe..6d61b3af8165fcc33e3e95eab3f7d3847046eca7 100644 (file)
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -100,7 +100,7 @@ struct CompatProperty {
 
 DeviceState *qdev_create(BusState *bus, const char *name);
 DeviceState *qdev_device_add(QemuOpts *opts);
-int qdev_init(DeviceState *dev) __attribute__((warn_unused_result));
+int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
 void qdev_init_nofail(DeviceState *dev);
 int qdev_unplug(DeviceState *dev);
 void qdev_free(DeviceState *dev);
index 8551862c51b1a318db23605d1274f89fda98041e..47272f58cb5ac7db65e2fdf81a215954d4b72cb5 100644 (file)
@@ -3,6 +3,11 @@
 #define QEMU_COMMON_H
 
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
+#ifdef CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT
+#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+#define QEMU_WARN_UNUSED_RESULT
+#endif
 
 /* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that
    cannot include the following headers without conflicts. This condition has