1 /* Verify absence of false positive from -Wanalyzer-mismatching-deallocation
3 Based on https://github.com/libguestfs/libguestfs/blob/f19fd566f6387ce7e4d82409528c9dde374d25e0/df/main.c#L404
4 which is GPLv2 or later. */
6 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
8 typedef __SIZE_TYPE__
size_t;
9 typedef __builtin_va_list
va_list;
11 #include "../../gcc.dg/analyzer/analyzer-decls.h"
13 extern void free (void *);
14 extern void *realloc (void *__ptr
, size_t __size
)
15 __attribute__ ((__nothrow__
, __leaf__
))
16 __attribute__ ((__warn_unused_result__
))
17 __attribute__ ((__alloc_size__ (2)));
18 char *strdup (const char *)
19 __attribute__((malloc (free
)));
21 extern void error (int __status
, int __errnum
, const char *__format
, ...)
22 __attribute__ ((__format__ (__printf__
, 3, 4)));
31 #define EXIT_FAILURE 1
34 single_drive_display_name (struct drv
*)
36 char *result
= strdup ("placeholder");
43 make_display_name (struct drv
*drvs
)
47 if (drvs
->next
== NULL
)
48 ret
= single_drive_display_name (drvs
);
53 while (drvs
->next
!= NULL
) {
58 ret
= single_drive_display_name (drvs
);
59 len
= __builtin_strlen (ret
);
61 ret
= (char *) realloc (ret
, len
+ pluses
+ 1); /* { dg-bogus "'free'" } */
63 error (EXIT_FAILURE
, errno
, "realloc");
64 for (i
= len
; i
< len
+ pluses
; ++i
)