Bug Summary

File:cdk/tmp-introspectvyiqd_q_/Cdk-3.0.c
Warning:line 89, column 13
Read function called when stream is in EOF state. Function has no effect

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Cdk-3.0.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/cdk -fcoverage-compilation-dir=/rootdir/cdk -resource-dir /usr/lib/llvm-19/lib/clang/19 -D G_LOG_DOMAIN="Cdk" -D G_LOG_USE_STRUCTURED=1 -D CDK_COMPILATION -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /rootdir -I /rootdir/cdk -I /rootdir -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-declarations -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-12-22-120316-43637-1 -x c /rootdir/cdk/tmp-introspectvyiqd_q_/Cdk-3.0.c
1/* This file is generated, do not edit */
2
3#undef GLIB_VERSION_MIN_REQUIRED((((2) << 16 | (82) << 8)))
4#undef GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (82) << 8)))
5
6#include <glib.h>
7#include <string.h>
8#include <stdlib.h>
9
10/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
11 * GObject introspection: Dump introspection data
12 *
13 * Copyright (C) 2008 Colin Walters <walters@verbum.org>
14 *
15 * SPDX-License-Identifier: LGPL-2.1-or-later
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 * Boston, MA 02111-1307, USA.
31 */
32
33/* This file is both compiled into libgirepository.so, and installed
34 * on the filesystem. But for the dumper, we want to avoid linking
35 * to libgirepository; see
36 * https://bugzilla.gnome.org/show_bug.cgi?id=630342
37 */
38#ifdef G_IREPOSITORY_COMPILATION
39#include "config.h"
40#include "girepository.h"
41#endif
42
43#include <glib.h>
44#include <glib-object.h>
45#include <gmodule.h>
46
47#include <stdlib.h>
48#include <stdio.h>
49#include <string.h>
50
51/* Analogue of g_output_stream_write_all(). */
52static gboolean
53write_all (FILE *out,
54 const void *buffer,
55 gsize count,
56 gsize *bytes_written,
57 GError **error)
58{
59 size_t ret;
60
61 ret = fwrite (buffer, 1, count, out);
62
63 if (bytes_written != NULL((void*)0))
64 *bytes_written = ret;
65
66 if (ret < count)
67 {
68 g_set_error (error, G_FILE_ERRORg_file_error_quark (), G_FILE_ERROR_FAILED,
69 "Failed to write to file");
70 return FALSE(0);
71 }
72
73 return TRUE(!(0));
74}
75
76/* Analogue of g_data_input_stream_read_line(). */
77static char *
78read_line (FILE *input,
79 size_t *len_out)
80{
81 GByteArray *buffer = g_byte_array_new ();
82 const guint8 nul = '\0';
83
84 while (TRUE(!(0)))
14
Loop condition is true. Entering loop body
28
Loop condition is true. Entering loop body
85 {
86 size_t ret;
87 guint8 byte;
88
89 ret = fread (&byte, 1, 1, input);
15
Assuming stream reaches end-of-file here
29
Read function called when stream is in EOF state. Function has no effect
90 if (ret
15.1
'ret' is equal to 0
== 0)
16
Taking true branch
91 break;
92
93 if (byte == '\n')
94 break;
95
96 g_byte_array_append (buffer, &byte, 1);
97 }
98
99 g_byte_array_append (buffer, &nul, 1);
100
101 if (len_out
16.1
'len_out' is not equal to NULL
!= NULL((void*)0))
17
Taking true branch
102 *len_out = buffer->len - 1; /* don’t include terminating nul */
103
104 return (char *) g_byte_array_free (buffer, FALSE(0));
105}
106
107static void
108escaped_printf (FILE *out, const char *fmt, ...) G_GNUC_PRINTF (2, 3)__attribute__((__format__ (__printf__, 2, 3)));
109
110static void
111escaped_printf (FILE *out, const char *fmt, ...)
112{
113 char *str;
114 va_list args;
115 gsize written;
116 GError *error = NULL((void*)0);
117
118 va_start (args, fmt)__builtin_va_start(args, fmt);
119
120 str = g_markup_vprintf_escaped (fmt, args);
121 if (!write_all (out, str, strlen (str), &written, &error))
122 {
123 g_critical ("failed to write to iochannel: %s", error->message);
124 g_clear_error (&error);
125 }
126 g_free (str);
127
128 va_end (args)__builtin_va_end(args);
129}
130
131static void
132goutput_write (FILE *out, const char *str)
133{
134 gsize written;
135 GError *error = NULL((void*)0);
136 if (!write_all (out, str, strlen (str), &written, &error))
137 {
138 g_critical ("failed to write to iochannel: %s", error->message);
139 g_clear_error (&error);
140 }
141}
142
143typedef GType (*GetTypeFunc)(void);
144typedef GQuark (*ErrorQuarkFunc)(void);
145
146static GType
147invoke_get_type (GModule *self, const char *symbol, GError **error)
148{
149 GetTypeFunc sym;
150 GType ret;
151
152 if (!g_module_symbol (self, symbol, (void**)&sym))
153 {
154 g_set_error (error,
155 G_FILE_ERRORg_file_error_quark (),
156 G_FILE_ERROR_FAILED,
157 "Failed to find symbol '%s'", symbol);
158 return G_TYPE_INVALID((GType) ((0) << (2)));
159 }
160
161 ret = sym ();
162 if (ret == G_TYPE_INVALID((GType) ((0) << (2))))
163 {
164 g_set_error (error,
165 G_FILE_ERRORg_file_error_quark (),
166 G_FILE_ERROR_FAILED,
167 "Function '%s' returned G_TYPE_INVALID", symbol);
168 }
169 return ret;
170}
171
172static GQuark
173invoke_error_quark (GModule *self, const char *symbol, GError **error)
174{
175 ErrorQuarkFunc sym;
176
177 if (!g_module_symbol (self, symbol, (void**)&sym))
178 {
179 g_set_error (error,
180 G_FILE_ERRORg_file_error_quark (),
181 G_FILE_ERROR_FAILED,
182 "Failed to find symbol '%s'", symbol);
183 return G_TYPE_INVALID((GType) ((0) << (2)));
184 }
185
186 return sym ();
187}
188
189static char *
190value_transform_to_string (const GValue *value)
191{
192 GValue tmp = G_VALUE_INIT{ 0, { { 0 } } };
193 char *s = NULL((void*)0);
194
195 g_value_init (&tmp, G_TYPE_STRING((GType) ((16) << (2))));
196
197 if (g_value_transform (value, &tmp))
198 {
199 const char *str = g_value_get_string (&tmp);
200
201 if (str != NULL((void*)0))
202 s = g_strescape (str, NULL((void*)0));
203 }
204
205 g_value_unset (&tmp);
206
207 return s;
208}
209
210/* A simpler version of g_strdup_value_contents(), but with stable
211 * output and less complex semantics
212 */
213static char *
214value_to_string (const GValue *value)
215{
216 if (value == NULL((void*)0))
217 return NULL((void*)0);
218
219 if (G_VALUE_HOLDS_STRING (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value
)); GType __t = (((GType) ((16) << (2)))); gboolean __r
; if (!__val) __r = (0); else if (__val->g_type == __t) __r
= (!(0)); else __r = g_type_check_value_holds (__val, __t); __r
; }))))
)
220 {
221 const char *s = g_value_get_string (value);
222
223 if (s == NULL((void*)0))
224 return g_strdup ("NULL")g_strdup_inline ("NULL");
225
226 return g_strescape (s, NULL((void*)0));
227 }
228 else
229 {
230 GType value_type = G_VALUE_TYPE (value)(((GValue*) (value))->g_type);
231
232 switch (G_TYPE_FUNDAMENTAL (value_type)(g_type_fundamental (value_type)))
233 {
234 case G_TYPE_BOXED((GType) ((18) << (2))):
235 if (g_value_get_boxed (value) == NULL((void*)0))
236 return NULL((void*)0);
237 else
238 return value_transform_to_string (value);
239 break;
240
241 case G_TYPE_OBJECT((GType) ((20) << (2))):
242 if (g_value_get_object (value) == NULL((void*)0))
243 return NULL((void*)0);
244 else
245 return value_transform_to_string (value);
246 break;
247
248 case G_TYPE_POINTER((GType) ((17) << (2))):
249 return NULL((void*)0);
250
251 default:
252 return value_transform_to_string (value);
253 }
254 }
255
256 return NULL((void*)0);
257}
258
259static void
260dump_properties (GType type, FILE *out)
261{
262 guint i;
263 guint n_properties = 0;
264 GParamSpec **props;
265
266 if (G_TYPE_FUNDAMENTAL (type)(g_type_fundamental (type)) == G_TYPE_OBJECT((GType) ((20) << (2))))
267 {
268 GObjectClass *klass;
269 klass = g_type_class_ref (type);
270 props = g_object_class_list_properties (klass, &n_properties);
271 }
272 else
273 {
274 void *klass;
275 klass = g_type_default_interface_ref (type);
276 props = g_object_interface_list_properties (klass, &n_properties);
277 }
278
279 for (i = 0; i < n_properties; i++)
280 {
281 GParamSpec *prop;
282
283 prop = props[i];
284 if (prop->owner_type != type)
285 continue;
286
287 const GValue *v = g_param_spec_get_default_value (prop);
288 char *default_value = value_to_string (v);
289
290 if (v != NULL((void*)0) && default_value != NULL((void*)0))
291 {
292 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\" default-value=\"%s\"/>\n",
293 prop->name,
294 g_type_name (prop->value_type),
295 prop->flags,
296 default_value);
297 }
298 else
299 {
300 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\"/>\n",
301 prop->name,
302 g_type_name (prop->value_type),
303 prop->flags);
304 }
305
306 g_free (default_value);
307 }
308
309 g_free (props);
310}
311
312static void
313dump_signals (GType type, FILE *out)
314{
315 guint i;
316 guint n_sigs;
317 guint *sig_ids;
318
319 sig_ids = g_signal_list_ids (type, &n_sigs);
320 for (i = 0; i < n_sigs; i++)
321 {
322 guint sigid;
323 GSignalQuery query;
324 guint j;
325
326 sigid = sig_ids[i];
327 g_signal_query (sigid, &query);
328
329 escaped_printf (out, " <signal name=\"%s\" return=\"%s\"",
330 query.signal_name, g_type_name (query.return_type));
331
332 if (query.signal_flags & G_SIGNAL_RUN_FIRST)
333 escaped_printf (out, " when=\"first\"");
334 else if (query.signal_flags & G_SIGNAL_RUN_LAST)
335 escaped_printf (out, " when=\"last\"");
336 else if (query.signal_flags & G_SIGNAL_RUN_CLEANUP)
337 escaped_printf (out, " when=\"cleanup\"");
338 else if (query.signal_flags & G_SIGNAL_MUST_COLLECT)
339 escaped_printf (out, " when=\"must-collect\"");
340 if (query.signal_flags & G_SIGNAL_NO_RECURSE)
341 escaped_printf (out, " no-recurse=\"1\"");
342
343 if (query.signal_flags & G_SIGNAL_DETAILED)
344 escaped_printf (out, " detailed=\"1\"");
345
346 if (query.signal_flags & G_SIGNAL_ACTION)
347 escaped_printf (out, " action=\"1\"");
348
349 if (query.signal_flags & G_SIGNAL_NO_HOOKS)
350 escaped_printf (out, " no-hooks=\"1\"");
351
352 goutput_write (out, ">\n");
353
354 for (j = 0; j < query.n_params; j++)
355 {
356 escaped_printf (out, " <param type=\"%s\"/>\n",
357 g_type_name (query.param_types[j]));
358 }
359 goutput_write (out, " </signal>\n");
360 }
361 g_free (sig_ids);
362}
363
364static void
365dump_object_type (GType type, const char *symbol, FILE *out)
366{
367 guint n_interfaces;
368 guint i;
369 GType *interfaces;
370
371 escaped_printf (out, " <class name=\"%s\" get-type=\"%s\"",
372 g_type_name (type), symbol);
373 if (type != G_TYPE_OBJECT((GType) ((20) << (2))))
374 {
375 GString *parent_str;
376 GType parent;
377 gboolean first = TRUE(!(0));
378
379 parent = g_type_parent (type);
380 parent_str = g_string_new ("");
381 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
382 {
383 if (first)
384 first = FALSE(0);
385 else
386 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
387 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen (
((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(parent_str, g_type_name (parent), (gssize) -1))
;
388 parent = g_type_parent (parent);
389 }
390
391 escaped_printf (out, " parents=\"%s\"", parent_str->str);
392
393 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
394 }
395
396 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
397 escaped_printf (out, " abstract=\"1\"");
398
399 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
400 escaped_printf (out, " final=\"1\"");
401
402 goutput_write (out, ">\n");
403
404 interfaces = g_type_interfaces (type, &n_interfaces);
405 for (i = 0; i < n_interfaces; i++)
406 {
407 GType itype = interfaces[i];
408 escaped_printf (out, " <implements name=\"%s\"/>\n",
409 g_type_name (itype));
410 }
411 g_free (interfaces);
412
413 dump_properties (type, out);
414 dump_signals (type, out);
415 goutput_write (out, " </class>\n");
416}
417
418static void
419dump_interface_type (GType type, const char *symbol, FILE *out)
420{
421 guint n_interfaces;
422 guint i;
423 GType *interfaces;
424
425 escaped_printf (out, " <interface name=\"%s\" get-type=\"%s\">\n",
426 g_type_name (type), symbol);
427
428 interfaces = g_type_interface_prerequisites (type, &n_interfaces);
429 for (i = 0; i < n_interfaces; i++)
430 {
431 GType itype = interfaces[i];
432 if (itype == G_TYPE_OBJECT((GType) ((20) << (2))))
433 {
434 /* Treat this as implicit for now; in theory GInterfaces are
435 * supported on things like GstMiniObject, but right now
436 * the introspection system only supports GObject.
437 * http://bugzilla.gnome.org/show_bug.cgi?id=559706
438 */
439 continue;
440 }
441 escaped_printf (out, " <prerequisite name=\"%s\"/>\n",
442 g_type_name (itype));
443 }
444 g_free (interfaces);
445
446 dump_properties (type, out);
447 dump_signals (type, out);
448 goutput_write (out, " </interface>\n");
449}
450
451static void
452dump_boxed_type (GType type, const char *symbol, FILE *out)
453{
454 escaped_printf (out, " <boxed name=\"%s\" get-type=\"%s\"/>\n",
455 g_type_name (type), symbol);
456}
457
458static void
459dump_pointer_type (GType type, const char *symbol, FILE *out)
460{
461 escaped_printf (out, " <pointer name=\"%s\" get-type=\"%s\"/>\n",
462 g_type_name (type), symbol);
463}
464
465static void
466dump_flags_type (GType type, const char *symbol, FILE *out)
467{
468 guint i;
469 GFlagsClass *klass;
470
471 klass = g_type_class_ref (type);
472 escaped_printf (out, " <flags name=\"%s\" get-type=\"%s\">\n",
473 g_type_name (type), symbol);
474
475 for (i = 0; i < klass->n_values; i++)
476 {
477 GFlagsValue *value = &(klass->values[i]);
478
479 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%u\"/>\n",
480 value->value_name, value->value_nick, value->value);
481 }
482 goutput_write (out, " </flags>\n");
483}
484
485static void
486dump_enum_type (GType type, const char *symbol, FILE *out)
487{
488 guint i;
489 GEnumClass *klass;
490
491 klass = g_type_class_ref (type);
492 escaped_printf (out, " <enum name=\"%s\" get-type=\"%s\">\n",
493 g_type_name (type), symbol);
494
495 for (i = 0; i < klass->n_values; i++)
496 {
497 GEnumValue *value = &(klass->values[i]);
498
499 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%d\"/>\n",
500 value->value_name, value->value_nick, value->value);
501 }
502 goutput_write (out, " </enum>");
503}
504
505static void
506dump_fundamental_type (GType type, const char *symbol, FILE *out)
507{
508 guint n_interfaces;
509 guint i;
510 GType *interfaces;
511 GString *parent_str;
512 GType parent;
513 gboolean first = TRUE(!(0));
514
515
516 escaped_printf (out, " <fundamental name=\"%s\" get-type=\"%s\"",
517 g_type_name (type), symbol);
518
519 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
520 escaped_printf (out, " abstract=\"1\"");
521
522 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
523 escaped_printf (out, " final=\"1\"");
524
525 if (G_TYPE_IS_INSTANTIATABLE (type)(g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)))
526 escaped_printf (out, " instantiatable=\"1\"");
527
528 parent = g_type_parent (type);
529 parent_str = g_string_new ("");
530 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
531 {
532 if (first)
533 first = FALSE(0);
534 else
535 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
536 if (!g_type_name (parent))
537 break;
538 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen (
((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(parent_str, g_type_name (parent), (gssize) -1))
;
539 parent = g_type_parent (parent);
540 }
541
542 if (parent_str->len > 0)
543 escaped_printf (out, " parents=\"%s\"", parent_str->str);
544 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
545
546 goutput_write (out, ">\n");
547
548 interfaces = g_type_interfaces (type, &n_interfaces);
549 for (i = 0; i < n_interfaces; i++)
550 {
551 GType itype = interfaces[i];
552 escaped_printf (out, " <implements name=\"%s\"/>\n",
553 g_type_name (itype));
554 }
555 g_free (interfaces);
556 goutput_write (out, " </fundamental>\n");
557}
558
559static void
560dump_type (GType type, const char *symbol, FILE *out)
561{
562 /* XXX: We need to ensure that global ancillary structures like
563 * GParamSpecPool are initialized before we use the GType and
564 * GObject reflection API to poke at things like properties and
565 * signals; we cannot rely on GObject being instantiated at this
566 * point.
567 */
568 GObjectClass *gobject_class = g_type_class_ref (G_TYPE_OBJECT((GType) ((20) << (2))));
569
570 switch (g_type_fundamental (type))
571 {
572 case G_TYPE_OBJECT((GType) ((20) << (2))):
573 dump_object_type (type, symbol, out);
574 break;
575 case G_TYPE_INTERFACE((GType) ((2) << (2))):
576 dump_interface_type (type, symbol, out);
577 break;
578 case G_TYPE_BOXED((GType) ((18) << (2))):
579 dump_boxed_type (type, symbol, out);
580 break;
581 case G_TYPE_FLAGS((GType) ((13) << (2))):
582 dump_flags_type (type, symbol, out);
583 break;
584 case G_TYPE_ENUM((GType) ((12) << (2))):
585 dump_enum_type (type, symbol, out);
586 break;
587 case G_TYPE_POINTER((GType) ((17) << (2))):
588 dump_pointer_type (type, symbol, out);
589 break;
590 default:
591 dump_fundamental_type (type, symbol, out);
592 break;
593 }
594
595 g_type_class_unref ((GTypeClass *) gobject_class);
596}
597
598static void
599dump_error_quark (GQuark quark, const char *symbol, FILE *out)
600{
601 escaped_printf (out, " <error-quark function=\"%s\" domain=\"%s\"/>\n",
602 symbol, g_quark_to_string (quark));
603}
604
605/**
606 * g_irepository_dump:
607 * @input_filename: (type filename): Input filename (for example `input.txt`)
608 * @output_filename: (type filename): Output filename (for example `output.xml`)
609 * @error: a %GError
610 *
611 * Dump the introspection data from the types specified in @input_filename to
612 * @output_filename.
613 *
614 * The input file should be a
615 * UTF-8 Unix-line-ending text file, with each line containing either
616 * `get-type:` followed by the name of a [type@GObject.Type] `_get_type`
617 * function, or `error-quark:` followed by the name of an error quark function.
618 * No extra whitespace is allowed.
619 *
620 * This function will overwrite the contents of the output file.
621 *
622 * Returns: true on success, false on error
623 * Since: 2.80
624 */
625#ifndef G_IREPOSITORY_COMPILATION
626static gboolean
627dump_irepository (const char *arg,
628 GError **error) G_GNUC_UNUSED__attribute__ ((__unused__));
629static gboolean
630dump_irepository (const char *arg,
631 GError **error)
632#else
633gboolean
634g_irepository_dump (const char *arg,
635 GError **error)
636#endif
637{
638 GHashTable *output_types;
639 FILE *input;
640 FILE *output;
641 GModule *self;
642 gboolean caught_error = FALSE(0);
643
644 char **args = g_strsplit (arg, ",", 2);
645 if (args == NULL((void*)0))
6
Assuming 'args' is not equal to NULL
7
Taking false branch
646 {
647 g_set_error (error,
648 G_FILE_ERRORg_file_error_quark (),
649 G_FILE_ERROR_FAILED,
650 "Usage: --introspect-dump=input,output");
651 return FALSE(0);
652 }
653
654 const char *input_filename = args[0];
655 const char *output_filename = args[1];
656
657 self = g_module_open (NULL((void*)0), 0);
658 if (!self)
8
Assuming 'self' is non-null
9
Taking false branch
659 {
660 g_set_error (error,
661 G_FILE_ERRORg_file_error_quark (),
662 G_FILE_ERROR_FAILED,
663 "failed to open self: %s",
664 g_module_error ());
665 g_strfreev (args);
666 return FALSE(0);
667 }
668
669 input = fopen (input_filename, "rb");
670 if (input
9.1
'input' is not equal to NULL
== NULL((void*)0))
10
Taking false branch
671 {
672 int saved_errno = errno(*__errno_location ());
673 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
674 "Failed to open ‘%s’: %s", input_filename, g_strerror (saved_errno));
675
676 g_module_close (self);
677 g_strfreev (args);
678
679 return FALSE(0);
680 }
681
682 output = fopen (output_filename, "wb");
683 if (output
10.1
'output' is not equal to NULL
== NULL((void*)0))
11
Taking false branch
684 {
685 int saved_errno = errno(*__errno_location ());
686 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
687 "Failed to open ‘%s’: %s", output_filename, g_strerror (saved_errno));
688
689 fclose (input);
690 g_module_close (self);
691 g_strfreev (args);
692
693 return FALSE(0);
694 }
695
696 goutput_write (output, "<?xml version=\"1.0\"?>\n");
697 goutput_write (output, "<dump>\n");
698
699 output_types = g_hash_table_new (NULL((void*)0), NULL((void*)0));
700
701 while (TRUE(!(0)))
12
Loop condition is true. Entering loop body
26
Loop condition is true. Entering loop body
702 {
703 gsize len;
704 char *line = read_line (input, &len);
13
Calling 'read_line'
18
Returning from 'read_line'
27
Calling 'read_line'
705 const char *function;
706
707 if (line == NULL((void*)0) || *line == '\0')
19
Assuming 'line' is not equal to NULL
20
Assuming the condition is false
21
Taking false branch
708 {
709 g_free (line);
710 break;
711 }
712
713 g_strchomp (line);
714
715 if (strncmp (line, "get-type:", strlen ("get-type:")) == 0)
22
Assuming the condition is false
23
Taking false branch
716 {
717 GType type;
718
719 function = line + strlen ("get-type:");
720
721 type = invoke_get_type (self, function, error);
722
723 if (type == G_TYPE_INVALID((GType) ((0) << (2))))
724 {
725 g_printerr ("Invalid GType function: '%s'\n", function);
726 caught_error = TRUE(!(0));
727 g_free (line);
728 break;
729 }
730
731 if (g_hash_table_lookup (output_types, (gpointer) type))
732 goto next;
733 g_hash_table_insert (output_types, (gpointer) type, (gpointer) type);
734
735 dump_type (type, function, output);
736 }
737 else if (strncmp (line, "error-quark:", strlen ("error-quark:")) == 0)
24
Assuming the condition is false
25
Taking false branch
738 {
739 GQuark quark;
740 function = line + strlen ("error-quark:");
741 quark = invoke_error_quark (self, function, error);
742
743 if (quark == 0)
744 {
745 g_printerr ("Invalid error quark function: '%s'\n", function);
746 caught_error = TRUE(!(0));
747 g_free (line);
748 break;
749 }
750
751 dump_error_quark (quark, function, output);
752 }
753
754
755 next:
756 g_free (line);
757 }
758
759 g_hash_table_destroy (output_types);
760
761 goutput_write (output, "</dump>\n");
762
763 {
764 /* Avoid overwriting an earlier set error */
765 if (fclose (input) != 0 && !caught_error)
766 {
767 int saved_errno = errno(*__errno_location ());
768
769 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
770 "Error closing input file ‘%s’: %s", input_filename,
771 g_strerror (saved_errno));
772 caught_error = TRUE(!(0));
773 }
774
775 if (fclose (output) != 0 && !caught_error)
776 {
777 int saved_errno = errno(*__errno_location ());
778
779 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
780 "Error closing output file ‘%s’: %s", output_filename,
781 g_strerror (saved_errno));
782 caught_error = TRUE(!(0));
783 }
784 }
785
786 g_strfreev (args);
787
788 return !caught_error;
789}
790
791
792int
793main(int argc, char **argv)
794{
795 GError *error = NULL((void*)0);
796 const char *introspect_dump_prefix = "--introspect-dump=";
797
798#if !GLIB_CHECK_VERSION(2,35,0)(2 > (2) || (2 == (2) && 82 > (35)) || (2 == (2
) && 82 == (35) && 4 >= (0)))
799 g_type_init ();
800#endif
801
802
803
804 if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix)(__builtin_constant_p (introspect_dump_prefix)? __extension__
({ const char * const __str = (argv[1]); const char * const __prefix
= (introspect_dump_prefix); gboolean __result = (0); if (__str
== ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (argv[1], introspect_dump_prefix
) )
)
1
Assuming 'argc' is equal to 2
2
'?' condition is false
3
Assuming the condition is false
4
Taking false branch
805 {
806 g_printerr ("Usage: %s --introspect-dump=input,output", argv[0]);
807 exit (1);
808 }
809
810 if (!dump_irepository (argv[1] + strlen(introspect_dump_prefix), &error))
5
Calling 'dump_irepository'
811 {
812 g_printerr ("%s\n", error->message);
813 exit (1);
814 }
815 exit (0);
816}
817extern GType cdk_device_get_type(void);
818extern GType cdk_drag_context_get_type(void);
819extern GType cdk_device_tool_get_type(void);
820extern GType cdk_event_get_type(void);
821extern GType cdk_event_sequence_get_type(void);
822extern GType cdk_device_manager_get_type(void);
823extern GType cdk_drawing_context_get_type(void);
824extern GType cdk_frame_timings_get_type(void);
825extern GType cdk_frame_clock_get_type(void);
826extern GType cdk_window_get_type(void);
827extern GType cdk_seat_get_type(void);
828extern GType cdk_rectangle_get_type(void);
829extern GType cdk_monitor_get_type(void);
830extern GType cdk_display_get_type(void);
831extern GType cdk_screen_get_type(void);
832extern GType cdk_app_launch_context_get_type(void);
833extern GType cdk_color_get_type(void);
834extern GType cdk_rgba_get_type(void);
835extern GType cdk_cursor_get_type(void);
836extern GType cdk_device_pad_get_type(void);
837extern GType cdk_display_manager_get_type(void);
838extern GType cdk_cursor_type_get_type(void);
839extern GType cdk_input_source_get_type(void);
840extern GType cdk_input_mode_get_type(void);
841extern GType cdk_device_type_get_type(void);
842extern GType cdk_device_pad_feature_get_type(void);
843extern GType cdk_device_tool_type_get_type(void);
844extern GType cdk_drag_action_get_type(void);
845extern GType cdk_drag_cancel_reason_get_type(void);
846extern GType cdk_drag_protocol_get_type(void);
847extern GType cdk_filter_return_get_type(void);
848extern GType cdk_event_type_get_type(void);
849extern GType cdk_visibility_state_get_type(void);
850extern GType cdk_touchpad_gesture_phase_get_type(void);
851extern GType cdk_scroll_direction_get_type(void);
852extern GType cdk_notify_type_get_type(void);
853extern GType cdk_crossing_mode_get_type(void);
854extern GType cdk_property_state_get_type(void);
855extern GType cdk_window_state_get_type(void);
856extern GType cdk_setting_action_get_type(void);
857extern GType cdk_owner_change_get_type(void);
858extern GType cdk_frame_clock_phase_get_type(void);
859extern GType cdk_subpixel_layout_get_type(void);
860extern GType cdk_prop_mode_get_type(void);
861extern GType cdk_seat_capabilities_get_type(void);
862extern GType cdk_byte_order_get_type(void);
863extern GType cdk_modifier_type_get_type(void);
864extern GType cdk_modifier_intent_get_type(void);
865extern GType cdk_status_get_type(void);
866extern GType cdk_grab_status_get_type(void);
867extern GType cdk_grab_ownership_get_type(void);
868extern GType cdk_event_mask_get_type(void);
869extern GType cdk_gl_error_get_type(void);
870extern GType cdk_window_type_hint_get_type(void);
871extern GType cdk_axis_use_get_type(void);
872extern GType cdk_axis_flags_get_type(void);
873extern GType cdk_visual_type_get_type(void);
874extern GType cdk_window_window_class_get_type(void);
875extern GType cdk_window_type_get_type(void);
876extern GType cdk_window_attributes_type_get_type(void);
877extern GType cdk_window_hints_get_type(void);
878extern GType cdk_wm_decoration_get_type(void);
879extern GType cdk_wm_function_get_type(void);
880extern GType cdk_gravity_get_type(void);
881extern GType cdk_anchor_hints_get_type(void);
882extern GType cdk_window_edge_get_type(void);
883extern GType cdk_fullscreen_mode_get_type(void);
884extern GType cdk_gl_context_get_type(void);
885extern GType cdk_keymap_get_type(void);
886extern GType cdk_visual_get_type(void);
887G_MODULE_EXPORT__attribute__((visibility("default"))) GType (*GI_GET_TYPE_FUNCS_[])(void) = {
888 cdk_device_get_type,
889 cdk_drag_context_get_type,
890 cdk_device_tool_get_type,
891 cdk_event_get_type,
892 cdk_event_sequence_get_type,
893 cdk_device_manager_get_type,
894 cdk_drawing_context_get_type,
895 cdk_frame_timings_get_type,
896 cdk_frame_clock_get_type,
897 cdk_window_get_type,
898 cdk_seat_get_type,
899 cdk_rectangle_get_type,
900 cdk_monitor_get_type,
901 cdk_display_get_type,
902 cdk_screen_get_type,
903 cdk_app_launch_context_get_type,
904 cdk_color_get_type,
905 cdk_rgba_get_type,
906 cdk_cursor_get_type,
907 cdk_device_pad_get_type,
908 cdk_display_manager_get_type,
909 cdk_cursor_type_get_type,
910 cdk_input_source_get_type,
911 cdk_input_mode_get_type,
912 cdk_device_type_get_type,
913 cdk_device_pad_feature_get_type,
914 cdk_device_tool_type_get_type,
915 cdk_drag_action_get_type,
916 cdk_drag_cancel_reason_get_type,
917 cdk_drag_protocol_get_type,
918 cdk_filter_return_get_type,
919 cdk_event_type_get_type,
920 cdk_visibility_state_get_type,
921 cdk_touchpad_gesture_phase_get_type,
922 cdk_scroll_direction_get_type,
923 cdk_notify_type_get_type,
924 cdk_crossing_mode_get_type,
925 cdk_property_state_get_type,
926 cdk_window_state_get_type,
927 cdk_setting_action_get_type,
928 cdk_owner_change_get_type,
929 cdk_frame_clock_phase_get_type,
930 cdk_subpixel_layout_get_type,
931 cdk_prop_mode_get_type,
932 cdk_seat_capabilities_get_type,
933 cdk_byte_order_get_type,
934 cdk_modifier_type_get_type,
935 cdk_modifier_intent_get_type,
936 cdk_status_get_type,
937 cdk_grab_status_get_type,
938 cdk_grab_ownership_get_type,
939 cdk_event_mask_get_type,
940 cdk_gl_error_get_type,
941 cdk_window_type_hint_get_type,
942 cdk_axis_use_get_type,
943 cdk_axis_flags_get_type,
944 cdk_visual_type_get_type,
945 cdk_window_window_class_get_type,
946 cdk_window_type_get_type,
947 cdk_window_attributes_type_get_type,
948 cdk_window_hints_get_type,
949 cdk_wm_decoration_get_type,
950 cdk_wm_function_get_type,
951 cdk_gravity_get_type,
952 cdk_anchor_hints_get_type,
953 cdk_window_edge_get_type,
954 cdk_fullscreen_mode_get_type,
955 cdk_gl_context_get_type,
956 cdk_keymap_get_type,
957 cdk_visual_get_type
958};
959extern GQuark cdk_gl_error_quark(void);
960G_MODULE_EXPORT__attribute__((visibility("default"))) GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {
961 cdk_gl_error_quark
962};