From: Paolo Bonzini <pbonzini@redhat.com>
To: Leonid Bloch <lb.workbox@gmail.com>, qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: Re: [PATCH] configure: Do not ignore malloc value
Date: Thu, 4 Jun 2020 19:57:51 +0200 [thread overview]
Message-ID: <5d5eec2d-f95e-4c12-4427-8e6b68fa1426@redhat.com> (raw)
In-Reply-To: <20200524221204.9791-1-lb.workbox@gmail.com>
On 25/05/20 00:12, Leonid Bloch wrote:
> From: Leonid Bloch <lbloch@janustech.com>
>
> 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>
> ---
> configure | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 2fc05c4465..d0220b2944 100755
> --- a/configure
> +++ b/configure
> @@ -4567,7 +4567,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
> @@ -4583,7 +4589,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
> @@ -6144,7 +6156,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
>
Queued, thanks.
Paolo
prev parent reply other threads:[~2020-06-04 17:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-24 22:12 [PATCH] configure: Do not ignore malloc value Leonid Bloch
2020-05-25 4:20 ` Philippe Mathieu-Daudé
2020-06-04 17:57 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d5eec2d-f95e-4c12-4427-8e6b68fa1426@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=laurent@vivier.eu \
--cc=lb.workbox@gmail.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).