Bug Summary

File:_build/../cdk-pixbuf/cdk-pixbuf-csource.c
Warning:line 133, column 17
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cdk-pixbuf-csource.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=none -relaxed-aliasing -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/_build -fcoverage-compilation-dir=/rootdir/_build -resource-dir /usr/lib/llvm-21/lib/clang/21 -I cdk-pixbuf/cdk-pixbuf-csource.p -I cdk-pixbuf -I ../cdk-pixbuf -I . -I .. -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 -D _FILE_OFFSET_BITS=64 -D _POSIX_C_SOURCE=200809L -D _DEFAULT_SOURCE -D _XOPEN_SOURCE=700 -D HAVE_CONFIG_H=1 -D G_LOG_STRUCTURED=1 -D G_LOG_DOMAIN="CdkPixbuf" -D CDK_PIXBUF_COMPILATION -D CDK_PIXBUF_PREFIX="/usr/local" -D CDK_PIXBUF_LOCALEDIR="/usr/local/share/locale" -D CDK_PIXBUF_LIBDIR="/usr/local/lib/x86_64-linux-gnu" -D CDK_PIXBUF_BINARY_VERSION="2.10.0" -D CDK_PIXBUF_ENABLE_BACKEND -D PIXBUF_LIBDIR="/usr/local/lib/x86_64-linux-gnu/cdk-pixbuf-2.0/2.10.0/loaders" -D BUILT_MODULES_DIR="/rootdir/_build/cdk-pixbuf" -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-int-conversion -Wno-uninitialized -Wno-discarded-qualifiers -std=gnu99 -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -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/2026-08-29-083117-8036-1 -x c ../cdk-pixbuf/cdk-pixbuf-csource.c
1/* Cdk-Pixbuf-CSource - CdkPixbuf based image CSource generator
2 * Copyright (C) 1999, 2001 Tim Janik
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17#include "config.h"
18
19#include "cdk-pixbuf.h"
20#include "cdk-pixdata.h"
21#include <glib/gprintf.h>
22#include <stdlib.h>
23#include <string.h>
24
25
26/* --- defines --- */
27#undef G_LOG_DOMAIN"Cdk-Pixbuf-CSource"
28#define G_LOG_DOMAIN"Cdk-Pixbuf-CSource" "Cdk-Pixbuf-CSource"
29#define PRG_NAME"cdk-pixbuf-csource-3.0" "cdk-pixbuf-csource-3.0"
30#define PKG_NAME"cdk-pixbuf" "cdk-pixbuf"
31#define PKG_HTTP_HOME"https://github.com/cafe-desktop/ctk" "https://github.com/cafe-desktop/ctk"
32
33
34/* --- prototypes --- */
35static void parse_args (gint *argc_p,
36 gchar ***argv_p);
37static void print_blurb (FILE *bout,
38 gboolean print_help);
39
40
41/* --- variables --- */
42static guint gen_type = CDK_PIXDATA_DUMP_PIXDATA_STREAM;
43static guint gen_ctype = CDK_PIXDATA_DUMP_GTYPES | CDK_PIXDATA_DUMP_STATIC | CDK_PIXDATA_DUMP_CONST;
44static gboolean use_rle = TRUE(!(0));
45static gboolean with_decoder = FALSE(0);
46static gchar *image_name = "my_pixbuf";
47static gboolean build_list = FALSE(0);
48
49
50/* --- functions --- */
51static void
52print_csource (FILE *f_out,
53 CdkPixbuf *pixbuf)
54{
55G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
56 CdkPixdata pixdata;
57 gpointer free_me;
58 GString *gstring;
59
60 free_me = cdk_pixdata_from_pixbuf (&pixdata, pixbuf, use_rle);
61 gstring = cdk_pixdata_to_csource (&pixdata, image_name,
62 gen_type | gen_ctype |
63 (with_decoder ? CDK_PIXDATA_DUMP_RLE_DECODER : 0));
64
65 g_fprintf (f_out, "%s\n", gstring->str);
66
67 g_free (free_me)(__builtin_object_size ((free_me), 0) != ((size_t) - 1)) ? g_free_sized
(free_me, __builtin_object_size ((free_me), 0)) : (g_free) (
free_me)
;
68 g_string_free (gstring, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(gstring), ((!(0)))) : g_string_free_and_steal (gstring)) : (
g_string_free) ((gstring), ((!(0)))))
;
69G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
70}
71
72int
73main (int argc,
74 char *argv[])
75{
76 CdkPixbuf *pixbuf;
77 GError *error = NULL((void*)0);
78 gchar *infilename;
79
80 g_set_prgname ("cdk-pixbuf-csource");
81
82 /* parse args and do fast exits */
83 parse_args (&argc, &argv);
84
85 if (!build_list)
86 {
87 if (argc != 2)
88 {
89 print_blurb (stderrstderr, TRUE(!(0)));
90 return 1;
91 }
92
93#ifdef G_OS_WIN32
94 infilename = g_locale_to_utf8 (argv[1], -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
95#else
96 infilename = argv[1];
97#endif
98
99 pixbuf = cdk_pixbuf_new_from_file (infilename, &error);
100 if (!pixbuf)
101 {
102 g_fprintf (stderrstderr, "failed to load \"%s\": %s\n",
103 argv[1],
104 error->message);
105 g_error_free (error);
106 return 1;
107 }
108
109 print_csource (stdoutstdout, pixbuf);
110 g_object_unref (pixbuf);
111 }
112 else /* parse name, file pairs */
113 {
114 gchar **p = argv + 1;
115 guint j = argc - 1;
116 gboolean toggle = FALSE(0);
117
118 while (j--)
119 {
120#ifdef G_OS_WIN32
121 infilename = g_locale_to_utf8 (*p, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
122#else
123 infilename = *p;
124#endif
125
126 if (!toggle)
127 {
128 image_name = infilename;
129 p++;
130 }
131 else
132 {
133 pixbuf = cdk_pixbuf_new_from_file (infilename, &error);
This statement is never executed
134 if (!pixbuf)
135 {
136 g_fprintf (stderrstderr, "failed to load \"%s\": %s\n",
137 *p,
138 error->message);
139 g_error_free (error);
140 return 1;
141 }
142 print_csource (stdoutstdout, pixbuf);
143 g_object_unref (pixbuf);
144 p++;
145 }
146 toggle = !toggle;
147 }
148 }
149
150 return 0;
151}
152
153static void
154parse_args (gint *argc_p,
155 gchar ***argv_p)
156{
157 guint argc = *argc_p;
158 gchar **argv = *argv_p;
159 guint i, e;
160
161 for (i = 1; i < argc; i++)
162 {
163 if (strcmp ("--macros", argv[i]) == 0)
164 {
165 gen_type = CDK_PIXDATA_DUMP_MACROS;
166 argv[i] = NULL((void*)0);
167 }
168 else if (strcmp ("--struct", argv[i]) == 0)
169 {
170 gen_type = CDK_PIXDATA_DUMP_PIXDATA_STRUCT;
171 argv[i] = NULL((void*)0);
172 }
173 else if (strcmp ("--stream", argv[i]) == 0)
174 {
175 gen_type = CDK_PIXDATA_DUMP_PIXDATA_STREAM;
176 argv[i] = NULL((void*)0);
177 }
178 else if (strcmp ("--rle", argv[i]) == 0)
179 {
180 use_rle = TRUE(!(0));
181 argv[i] = NULL((void*)0);
182 }
183 else if (strcmp ("--raw", argv[i]) == 0)
184 {
185 use_rle = FALSE(0);
186 argv[i] = NULL((void*)0);
187 }
188 else if (strcmp ("--extern", argv[i]) == 0)
189 {
190 gen_ctype &= ~CDK_PIXDATA_DUMP_STATIC;
191 argv[i] = NULL((void*)0);
192 }
193 else if (strcmp ("--static", argv[i]) == 0)
194 {
195 gen_ctype |= CDK_PIXDATA_DUMP_STATIC;
196 argv[i] = NULL((void*)0);
197 }
198 else if (strcmp ("--decoder", argv[i]) == 0)
199 {
200 with_decoder = TRUE(!(0));
201 argv[i] = NULL((void*)0);
202 }
203 else if ((strcmp ("--name", argv[i]) == 0) ||
204 (strncmp ("--name=", argv[i], 7) == 0))
205 {
206 gchar *equal = argv[i] + 6;
207
208 if (*equal == '=')
209 image_name = g_strdup (equal + 1)g_strdup_inline (equal + 1);
210 else if (i + 1 < argc)
211 {
212 image_name = g_strdup (argv[i + 1])g_strdup_inline (argv[i + 1]);
213 argv[i] = NULL((void*)0);
214 i += 1;
215 }
216 argv[i] = NULL((void*)0);
217 }
218 else if (strcmp ("--build-list", argv[i]) == 0)
219 {
220 build_list = TRUE(!(0));
221 argv[i] = NULL((void*)0);
222 }
223 else if (strcmp ("-h", argv[i]) == 0 ||
224 strcmp ("--help", argv[i]) == 0)
225 {
226 print_blurb (stderrstderr, TRUE(!(0)));
227 argv[i] = NULL((void*)0);
228 exit (0);
229 }
230 else if (strcmp ("-v", argv[i]) == 0 ||
231 strcmp ("--version", argv[i]) == 0)
232 {
233 print_blurb (stderrstderr, FALSE(0));
234 argv[i] = NULL((void*)0);
235 exit (0);
236 }
237 else if (strcmp (argv[i], "--g-fatal-warnings") == 0)
238 {
239 GLogLevelFlags fatal_mask;
240
241 fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK(G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR));
242 fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
243 g_log_set_always_fatal (fatal_mask);
244
245 argv[i] = NULL((void*)0);
246 }
247 }
248
249 e = 0;
250 for (i = 1; i < argc; i++)
251 {
252 if (e)
253 {
254 if (argv[i])
255 {
256 argv[e++] = argv[i];
257 argv[i] = NULL((void*)0);
258 }
259 }
260 else if (!argv[i])
261 e = i;
262 }
263 if (e)
264 *argc_p = e;
265}
266
267static void
268print_blurb (FILE *bout,
269 gboolean print_help)
270{
271 if (!print_help)
272 {
273 g_fprintf (bout, "%s version ", PRG_NAME"cdk-pixbuf-csource-3.0");
274 g_fprintf (bout, "%s", CDK_PIXBUF_VERSION"2.45.1");
275 g_fprintf (bout, "\n");
276 g_fprintf (bout, "%s comes with ABSOLUTELY NO WARRANTY.\n", PRG_NAME"cdk-pixbuf-csource-3.0");
277 g_fprintf (bout, "You may redistribute copies of %s under the terms of\n", PRG_NAME"cdk-pixbuf-csource-3.0");
278 g_fprintf (bout, "the GNU Lesser General Public License which can be found in the\n");
279 g_fprintf (bout, "%s source package. Sources, examples and contact\n", PKG_NAME"cdk-pixbuf");
280 g_fprintf (bout, "information are available at %s\n", PKG_HTTP_HOME"https://github.com/cafe-desktop/ctk");
281 }
282 else
283 {
284 g_fprintf (bout, "Usage: %s [options] [image]\n", PRG_NAME"cdk-pixbuf-csource-3.0");
285 g_fprintf (bout, " %s [options] --build-list [[name image]...]\n", PRG_NAME"cdk-pixbuf-csource-3.0");
286 g_fprintf (bout, " --stream generate pixbuf data stream\n");
287 g_fprintf (bout, " --struct generate CdkPixdata structure\n");
288 g_fprintf (bout, " --macros generate image size/pixel macros\n");
289 g_fprintf (bout, " --rle use one byte run-length-encoding\n");
290 g_fprintf (bout, " --raw provide raw image data copy\n");
291 g_fprintf (bout, " --extern generate extern symbols\n");
292 g_fprintf (bout, " --static generate static symbols\n");
293 g_fprintf (bout, " --decoder provide rle decoder\n");
294 g_fprintf (bout, " --name=identifier C macro/variable name\n");
295 g_fprintf (bout, " --build-list parse (name, image) pairs\n");
296 g_fprintf (bout, " -h, --help show this help message\n");
297 g_fprintf (bout, " -v, --version print version informations\n");
298 g_fprintf (bout, " --g-fatal-warnings make warnings fatal (abort)\n");
299 }
300}
301