public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1192] testsuite, analyzer: Fix testcases with fclose
@ 2023-05-25 5:51 Christophe Lyon
0 siblings, 0 replies; only message in thread
From: Christophe Lyon @ 2023-05-25 5:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c9a19621a07e246385ae075b61283140b23c3b5a
commit r14-1192-gc9a19621a07e246385ae075b61283140b23c3b5a
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date: Tue May 23 09:20:05 2023 +0000
testsuite, analyzer: Fix testcases with fclose
The gcc.dg/analyzer/data-model-4.c and
gcc.dg/analyzer/torture/conftest-1.c fail with recent glibc headers
and succeed with older headers.
The new error message is:
warning: use of possibly-NULL 'f' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
Like similar previous fixes in this area, this patch updates the
testcase so that this warning isn't reported.
2023-05-23 Christophe Lyon <christophe.lyon@linaro.org>
gcc/testsuite/
* gcc.dg/analyzer/data-model-4.c: Exit if fopen returns NULL.
* gcc.dg/analyzer/torture/conftest-1.c: Likewise.
Diff:
---
gcc/testsuite/gcc.dg/analyzer/data-model-4.c | 2 ++
gcc/testsuite/gcc.dg/analyzer/torture/conftest-1.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-4.c b/gcc/testsuite/gcc.dg/analyzer/data-model-4.c
index 33f90871dfb..d41868d6dbc 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-4.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-4.c
@@ -8,6 +8,8 @@ int
main ()
{
FILE *f = fopen ("conftest.out", "w");
+ if (f == NULL)
+ return 1;
return ferror (f) || fclose (f) != 0;
;
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/conftest-1.c b/gcc/testsuite/gcc.dg/analyzer/torture/conftest-1.c
index 0cf85f0ebe1..9631bcf73e0 100644
--- a/gcc/testsuite/gcc.dg/analyzer/torture/conftest-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/conftest-1.c
@@ -3,6 +3,8 @@ int
main ()
{
FILE *f = fopen ("conftest.out", "w");
+ if (f == NULL)
+ return 1;
return ferror (f) || fclose (f) != 0;
;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-25 5:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 5:51 [gcc r14-1192] testsuite, analyzer: Fix testcases with fclose Christophe Lyon
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 read-only IMAP folder(s) and NNTP newsgroup(s).