summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorLeonid Bloch2020-05-25 00:12:04 +0200
committerPaolo Bonzini2020-06-10 18:10:50 +0200
commitf2dfe54c74f768a5bf78c9e5918918727f9d9459 (patch)
tree40290a59c6879028d81d34717828e6257392438e /configure
parentqemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute (diff)
downloadqemu-f2dfe54c74f768a5bf78c9e5918918727f9d9459.tar.gz
qemu-f2dfe54c74f768a5bf78c9e5918918727f9d9459.tar.xz
qemu-f2dfe54c74f768a5bf78c9e5918918727f9d9459.zip
configure: Do not ignore malloc value
Not checking the value of malloc will cause a warning with GCC 10.1, which may result in configuration failure, with the following line in config.log: config-temp/qemu-conf.c:2:18: error: ignoring return value of ‘malloc’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 2 | int main(void) { malloc(1); return 0; } | ^~~~~~~~~ Signed-off-by: Leonid Bloch <lb.workbox@gmail.com> Message-Id: <20200524221204.9791-1-lb.workbox@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure20
1 files changed, 17 insertions, 3 deletions
diff --git a/configure b/configure
index 53a6dd0297..dbc16b5656 100755
--- a/configure
+++ b/configure
@@ -4587,7 +4587,13 @@ fi
if test "$tcmalloc" = "yes" ; then
cat > $TMPC << EOF
#include <stdlib.h>
-int main(void) { malloc(1); return 0; }
+int main(void) {
+ void *tmp = malloc(1);
+ if (tmp != NULL) {
+ return 0;
+ }
+ return 1;
+}
EOF
if compile_prog "" "-ltcmalloc" ; then
@@ -4603,7 +4609,13 @@ fi
if test "$jemalloc" = "yes" ; then
cat > $TMPC << EOF
#include <stdlib.h>
-int main(void) { malloc(1); return 0; }
+int main(void) {
+ void *tmp = malloc(1);
+ if (tmp != NULL) {
+ return 0;
+ }
+ return 1;
+}
EOF
if compile_prog "" "-ljemalloc" ; then
@@ -6164,7 +6176,9 @@ if test "$sanitizers" = "yes" ; then
#include <stdlib.h>
int main(void) {
void *tmp = malloc(10);
- return *(int *)(tmp + 2);
+ if (tmp != NULL) {
+ return *(int *)(tmp + 2);
+ }
}
EOF
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then