Skip to content

Commit

Permalink
Fix and clean code which tests the gcc version
Browse files Browse the repository at this point in the history
The code which tests whether gcc supports warn_unused_result was wrong.
Remove the wrong test from configure and replace it by code using
macro QEMU_GNUC_PREREQ in compiler.h.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
Stefan Weil authored and Anthony Liguori committed Sep 23, 2011
1 parent f8b7275 commit 8775179
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion compiler.h
Expand Up @@ -18,7 +18,7 @@


#define QEMU_NORETURN __attribute__ ((__noreturn__)) #define QEMU_NORETURN __attribute__ ((__noreturn__))


#ifdef CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT #if QEMU_GNUC_PREREQ(3, 4)
#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else #else
#define QEMU_WARN_UNUSED_RESULT #define QEMU_WARN_UNUSED_RESULT
Expand Down
20 changes: 0 additions & 20 deletions configure
Expand Up @@ -2359,23 +2359,6 @@ if compile_prog "" "" ; then
need_offsetof=no need_offsetof=no
fi 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

# spice probe # spice probe
if test "$spice" != "no" ; then if test "$spice" != "no" ; then
cat > $TMPC << EOF cat > $TMPC << EOF
Expand Down Expand Up @@ -2998,9 +2981,6 @@ fi
if test "$need_offsetof" = "yes" ; then if test "$need_offsetof" = "yes" ; then
echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
fi 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 if test "$fdatasync" = "yes" ; then
echo "CONFIG_FDATASYNC=y" >> $config_host_mak echo "CONFIG_FDATASYNC=y" >> $config_host_mak
fi fi
Expand Down

0 comments on commit 8775179

Please sign in to comment.