]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite, analyzer: Fix testcases with fclose
authorChristophe Lyon <christophe.lyon@linaro.org>
Tue, 23 May 2023 09:20:05 +0000 (09:20 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Thu, 25 May 2023 05:50:40 +0000 (05:50 +0000)
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.

gcc/testsuite/gcc.dg/analyzer/data-model-4.c
gcc/testsuite/gcc.dg/analyzer/torture/conftest-1.c

index 33f90871dfbcda4cd28ad4497a490b92e9f77fda..d41868d6dbc2abe98fe4b54464f8e9a90f53e3eb 100644 (file)
@@ -8,6 +8,8 @@ int
 main ()
 {
   FILE *f = fopen ("conftest.out", "w");
+  if (f == NULL)
+    return 1;
   return ferror (f) || fclose (f) != 0;
 
   ;
index 0cf85f0ebe190f4442271b8e3e329deb08c539a8..9631bcf73e0d33e98c2fd67d1bbf868bf0d61b0c 100644 (file)
@@ -3,6 +3,8 @@ int
 main ()
 {
   FILE *f = fopen ("conftest.out", "w");
+  if (f == NULL)
+    return 1;
   return ferror (f) || fclose (f) != 0;
 
   ;