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#define NULL ((void *)0)
33
34typedef unsigned char uint8_t;
35typedef char int8_t;
36typedef unsigned int uint32_t;
37typedef int int32_t;
38typedef long ssize_t;
39typedef unsigned long long uint64_t;
40typedef long long int64_t;
41typedef _Bool bool;
42
43
44
45typedef struct AddressSpace AddressSpace;
46typedef uint64_t hwaddr;
47
48static void __write(uint8_t *buf, ssize_t len)
49{
50 int first, last;
51 __coverity_negative_sink__(len);
52 if (len == 0) return;
53 buf[0] = first;
54 buf[len-1] = last;
55 __coverity_writeall__(buf);
56}
57
58static void __read(uint8_t *buf, ssize_t len)
59{
60 __coverity_negative_sink__(len);
61 if (len == 0) return;
62 int first = buf[0];
63 int last = buf[len-1];
64}
65
66bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf,
67 int len, bool is_write)
68{
69 bool result;
70
71
72
73 if (is_write) __write(buf, len); else __read(buf, len);
74
75 return result;
76}
77
78
79
80typedef struct {} name2keysym_t;
81static int get_keysym(const name2keysym_t *table,
82 const char *name)
83{
84 int result;
85 if (result > 0) {
86 __coverity_tainted_string_sanitize_content__(name);
87 return result;
88 } else {
89 return 0;
90 }
91}
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110void *malloc(size_t);
111void *calloc(size_t, size_t);
112void *realloc(void *, size_t);
113void free(void *);
114
115void *
116g_malloc(size_t n_bytes)
117{
118 void *mem;
119 __coverity_negative_sink__(n_bytes);
120 mem = malloc(n_bytes == 0 ? 1 : n_bytes);
121 if (!mem) __coverity_panic__();
122 return mem;
123}
124
125void *
126g_malloc0(size_t n_bytes)
127{
128 void *mem;
129 __coverity_negative_sink__(n_bytes);
130 mem = calloc(1, n_bytes == 0 ? 1 : n_bytes);
131 if (!mem) __coverity_panic__();
132 return mem;
133}
134
135void g_free(void *mem)
136{
137 free(mem);
138}
139
140void *g_realloc(void * mem, size_t n_bytes)
141{
142 __coverity_negative_sink__(n_bytes);
143 mem = realloc(mem, n_bytes == 0 ? 1 : n_bytes);
144 if (!mem) __coverity_panic__();
145 return mem;
146}
147
148void *g_try_malloc(size_t n_bytes)
149{
150 __coverity_negative_sink__(n_bytes);
151 return malloc(n_bytes == 0 ? 1 : n_bytes);
152}
153
154void *g_try_malloc0(size_t n_bytes)
155{
156 __coverity_negative_sink__(n_bytes);
157 return calloc(1, n_bytes == 0 ? 1 : n_bytes);
158}
159
160void *g_try_realloc(void *mem, size_t n_bytes)
161{
162 __coverity_negative_sink__(n_bytes);
163 return realloc(mem, n_bytes == 0 ? 1 : n_bytes);
164}
165
166
167
168typedef struct _GIOChannel GIOChannel;
169GIOChannel *g_io_channel_unix_new(int fd)
170{
171 GIOChannel *c = g_malloc0(sizeof(GIOChannel));
172 __coverity_escape__(fd);
173 return c;
174}
175
176void g_assertion_message_expr(const char *domain,
177 const char *file,
178 int line,
179 const char *func,
180 const char *expr)
181{
182 __coverity_panic__();
183}
184