1 /* Verify absence of false positive from -Wanalyzer-mismatching-deallocation
3 Based on https://github.com/libguestfs/libguestfs/blob/f19fd566f6387ce7e4d82409528c9dde374d25e0/daemon/command.c#L115
4 which is GPLv2 or later. */
6 typedef __SIZE_TYPE__
size_t;
7 typedef __builtin_va_list
va_list;
9 #define NULL ((void *)0)
11 extern void *malloc (size_t __size
)
12 __attribute__ ((__nothrow__
, __leaf__
))
13 __attribute__ ((__malloc__
))
14 __attribute__ ((__alloc_size__ (1)));
15 extern void perror (const char *__s
);
16 extern void *realloc (void *__ptr
, size_t __size
)
17 __attribute__ ((__nothrow__
, __leaf__
))
18 __attribute__ ((__warn_unused_result__
))
19 __attribute__ ((__alloc_size__ (2)));
21 extern void guestfs_int_cleanup_free (void *ptr
);
22 extern int commandrvf (char **stdoutput
, char **stderror
, unsigned flags
,
23 char const* const *argv
);
24 #define CLEANUP_FREE __attribute__((cleanup(guestfs_int_cleanup_free)))
27 commandrf (char **stdoutput
, char **stderror
, unsigned flags
,
28 const char *name
, ...)
31 CLEANUP_FREE
const char **argv
= NULL
;
35 /* Collect the command line arguments into an array. */
37 argv
= malloc (sizeof (char *) * i
);
43 argv
[0] = (char *) name
;
46 __builtin_va_start (args
, name
);
48 while ((s
= __builtin_va_arg (args
, char *)) != NULL
) {
49 const char **p
= realloc (argv
, sizeof (char *) * (++i
)); /* { dg-bogus "'free'" } */
52 __builtin_va_end (args
);
60 __builtin_va_end (args
);
62 r
= commandrvf (stdoutput
, stderror
, flags
, argv
);