Bug Summary

File:ctk/ctkcsslookup.c
Warning:line 40, column 23
Using a fixed address is not portable because that address will probably not be valid in all environments or platforms

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 ctkcsslookup.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 -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 -D PIC -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 -fvisibility=hidden -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-170505-43637-1 -x c ctkcsslookup.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 2011 Benjamin Otte <otte@gnome.org>
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
18#include "config.h"
19
20#include "ctkcsslookupprivate.h"
21
22#include "ctkcssstylepropertyprivate.h"
23#include "ctkcsstypesprivate.h"
24#include "ctkprivatetypebuiltins.h"
25#include "ctkprivate.h"
26
27CtkCssLookup *
28_ctk_css_lookup_new (const CtkBitmask *relevant)
29{
30 CtkCssLookup *lookup;
31
32 lookup = g_malloc0 (sizeof (CtkCssLookup));
33
34 if (relevant)
1
Assuming 'relevant' is null
2
Taking false branch
35 {
36 lookup->missing = _ctk_bitmask_copy (relevant);
37 }
38 else
39 {
40 lookup->missing = _ctk_bitmask_new ();
3
Using a fixed address is not portable because that address will probably not be valid in all environments or platforms
41 lookup->missing = _ctk_bitmask_invert_range (lookup->missing, 0, CTK_CSS_PROPERTY_N_PROPERTIES);
42 }
43
44 return lookup;
45}
46
47void
48_ctk_css_lookup_free (CtkCssLookup *lookup)
49{
50 ctk_internal_return_if_fail (lookup != NULL)do { if ((lookup != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "lookup != ((void*)0)");
return; } } while (0)
;
51
52 _ctk_bitmask_free (lookup->missing);
53 g_free (lookup);
54}
55
56gboolean
57_ctk_css_lookup_is_missing (const CtkCssLookup *lookup,
58 guint id)
59{
60 ctk_internal_return_val_if_fail (lookup != NULL, FALSE)do { if ((lookup != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "lookup != ((void*)0)");
return ((0)); } } while (0)
;
61
62 return _ctk_bitmask_get (lookup->missing, id);
63}
64
65/**
66 * _ctk_css_lookup_set:
67 * @lookup: the lookup
68 * @id: id of the property to set, see _ctk_style_property_get_id()
69 * @section: (allow-none): The @section the value was defined in or %NULL
70 * @value: the “cascading value” to use
71 *
72 * Sets the @value for a given @id. No value may have been set for @id
73 * before. See _ctk_css_lookup_is_missing(). This function is used to
74 * set the “winning declaration” of a lookup. Note that for performance
75 * reasons @value and @section are not copied. It is your responsibility
76 * to ensure they are kept alive until _ctk_css_lookup_free() is called.
77 **/
78void
79_ctk_css_lookup_set (CtkCssLookup *lookup,
80 guint id,
81 CtkCssSection *section,
82 CtkCssValue *value)
83{
84 ctk_internal_return_if_fail (lookup != NULL)do { if ((lookup != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "lookup != ((void*)0)");
return; } } while (0)
;
85 ctk_internal_return_if_fail (_ctk_bitmask_get (lookup->missing, id))do { if ((_ctk_bitmask_get (lookup->missing, id))) { } else
{ g_return_if_fail_warning ("Ctk", ((const char*) (__func__)
), "_ctk_bitmask_get (lookup->missing, id)"); return; } } while
(0)
;
86 ctk_internal_return_if_fail (value != NULL)do { if ((value != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "value != ((void*)0)"); return
; } } while (0)
;
87
88 lookup->missing = _ctk_bitmask_set (lookup->missing, id, FALSE(0));
89 lookup->values[id].value = value;
90 lookup->values[id].section = section;
91}
92
93/**
94 * _ctk_css_lookup_resolve:
95 * @lookup: the lookup
96 * @context: the context the values are resolved for
97 * @values: a new #CtkCssStyle to be filled with the new properties
98 *
99 * Resolves the current lookup into a styleproperties object. This is done
100 * by converting from the “winning declaration” to the “computed value”.
101 *
102 * XXX: This bypasses the notion of “specified value”. If this ever becomes
103 * an issue, go fix it.
104 **/
105void
106_ctk_css_lookup_resolve (CtkCssLookup *lookup,
107 CtkStyleProviderPrivate *provider,
108 CtkCssStaticStyle *style,
109 CtkCssStyle *parent_style)
110{
111 guint i;
112
113 ctk_internal_return_if_fail (lookup != NULL)do { if ((lookup != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "lookup != ((void*)0)");
return; } } while (0)
;
114 ctk_internal_return_if_fail (CTK_IS_STYLE_PROVIDER_PRIVATE (provider))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((provider)); GType __t = ((_ctk_style_provider_private_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((provider)); GType __t = ((_ctk_style_provider_private_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))"
); return; } } while (0)
;
115 ctk_internal_return_if_fail (CTK_IS_CSS_STATIC_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) (style); GType __t = ((ctk_css_static_style_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
)))))) { } else { g_return_if_fail_warning ("Ctk", ((const char
*) (__func__)), "(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (style); GType __t = ((ctk_css_static_style_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))"
); return; } } while (0)
;
116 ctk_internal_return_if_fail (parent_style == NULL || CTK_IS_CSS_STYLE (parent_style))do { if ((parent_style == ((void*)0) || (((__extension__ ({ GTypeInstance
*__inst = (GTypeInstance*) (parent_style); GType __t = ((ctk_css_style_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "parent_style == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (parent_style); GType __t = ((ctk_css_style_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))"
); return; } } while (0)
;
117
118 for (i = 0; i < CTK_CSS_PROPERTY_N_PROPERTIES; i++)
119 {
120 if (lookup->values[i].value ||
121 _ctk_bitmask_get (lookup->missing, i))
122 ctk_css_static_style_compute_value (style,
123 provider,
124 parent_style,
125 i,
126 lookup->values[i].value,
127 lookup->values[i].section);
128 /* else not a relevant property */
129 }
130}