Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/atomic-builtins-haproxy-proxy.c

raw
1 /* Reduced from haproxy-2.7.1's proxy.c */
2
3 /* { dg-require-effective-target sync_int_long_stack } */
4 /* { dg-require-effective-target sync_int_long } */
5
6 typedef __SIZE_TYPE__ size_t;
7
8 extern void* malloc(size_t __size)
9 __attribute__((__nothrow__, __leaf__, __malloc__, __alloc_size__(1)));
10
11 extern void free(void* __ptr) __attribute__((__nothrow__, __leaf__));
12
13 struct error_snapshot
14 {
15 /* [..snip...] */
16 };
17
18 struct proxy
19 {
20 /* [..snip...] */
21 struct error_snapshot *invalid_req, *invalid_rep;
22 /* [..snip...] */
23 };
24
25 extern unsigned int error_snapshot_id;
26
27 void
28 proxy_capture_error(struct proxy* proxy,
29 int is_back)
30 {
31 struct error_snapshot* es;
32 unsigned int ev_id;
33
34 /* [...snip...] */
35
36 ev_id = __atomic_fetch_add(&error_snapshot_id, 1, 5);
37
38 /* [...snip...] */
39
40 es = (struct error_snapshot *) malloc(sizeof(*es));
41 if (!es)
42 return;
43
44 /* [...snip...] */
45
46 if (is_back) {
47 es = __atomic_exchange_n(&proxy->invalid_rep, es, 4); /* { dg-bogus "leak" } */
48 } else {
49 es = __atomic_exchange_n(&proxy->invalid_req, es, 4); /* { dg-bogus "leak" } */
50 }
51
52 /* [...snip...] */
53
54 free(es);
55 }