From: Tom de Vries Date: Fri, 1 May 2020 09:04:22 +0000 (+0200) Subject: [gdb/testsuite] Fix Wunused-result warning in until-reverse.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=53ae0aa9c65bc41b6f67f52a657b9f5339a331be;p=binutils-gdb.git [gdb/testsuite] Fix Wunused-result warning in until-reverse.c When running test-case gdb.reverse/until-reverse.exp or gdb.reverse/until-precsave.exp with gcc-10, we run into a Wunused-result warning: ... gdb compile failed, gdb.reverse/until-reverse.c: In function 'main': gdb.reverse/until-reverse.c:40:14: warning: ignoring return value of \ 'malloc' declared with attribute 'warn_unused_result' [-Wunused-result] 40 | (void) malloc (1); | ^~~~~~~~~~ ... Fix this by using the result of malloc as argument to a free call. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-01 Tom de Vries * gdb.reverse/until-reverse.c (main): Fix Wunused-result warning. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e2bf45b3e3b..210499af06d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-05-01 Tom de Vries + + * gdb.reverse/until-reverse.c (main): Fix Wunused-result warning. + 2020-04-30 Hannes Domani PR gdb/18706 diff --git a/gdb/testsuite/gdb.reverse/until-reverse.c b/gdb/testsuite/gdb.reverse/until-reverse.c index e523235f34c..a8d8aed9aac 100644 --- a/gdb/testsuite/gdb.reverse/until-reverse.c +++ b/gdb/testsuite/gdb.reverse/until-reverse.c @@ -37,7 +37,8 @@ main (int argc, char **argv, char **envp) { /* We're used by a test that requires malloc, so make sure it is in the executable. */ - (void) malloc (1); + void *p = malloc (1); + free (p); return 1; }