Bug Summary

File:ctk/ctk-launch.c
Warning:line 161, column 11
This statement is never executed

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 ctk-launch.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 -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -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/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/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -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/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -internal-isystem /usr/lib/llvm-16/lib/clang/16/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 -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fgnuc-version=4.2.1 -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.core.SizeofPtr -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-09-19-171836-43636-1 -x c ctk-launch.c
1/* CTK - The GIMP Toolkit
2 *
3 * Copyright (C) 2012 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Tomas Bzatek <tbzatek@redhat.com>
19 */
20
21#include <config.h>
22
23#include <stdio.h>
24#ifdef HAVE_UNISTD_H1
25#include <unistd.h>
26#endif
27#include <locale.h>
28#include <errno(*__errno_location ()).h>
29
30#include <glib.h>
31#include <glib/gi18n.h>
32#include <gio/gio.h>
33#if defined(HAVE_GIO_UNIX1) && !defined(__APPLE__)
34#include <gio/gdesktopappinfo.h>
35#endif
36#include <ctk.h>
37
38static gboolean show_version;
39static gchar **args = NULL((void*)0);
40
41static GOptionEntry entries[] = {
42 { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Show program version")("Show program version"), NULL((void*)0) },
43 { G_OPTION_REMAINING"", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL((void*)0), NULL((void*)0) },
44 { NULL((void*)0)}
45};
46
47int
48main (int argc, char *argv[])
49{
50 GError *error = NULL((void*)0);
51 GOptionContext *context = NULL((void*)0);
52 gchar *summary;
53 gchar *app_name;
54#ifdef G_OS_UNIX
55 gchar *desktop_file_name;
56 gchar *bus_name = NULL((void*)0);
57#endif
58 GAppInfo *info = NULL((void*)0);
59 GAppLaunchContext *launch_context;
60 GList *l;
61 GFile *f;
62
63 setlocale (LC_ALL6, "");
64
65#ifdef ENABLE_NLS1
66 bindtextdomain (GETTEXT_PACKAGE"ctk30", CTK_LOCALEDIR"/usr/share/locale");
67 textdomain (GETTEXT_PACKAGE"ctk30");
68#ifdef HAVE_BIND_TEXTDOMAIN_CODESET1
69 bind_textdomain_codeset (GETTEXT_PACKAGE"ctk30", "UTF-8");
70#endif
71#endif
72
73 /* Translators: this message will appear immediately after the */
74 /* usage string - Usage: COMMAND [OPTION...] <THIS_MESSAGE> */
75 context =
76 g_option_context_new (_("APPLICATION [URI...] — launch an APPLICATION")gettext ("APPLICATION [URI...] — launch an APPLICATION"));
77
78 /* Translators: this message will appear after the usage string */
79 /* and before the list of options. */
80 summary = _("Launch an application (specified by its desktop file name),\n"gettext ("Launch an application (specified by its desktop file name),\n"
"optionally passing one or more URIs as arguments.")
81 "optionally passing one or more URIs as arguments.")gettext ("Launch an application (specified by its desktop file name),\n"
"optionally passing one or more URIs as arguments.")
;
82 g_option_context_set_summary (context, summary);
83 g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE"ctk30");
84 g_option_context_add_group (context, ctk_get_option_group (FALSE(0)));
85
86 g_option_context_parse (context, &argc, &argv, &error);
87
88 g_option_context_free (context);
89
90 if (error != NULL((void*)0))
91 {
92 g_printerr (_("Error parsing commandline options: %s\n")gettext ("Error parsing commandline options: %s\n"), error->message);
93 g_printerr ("\n");
94 g_printerr (_("Try \"%s --help\" for more information.")gettext ("Try \"%s --help\" for more information."), g_get_prgname ());
95 g_printerr ("\n");
96 g_error_free (error);
97 return 1;
98 }
99
100 if (show_version)
101 {
102 g_print ("%d.%d.%d\n",
103 ctk_get_major_version (),
104 ctk_get_minor_version (),
105 ctk_get_micro_version ());
106 return 0;
107 }
108
109 if (!args)
110 {
111 /* Translators: the %s is the program name. This error message */
112 /* means the user is calling ctk-launch without any argument. */
113 g_printerr (_("%s: missing application name")gettext ("%s: missing application name"), g_get_prgname ());
114 g_printerr ("\n");
115 g_printerr (_("Try \"%s --help\" for more information.")gettext ("Try \"%s --help\" for more information."), g_get_prgname ());
116 g_printerr ("\n");
117 return 1;
118 }
119
120
121 ctk_init (&argc, &argv);
122
123 app_name = *args;
124#if defined(HAVE_GIO_UNIX1) && !defined(__APPLE__)
125 bus_name = g_strdup (app_name)g_strdup_inline (app_name);
126 if (g_str_has_suffix (app_name, ".desktop")(__builtin_constant_p (".desktop")? __extension__ ({ const char
* const __str = (app_name); const char * const __suffix = (".desktop"
); gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (app_name, ".desktop"
) )
)
127 {
128 desktop_file_name = g_strdup (app_name)g_strdup_inline (app_name);
129 bus_name[strlen (bus_name) - strlen(".desktop")] = '\0';
130 }
131 else
132 {
133 desktop_file_name = g_strconcat (app_name, ".desktop", NULL((void*)0));
134 }
135
136 if (!g_dbus_is_name (bus_name))
137 g_clear_pointer (&bus_name, g_free)do { _Static_assert (sizeof *(&bus_name) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&bus_name
)) _pp = (&bus_name); __typeof__ (*(&bus_name)) _ptr =
*_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr); } while (
0)
;
138 info = G_APP_INFO (g_desktop_app_info_new (desktop_file_name))((((GAppInfo*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_desktop_app_info_new (desktop_file_name))), ((g_app_info_get_type
()))))))
;
139 g_free (desktop_file_name);
140#else
141 #ifndef _MSC_VER
142 #warning Please add support for creating AppInfo from id for your OS
143 #endif
144 g_printerr (_("Creating AppInfo from id not supported on non unix operating systems")gettext ("Creating AppInfo from id not supported on non unix operating systems"
)
);
145#endif
146 args++;
147
148 if (!info)
149 {
150 /* Translators: the first %s is the program name, the second one */
151 /* is the application name. */
152 g_printerr (_("%s: no such application %s")gettext ("%s: no such application %s"),
153 g_get_prgname (), app_name);
154 g_printerr ("\n");
155 return 2;
156 }
157
158 l = NULL((void*)0);
159 for (; *args; args++)
160 {
161 f = g_file_new_for_commandline_arg (*args);
This statement is never executed
162 l = g_list_append (l, f);
163 }
164
165 launch_context = (GAppLaunchContext*) cdk_display_get_app_launch_context (cdk_display_get_default ());
166 if (!g_app_info_launch (info, l, launch_context, &error))
167 {
168 /* Translators: the first %s is the program name, the second one */
169 /* is the error message. */
170 g_printerr (_("%s: error launching application: %s\n")gettext ("%s: error launching application: %s\n"),
171 g_get_prgname (), error->message);
172 return 3;
173 }
174 g_object_unref (info);
175 g_object_unref (launch_context);
176
177#ifdef G_OS_UNIX
178 if (bus_name != NULL((void*)0))
179 {
180 GDBusConnection *connection;
181 gchar *object_path, *p;
182
183 connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL((void*)0), NULL((void*)0));
184
185 object_path = g_strdup_printf ("/%s", bus_name);
186 for (p = object_path; *p != '\0'; p++)
187 if (*p == '.')
188 *p = '/';
189
190 if (connection)
191 g_dbus_connection_call_sync (connection,
192 bus_name,
193 object_path,
194 "org.freedesktop.DBus.Peer",
195 "Ping",
196 NULL((void*)0), NULL((void*)0),
197 G_DBUS_CALL_FLAGS_NONE, -1, NULL((void*)0), NULL((void*)0));
198 g_clear_pointer (&object_path, g_free)do { _Static_assert (sizeof *(&object_path) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&object_path
)) _pp = (&object_path); __typeof__ (*(&object_path))
_ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr); }
while (0)
;
199 g_clear_object (&connection)do { _Static_assert (sizeof *((&connection)) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ (((&connection
))) _pp = ((&connection)); __typeof__ (*((&connection
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
200 g_clear_pointer (&bus_name, g_free)do { _Static_assert (sizeof *(&bus_name) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&bus_name
)) _pp = (&bus_name); __typeof__ (*(&bus_name)) _ptr =
*_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr); } while (
0)
;
201 }
202#endif
203 g_list_free_full (l, g_object_unref);
204
205 return 0;
206}