Bug Summary

File:libcafe-desktop/cafe-gsettings.c
Warning:line 112, column 7
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 cafe-gsettings.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 -fhalf-no-semantic-interposition -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/libcafe-desktop -fcoverage-compilation-dir=/rootdir/libcafe-desktop -resource-dir /usr/lib/llvm-21/lib/clang/21 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glycin-2 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -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/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D G_LOG_DOMAIN="CafeDesktop" -D CAFELOCALEDIR="/usr/share/locale" -D PNP_IDS="/usr/share/libcafe-desktop/pnp.ids" -D ISO_CODES_PREFIX="/usr" -D PIC -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 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -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-05-02-100446-15377-1 -x c cafe-gsettings.c
1/*
2 * cafe-gsettings.c: helper API for GSettings
3 *
4 * Copyright (C) 2013 Stefano Karapetsas
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors:
22 * Stefano Karapetsas <stefano@karapetsas.com>
23 */
24
25#include "cafe-gsettings.h"
26
27/**
28 * cafe_gsettings_schema_exists:
29 * @schema: schema to check.
30 *
31 * Check if a given schema is installed in GSettings.
32 *
33 * Return value: TRUE if schema exists, FALSE if not.
34 *
35 * Since: 1.7.1
36 */
37gboolean
38cafe_gsettings_schema_exists (const gchar* schema)
39{
40 GSettingsSchemaSource *schema_source;
41 GSettingsSchema *schema_schema;
42 gboolean schema_exists;
43
44 schema_source = g_settings_schema_source_get_default();
45 schema_schema = g_settings_schema_source_lookup (schema_source, schema, FALSE(0));
46 schema_exists = (schema_schema != NULL((void*)0));
47 if (schema_schema)
48 g_settings_schema_unref (schema_schema);
49
50 return schema_exists;
51}
52
53/* (copied from gnome-panel)
54 * Adapted from is_valid_keyname() in glib (gio/glib-compile-schemas.c)
55 * Differences:
56 * - gettext support removed (we don't need translations here)
57 * - remove support for allow_any_name
58 */
59gboolean
60cafe_gsettings_is_valid_keyname (const gchar *key,
61 GError **error)
62{
63 gint i;
64
65 if (key[0] == '\0')
66 {
67 g_set_error_literal (error, G_MARKUP_ERRORg_markup_error_quark (), G_MARKUP_ERROR_INVALID_CONTENT,
68 "empty names are not permitted");
69 return FALSE(0);
70 }
71
72 if (!g_ascii_islower (key[0])((g_ascii_table[(guchar) (key[0])] & G_ASCII_LOWER) != 0))
73 {
74 g_set_error (error, G_MARKUP_ERRORg_markup_error_quark (), G_MARKUP_ERROR_INVALID_CONTENT,
75 "invalid name '%s': names must begin "
76 "with a lowercase letter", key);
77 return FALSE(0);
78 }
79
80 for (i = 1; key[i]; i++)
81 {
82 if (key[i] != '-' &&
83 !g_ascii_islower (key[i])((g_ascii_table[(guchar) (key[i])] & G_ASCII_LOWER) != 0) &&
84 !g_ascii_isdigit (key[i])((g_ascii_table[(guchar) (key[i])] & G_ASCII_DIGIT) != 0))
85 {
86 g_set_error (error, G_MARKUP_ERRORg_markup_error_quark (), G_MARKUP_ERROR_INVALID_CONTENT,
87 "invalid name '%s': invalid character '%c'; "
88 "only lowercase letters, numbers and dash ('-') "
89 "are permitted.", key, key[i]);
90 return FALSE(0);
91 }
92
93 if (key[i] == '-' && key[i + 1] == '-')
94 {
95 g_set_error (error, G_MARKUP_ERRORg_markup_error_quark (), G_MARKUP_ERROR_INVALID_CONTENT,
96 "invalid name '%s': two successive dashes ('--') "
97 "are not permitted.", key);
98 return FALSE(0);
99 }
100 }
101
102 if (key[i - 1] == '-')
103 {
104 g_set_error (error, G_MARKUP_ERRORg_markup_error_quark (), G_MARKUP_ERROR_INVALID_CONTENT,
105 "invalid name '%s': the last character may not be a "
106 "dash ('-').", key);
107 return FALSE(0);
108 }
109
110 if (i > 32)
111 {
112 g_set_error (error, G_MARKUP_ERRORg_markup_error_quark (), G_MARKUP_ERROR_INVALID_CONTENT,
This statement is never executed
113 "invalid name '%s': maximum length is 32", key);
114 return FALSE(0);
115 }
116
117 return TRUE(!(0));
118}
119
120gboolean
121cafe_gsettings_append_strv (GSettings *settings,
122 const gchar *key,
123 const gchar *value)
124{
125 gchar **old;
126 gchar **new;
127 gint size;
128 gboolean retval;
129
130 old = g_settings_get_strv (settings, key);
131
132 for (size = 0; old[size] != NULL((void*)0); size++);
133
134 size += 1; /* appended value */
135 size += 1; /* NULL */
136
137 new = g_realloc_n (old, size, sizeof (gchar *));
138
139 new[size - 2] = g_strdup (value)g_strdup_inline (value);
140 new[size - 1] = NULL((void*)0);
141
142 retval = g_settings_set_strv (settings, key,
143 (const gchar **) new);
144
145 g_strfreev (new);
146
147 return retval;
148}
149
150gboolean
151cafe_gsettings_remove_all_from_strv (GSettings *settings,
152 const gchar *key,
153 const gchar *value)
154{
155 GArray *array;
156 gchar **old;
157 gint i;
158 gboolean retval;
159
160 old = g_settings_get_strv (settings, key);
161 array = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
162
163 for (i = 0; old[i] != NULL((void*)0); i++) {
164 if (g_strcmp0 (old[i], value) != 0)
165 array = g_array_append_val (array, old[i])g_array_append_vals (array, &(old[i]), 1);
166 }
167
168 retval = g_settings_set_strv (settings, key,
169 (const gchar **) array->data);
170
171 g_strfreev (old);
172 g_array_free (array, TRUE(!(0)));
173
174 return retval;
175}
176
177GSList*
178cafe_gsettings_strv_to_gslist (const gchar *const *array)
179{
180 GSList *list = NULL((void*)0);
181 gint i;
182 if (array != NULL((void*)0)) {
183 for (i = 0; array[i]; i++) {
184 list = g_slist_append (list, g_strdup (array[i])g_strdup_inline (array[i]));
185 }
186 }
187 return list;
188}