aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/pr99716-2.c
blob: adc9819643ae4f69c291e61f3231f33e0c2f0cd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Reduced from
   https://github.com/libguestfs/libguestfs/blob/e0a11061035d47b118c95706240bcc17fd576edc/tests/mount-local/test-parallel-mount-local.c#L299-L335
   which is GPLv2 or later.  */

#include <stdio.h>
#include <stdlib.h>

extern int foo (void);

void
test_mountpoint (const char *mp)
{
  const int nr_passes = 5 + (rand () & 31);
  int pass;
  int ret = 1;
  FILE *fp;

  for (pass = 0; pass < nr_passes; ++pass) {
    if (foo ()) {
      goto error;
    }
    fp = fopen ("file", "w");
    if (fp == NULL) {
      goto error;
    }
    fprintf (fp, "hello world\n");
    fclose (fp); /* { dg-bogus "double 'fclose'" } */
  }

  ret = 0;

 error:
  exit (ret);
}