Bug Summary

File:_build/../libbean/bean-utils.c
Warning:line 283, column 11
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 bean-utils.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=none -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 libbean/libean-2.0.so.0.100.0.p -I libbean -I ../libbean -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 HAVE_CONFIG_H -D G_LOG_DOMAIN="libbean" -D DATADIR="/usr/local/share" -D LIBDIR="/usr/local/lib/x86_64-linux-gnu" -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 -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-06-21-102334-9975-1 -x c ../libbean/bean-utils.c
1/*
2 * bean-utils.c
3 * This file is part of libbean
4 *
5 * Copyright (C) 2010 Steve Frécinaux
6 * Copyright (C) 2011-2017 Garrett Regier
7 *
8 * libbean is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * libbean is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#ifdef HAVE_CONFIG_H1
24#include <config.h>
25#endif
26
27#include <string.h>
28
29#include <gobject/gvaluecollector.h>
30
31#include "bean-utils.h"
32
33static const gchar *all_plugin_loaders[] = {
34 "c", "lua5.1", "python", "python3"
35};
36
37static const gchar *all_plugin_loader_modules[] = {
38 "cloader", "lua51loader", "pythonloader", "python3loader"
39};
40
41static const gint conflicting_plugin_loaders[BEAN_UTILS_N_LOADERS4][2] = {
42 { -1, -1 }, /* c => {} */
43 { -1, -1 }, /* lua5.1 => {} */
44 { 3, -1 }, /* python => { python3 } */
45 { 2, -1 } /* python3 => { python } */
46};
47
48G_STATIC_ASSERT (G_N_ELEMENTS (all_plugin_loaders) == BEAN_UTILS_N_LOADERS)_Static_assert ((sizeof (all_plugin_loaders) / sizeof ((all_plugin_loaders
)[0])) == 4, "Expression evaluates to false")
;
49G_STATIC_ASSERT (G_N_ELEMENTS (all_plugin_loader_modules) == BEAN_UTILS_N_LOADERS)_Static_assert ((sizeof (all_plugin_loader_modules) / sizeof (
(all_plugin_loader_modules)[0])) == 4, "Expression evaluates to false"
)
;
50G_STATIC_ASSERT (G_N_ELEMENTS (conflicting_plugin_loaders) == BEAN_UTILS_N_LOADERS)_Static_assert ((sizeof (conflicting_plugin_loaders) / sizeof
((conflicting_plugin_loaders)[0])) == 4, "Expression evaluates to false"
)
;
51
52static
53G_DEFINE_QUARK (bean-extension-base-class-and-interfaces-cache,GQuark exten_type_cache_quark (void) { static GQuark q; if (__builtin_expect
(__extension__ ({ int _g_boolean_var_24 = 0; if (q == 0) _g_boolean_var_24
= 1; _g_boolean_var_24; }), 0)) q = g_quark_from_static_string
("bean-extension-base-class-and-interfaces-cache"); return q
; }
54 exten_type_cache)GQuark exten_type_cache_quark (void) { static GQuark q; if (__builtin_expect
(__extension__ ({ int _g_boolean_var_24 = 0; if (q == 0) _g_boolean_var_24
= 1; _g_boolean_var_24; }), 0)) q = g_quark_from_static_string
("bean-extension-base-class-and-interfaces-cache"); return q
; }
55
56static void
57add_all_prerequisites (GType iface_type,
58 GType *base_type,
59 GPtrArray *ifaces)
60{
61 GType *prereq;
62 guint n_prereq;
63 guint i;
64
65 g_ptr_array_add (ifaces, g_type_default_interface_ref (iface_type));
66
67 prereq = g_type_interface_prerequisites (iface_type, &n_prereq);
68
69 for (i = 0; i < n_prereq; ++i)
70 {
71 if (G_TYPE_IS_INTERFACE (prereq[i])((g_type_fundamental (prereq[i])) == ((GType) ((2) << (
2))))
)
72 {
73 add_all_prerequisites (prereq[i], base_type, ifaces);
74 continue;
75 }
76
77 if (!G_TYPE_IS_OBJECT (prereq[i])((g_type_fundamental (prereq[i])) == ((GType) ((20) << (
2))))
)
78 continue;
79
80 if (*base_type != G_TYPE_INVALID((GType) ((0) << (2))))
81 {
82 /* We already have the descendant GType */
83 if (g_type_is_a (*base_type, prereq[i])((*base_type) == (prereq[i]) || (g_type_is_a) ((*base_type), (
prereq[i])))
)
84 continue;
85
86 /* Neither GType are descendant of the other, this is an
87 * error and GObject will not be able to create an object
88 */
89 g_warn_if_fail (g_type_is_a (prereq[i], *base_type))do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_25
= 0; if (((prereq[i]) == (*base_type) || (g_type_is_a) ((prereq
[i]), (*base_type)))) _g_boolean_var_25 = 1; _g_boolean_var_25
; }), 1)) ; else g_warn_message ("libbean", "../libbean/bean-utils.c"
, 89, ((const char*) (__func__)), "g_type_is_a (prereq[i], *base_type)"
); } while (0)
;
90 }
91
92 *base_type = prereq[i];
93 }
94
95 g_free (prereq);
96}
97
98static gpointer *
99find_base_class_and_interfaces (GType exten_type)
100{
101 GPtrArray *results;
102 GType base_type = G_TYPE_INVALID((GType) ((0) << (2)));
103 static GMutex cache_lock;
104 gpointer *data, *cached_data;
105
106 results = g_ptr_array_new ();
107
108 /* This is used for the GObjectClass of the base_type */
109 g_ptr_array_add (results, NULL((void*)0));
110
111 if (G_TYPE_IS_INTERFACE (exten_type)((g_type_fundamental (exten_type)) == ((GType) ((2) << (
2))))
)
112 {
113 add_all_prerequisites (exten_type, &base_type, results);
114 }
115 else
116 {
117 gint i;
118 GType *interfaces;
119
120 interfaces = g_type_interfaces (exten_type, NULL((void*)0));
121 for (i = 0; interfaces[i] != G_TYPE_INVALID((GType) ((0) << (2))); ++i)
122 add_all_prerequisites (interfaces[i], &base_type, results);
123
124 base_type = exten_type;
125
126 g_free (interfaces);
127 }
128
129 if (base_type != G_TYPE_INVALID((GType) ((0) << (2))))
130 g_ptr_array_index (results, 0)((results)->pdata)[0] = g_type_class_ref (base_type);
131
132 g_ptr_array_add (results, NULL((void*)0));
133 data = g_ptr_array_free (results, FALSE(0));
134
135 g_mutex_lock (&cache_lock);
136 cached_data = g_type_get_qdata (exten_type, exten_type_cache_quark ());
137
138 if (cached_data != NULL((void*)0))
139 {
140 g_free (data);
141 data = cached_data;
142 }
143 else
144 {
145 g_type_set_qdata (exten_type, exten_type_cache_quark (), data);
146 }
147
148 g_mutex_unlock (&cache_lock);
149 return data;
150}
151
152static inline gpointer *
153get_base_class_and_interfaces (GType exten_type,
154 GObjectClass **base_class)
155{
156 gpointer *data;
157
158 data = g_type_get_qdata (exten_type, exten_type_cache_quark ());
159 if (G_UNLIKELY (data == NULL)(__builtin_expect (__extension__ ({ int _g_boolean_var_26 = 0
; if (data == ((void*)0)) _g_boolean_var_26 = 1; _g_boolean_var_26
; }), 0))
)
160 data = find_base_class_and_interfaces (exten_type);
161
162 *base_class = data[0];
163 return &data[1];
164}
165
166static inline GParamSpec *
167find_param_spec_for_prerequisites (const gchar *name,
168 GObjectClass *base_class,
169 gpointer *ifaces)
170{
171 guint i;
172 GParamSpec *pspec = NULL((void*)0);
173
174 if (base_class != NULL((void*)0))
175 pspec = g_object_class_find_property (base_class, name);
176
177 for (i = 0; ifaces[i] != NULL((void*)0) && pspec == NULL((void*)0); ++i)
178 pspec = g_object_interface_find_property (ifaces[i], name);
179
180 return pspec;
181}
182
183gboolean
184bean_utils_properties_array_to_parameter_list (GType exten_type,
185 guint n_properties,
186 const gchar **prop_names,
187 const GValue *prop_values,
188 const gchar ***out_names,
189 GValue **out_values)
190{
191 guint i;
192 gpointer *ifaces;
193 GObjectClass *base_class;
194
195 g_return_val_if_fail (n_properties == 0 || prop_names != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_27
= 0; if (n_properties == 0 || prop_names != ((void*)0)) _g_boolean_var_27
= 1; _g_boolean_var_27; }), 1))) { } else { g_return_if_fail_warning
("libbean", ((const char*) (__func__)), "n_properties == 0 || prop_names != NULL"
); return ((0)); } } while (0)
;
196 g_return_val_if_fail (n_properties == 0 || prop_values != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_28
= 0; if (n_properties == 0 || prop_values != ((void*)0)) _g_boolean_var_28
= 1; _g_boolean_var_28; }), 1))) { } else { g_return_if_fail_warning
("libbean", ((const char*) (__func__)), "n_properties == 0 || prop_values != NULL"
); return ((0)); } } while (0)
;
197 g_return_val_if_fail (n_properties == 0 || out_names != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_29
= 0; if (n_properties == 0 || out_names != ((void*)0)) _g_boolean_var_29
= 1; _g_boolean_var_29; }), 1))) { } else { g_return_if_fail_warning
("libbean", ((const char*) (__func__)), "n_properties == 0 || out_names != NULL"
); return ((0)); } } while (0)
;
198 g_return_val_if_fail (n_properties == 0 || out_values != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_30
= 0; if (n_properties == 0 || out_values != ((void*)0)) _g_boolean_var_30
= 1; _g_boolean_var_30; }), 1))) { } else { g_return_if_fail_warning
("libbean", ((const char*) (__func__)), "n_properties == 0 || out_values != NULL"
); return ((0)); } } while (0)
;
199
200 ifaces = get_base_class_and_interfaces (exten_type, &base_class);
201
202 *out_names = g_new (const gchar *, n_properties)(const gchar * *) (__extension__ ({ gsize __n = (gsize) (n_properties
); gsize __s = sizeof (const gchar *); gpointer __p; if (__s ==
1) __p = g_malloc (__n); else if (__builtin_constant_p (__n)
&& (__s == 0 || __n <= (9223372036854775807L *2UL
+1UL) / __s)) __p = g_malloc (__n * __s); else __p = g_malloc_n
(__n, __s); __p; }))
;
203 *out_values = g_new0 (GValue, n_properties)(GValue *) (__extension__ ({ gsize __n = (gsize) (n_properties
); gsize __s = sizeof (GValue); gpointer __p; if (__s == 1) __p
= g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
204
205 for (i = 0; i < n_properties; i++)
206 {
207 GParamSpec *pspec;
208 if (prop_names[i] == NULL((void*)0))
209 {
210 g_warning ("The property name at index %u should not be NULL.", i);
211 goto error;
212 }
213 if (!G_IS_VALUE (&prop_values[i])(((g_type_check_value ((GValue*) (&prop_values[i]))))))
214 {
215 g_warning ("The property value at index %u should be an initialized GValue.", i);
216 goto error;
217 }
218 pspec = find_param_spec_for_prerequisites (prop_names[i], base_class,
219 ifaces);
220 if (!pspec)
221 {
222 g_warning ("%s: type '%s' has no property named '%s'",
223 G_STRFUNC((const char*) (__func__)), g_type_name (exten_type), prop_names[i]);
224 goto error;
225 }
226
227 (*out_names)[i] = prop_names[i];
228
229 g_value_init (&(*out_values)[i],
230 G_VALUE_TYPE (&prop_values[i])(((GValue*) (&prop_values[i]))->g_type));
231 g_value_copy (&prop_values[i], &(*out_values)[i]);
232 }
233 return TRUE(!(0));
234
235error:
236 for (guint j = 0; j < i; j++)
237 g_value_unset (&(*out_values)[j]);
238 g_free (*out_names);
239 g_free (*out_values);
240 return FALSE(0);
241}
242
243gboolean
244bean_utils_valist_to_parameter_list (GType exten_type,
245 const gchar *first_property,
246 va_list args,
247 const gchar ***out_names,
248 GValue **out_values,
249 guint *n_properties)
250{
251 gpointer *ifaces;
252 GObjectClass *base_class;
253 const gchar *name;
254 guint n_allocated_params;
255
256 g_return_val_if_fail (G_TYPE_IS_INTERFACE (exten_type) ||do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_31
= 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2)
<< (2)))) || ((g_type_fundamental (exten_type)) == ((GType
) ((20) << (2))))) _g_boolean_var_31 = 1; _g_boolean_var_31
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_OBJECT (exten_type)"
); return ((0)); } } while (0)
257 G_TYPE_IS_OBJECT (exten_type), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_31
= 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2)
<< (2)))) || ((g_type_fundamental (exten_type)) == ((GType
) ((20) << (2))))) _g_boolean_var_31 = 1; _g_boolean_var_31
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_OBJECT (exten_type)"
); return ((0)); } } while (0)
;
258
259 ifaces = get_base_class_and_interfaces (exten_type, &base_class);
260
261 *n_properties = 0;
262 n_allocated_params = 16;
263 *out_names = g_new (const gchar *, n_allocated_params)(const gchar * *) (__extension__ ({ gsize __n = (gsize) (n_allocated_params
); gsize __s = sizeof (const gchar *); gpointer __p; if (__s ==
1) __p = g_malloc (__n); else if (__builtin_constant_p (__n)
&& (__s == 0 || __n <= (9223372036854775807L *2UL
+1UL) / __s)) __p = g_malloc (__n * __s); else __p = g_malloc_n
(__n, __s); __p; }))
;
264 *out_values = g_new0 (GValue, n_allocated_params)(GValue *) (__extension__ ({ gsize __n = (gsize) (n_allocated_params
); gsize __s = sizeof (GValue); gpointer __p; if (__s == 1) __p
= g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
265
266 name = first_property;
267 while (name)
268 {
269 gchar *error_msg = NULL((void*)0);
270 GParamSpec *pspec;
271
272 pspec = find_param_spec_for_prerequisites (name, base_class, ifaces);
273
274 if (!pspec)
275 {
276 g_warning ("%s: type '%s' has no property named '%s'",
277 G_STRFUNC((const char*) (__func__)), g_type_name (exten_type), name);
278 goto error;
279 }
280
281 if (*n_properties >= n_allocated_params)
282 {
283 n_allocated_params += 16;
This statement is never executed
284 *out_names = g_renew (const gchar *, *out_names, n_allocated_params)(const gchar * *) (__extension__ ({ gsize __n = (gsize) (n_allocated_params
); gsize __s = sizeof (const gchar *); gpointer __p = (gpointer
) (*out_names); if (__s == 1) __p = g_realloc (__p, __n); else
if (__builtin_constant_p (__n) && (__s == 0 || __n <=
(9223372036854775807L *2UL+1UL) / __s)) __p = g_realloc (__p
, __n * __s); else __p = g_realloc_n (__p, __n, __s); __p; })
)
;
285 *out_values = g_renew (GValue, *out_values, n_allocated_params)(GValue *) (__extension__ ({ gsize __n = (gsize) (n_allocated_params
); gsize __s = sizeof (GValue); gpointer __p = (gpointer) (*out_values
); if (__s == 1) __p = g_realloc (__p, __n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_realloc (__p, __n * __s); else __p
= g_realloc_n (__p, __n, __s); __p; }))
;
286 memset (*out_values + (n_allocated_params - 16),
287 0, sizeof (GValue) * 16);
288 }
289
290 (*out_names)[*n_properties] = name;
291 G_VALUE_COLLECT_INIT (&(*out_values)[*n_properties], pspec->value_type,do { GTypeValueTable *g_vci_vtab; do { GValue *g_vci_val = (&
(*out_values)[*n_properties]); guint g_vci_flags = (0); const
gchar *g_vci_collect_format; GTypeCValue g_vci_cvalues[(8)] =
{ { 0, }, }; guint g_vci_n_values = 0; g_vci_vtab = g_type_value_table_peek
(pspec->value_type); g_vci_collect_format = g_vci_vtab->
collect_format; g_vci_val->g_type = pspec->value_type; while
(*g_vci_collect_format) { GTypeCValue *g_vci_cvalue = g_vci_cvalues
+ g_vci_n_values++; switch (*g_vci_collect_format++) { case G_VALUE_COLLECT_INT
: g_vci_cvalue->v_int = __builtin_va_arg((args), gint); break
; case G_VALUE_COLLECT_LONG: g_vci_cvalue->v_long = __builtin_va_arg
((args), glong); break; case G_VALUE_COLLECT_INT64: g_vci_cvalue
->v_int64 = __builtin_va_arg((args), gint64); break; case G_VALUE_COLLECT_DOUBLE
: g_vci_cvalue->v_double = __builtin_va_arg((args), gdouble
); break; case G_VALUE_COLLECT_POINTER: g_vci_cvalue->v_pointer
= __builtin_va_arg((args), gpointer); break; default: do { g_assertion_message_expr
("libbean", "../libbean/bean-utils.c", 292, ((const char*) (
__func__)), ((void*)0)); } while (0); } } *(&error_msg) =
g_vci_vtab->collect_value (g_vci_val, g_vci_n_values, g_vci_cvalues
, g_vci_flags); } while (0); } while (0)
292 args, 0, &error_msg)do { GTypeValueTable *g_vci_vtab; do { GValue *g_vci_val = (&
(*out_values)[*n_properties]); guint g_vci_flags = (0); const
gchar *g_vci_collect_format; GTypeCValue g_vci_cvalues[(8)] =
{ { 0, }, }; guint g_vci_n_values = 0; g_vci_vtab = g_type_value_table_peek
(pspec->value_type); g_vci_collect_format = g_vci_vtab->
collect_format; g_vci_val->g_type = pspec->value_type; while
(*g_vci_collect_format) { GTypeCValue *g_vci_cvalue = g_vci_cvalues
+ g_vci_n_values++; switch (*g_vci_collect_format++) { case G_VALUE_COLLECT_INT
: g_vci_cvalue->v_int = __builtin_va_arg((args), gint); break
; case G_VALUE_COLLECT_LONG: g_vci_cvalue->v_long = __builtin_va_arg
((args), glong); break; case G_VALUE_COLLECT_INT64: g_vci_cvalue
->v_int64 = __builtin_va_arg((args), gint64); break; case G_VALUE_COLLECT_DOUBLE
: g_vci_cvalue->v_double = __builtin_va_arg((args), gdouble
); break; case G_VALUE_COLLECT_POINTER: g_vci_cvalue->v_pointer
= __builtin_va_arg((args), gpointer); break; default: do { g_assertion_message_expr
("libbean", "../libbean/bean-utils.c", 292, ((const char*) (
__func__)), ((void*)0)); } while (0); } } *(&error_msg) =
g_vci_vtab->collect_value (g_vci_val, g_vci_n_values, g_vci_cvalues
, g_vci_flags); } while (0); } while (0)
;
293
294 (*n_properties)++;
295
296 if (error_msg)
297 {
298 g_warning ("%s: %s", G_STRFUNC((const char*) (__func__)), error_msg);
299 g_free (error_msg);
300 goto error;
301 }
302
303 name = va_arg (args, gchar*)__builtin_va_arg(args, gchar*);
304 }
305
306 return TRUE(!(0));
307
308error:
309
310 for (; *n_properties > 0; --(*n_properties))
311 g_value_unset (&(*out_values)[*n_properties]);
312
313 g_free (*out_names);
314 g_free (*out_values);
315
316 return FALSE(0);
317}
318
319gint
320bean_utils_get_loader_id (const gchar *loader)
321{
322 gint i;
323 gsize len;
324 gchar lowercase[32];
325
326 len = strlen (loader);
327
328 /* No loader has a name that long */
329 if (len >= G_N_ELEMENTS (lowercase)(sizeof (lowercase) / sizeof ((lowercase)[0])))
330 return -1;
331
332 for (i = 0; i < len; ++i)
333 lowercase[i] = g_ascii_tolower (loader[i]);
334
335 lowercase[len] = '\0';
336
337 for (i = 0; i < G_N_ELEMENTS (all_plugin_loaders)(sizeof (all_plugin_loaders) / sizeof ((all_plugin_loaders)[0
]))
; ++i)
338 {
339 if (g_strcmp0 (lowercase, all_plugin_loaders[i]) == 0)
340 return i;
341 }
342
343 return -1;
344}
345
346const gchar *
347bean_utils_get_loader_from_id (gint loader_id)
348{
349 g_return_val_if_fail (loader_id >= 0, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_32
= 0; if (loader_id >= 0) _g_boolean_var_32 = 1; _g_boolean_var_32
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "loader_id >= 0"); return (((void
*)0)); } } while (0)
;
350 g_return_val_if_fail (loader_id < BEAN_UTILS_N_LOADERS, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_33
= 0; if (loader_id < 4) _g_boolean_var_33 = 1; _g_boolean_var_33
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "loader_id < BEAN_UTILS_N_LOADERS"
); return (((void*)0)); } } while (0)
;
351
352 return all_plugin_loaders[loader_id];
353}
354
355const gchar *
356bean_utils_get_loader_module_from_id (gint loader_id)
357{
358 g_return_val_if_fail (loader_id >= 0, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_34
= 0; if (loader_id >= 0) _g_boolean_var_34 = 1; _g_boolean_var_34
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "loader_id >= 0"); return (((void
*)0)); } } while (0)
;
359 g_return_val_if_fail (loader_id < BEAN_UTILS_N_LOADERS, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_35
= 0; if (loader_id < 4) _g_boolean_var_35 = 1; _g_boolean_var_35
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "loader_id < BEAN_UTILS_N_LOADERS"
); return (((void*)0)); } } while (0)
;
360
361 return all_plugin_loader_modules[loader_id];
362}
363
364const gint *
365bean_utils_get_conflicting_loaders_from_id (gint loader_id)
366{
367 g_return_val_if_fail (loader_id >= 0, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_36
= 0; if (loader_id >= 0) _g_boolean_var_36 = 1; _g_boolean_var_36
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "loader_id >= 0"); return (((void
*)0)); } } while (0)
;
368 g_return_val_if_fail (loader_id < BEAN_UTILS_N_LOADERS, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_37
= 0; if (loader_id < 4) _g_boolean_var_37 = 1; _g_boolean_var_37
; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((
const char*) (__func__)), "loader_id < BEAN_UTILS_N_LOADERS"
); return (((void*)0)); } } while (0)
;
369
370 return conflicting_plugin_loaders[loader_id];
371}
372