Bug Summary

File:ctk/ctkcssstylechange.c
Warning:line 72, 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 ctkcssstylechange.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-172241-43638-1 -x c ctkcssstylechange.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 2015 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 "ctkcssstylechangeprivate.h"
21
22#include "ctkcssstylepropertyprivate.h"
23
24void
25ctk_css_style_change_init (CtkCssStyleChange *change,
26 CtkCssStyle *old_style,
27 CtkCssStyle *new_style)
28{
29 change->old_style = g_object_ref (old_style)((__typeof__ (old_style)) (g_object_ref) (old_style));
30 change->new_style = g_object_ref (new_style)((__typeof__ (new_style)) (g_object_ref) (new_style));
31
32 change->n_compared = 0;
33
34 change->affects = 0;
35 change->changes = _ctk_bitmask_new ();
36
37 /* Make sure we don't do extra work if old and new are equal. */
38 if (old_style == new_style)
39 change->n_compared = CTK_CSS_PROPERTY_N_PROPERTIES;
40}
41
42void
43ctk_css_style_change_finish (CtkCssStyleChange *change)
44{
45 g_object_unref (change->old_style);
46 g_object_unref (change->new_style);
47 _ctk_bitmask_free (change->changes);
48}
49
50CtkCssStyle *
51ctk_css_style_change_get_old_style (CtkCssStyleChange *change)
52{
53 return change->old_style;
54}
55
56CtkCssStyle *
57ctk_css_style_change_get_new_style (CtkCssStyleChange *change)
58{
59 return change->new_style;
60}
61
62static gboolean
63ctk_css_style_compare_next_value (CtkCssStyleChange *change)
64{
65 if (change->n_compared == CTK_CSS_PROPERTY_N_PROPERTIES)
5
Assuming field 'n_compared' is not equal to CTK_CSS_PROPERTY_N_PROPERTIES
6
Taking false branch
66 return FALSE(0);
67
68 if (!_ctk_css_value_equal (ctk_css_style_get_value (change->old_style, change->n_compared),
7
Assuming the condition is true
8
Taking true branch
69 ctk_css_style_get_value (change->new_style, change->n_compared)))
70 {
71 change->affects |= _ctk_css_style_property_get_affects (_ctk_css_style_property_lookup_by_id (change->n_compared));
72 change->changes = _ctk_bitmask_set (change->changes, change->n_compared, TRUE(!(0)));
9
Using a fixed address is not portable because that address will probably not be valid in all environments or platforms
73 }
74
75 change->n_compared++;
76
77 return TRUE(!(0));
78}
79
80gboolean
81ctk_css_style_change_has_change (CtkCssStyleChange *change)
82{
83 do {
2
Loop condition is true. Execution continues on line 84
84 if (!_ctk_bitmask_is_empty (change->changes))
1
Taking false branch
3
Taking false branch
85 return TRUE(!(0));
86 } while (ctk_css_style_compare_next_value (change));
4
Calling 'ctk_css_style_compare_next_value'
87
88 return FALSE(0);
89}
90
91gboolean
92ctk_css_style_change_affects (CtkCssStyleChange *change,
93 CtkCssAffects affects)
94{
95 do {
96 if (change->affects & affects)
97 return TRUE(!(0));
98 } while (ctk_css_style_compare_next_value (change));
99
100 return FALSE(0);
101}
102
103gboolean
104ctk_css_style_change_changes_property (CtkCssStyleChange *change,
105 guint id)
106{
107 while (change->n_compared <= id)
108 ctk_css_style_compare_next_value (change);
109
110 return _ctk_bitmask_get (change->changes, id);
111}
112
113void
114ctk_css_style_change_print (CtkCssStyleChange *change,
115 GString *string)
116{
117 int i;
118 CtkCssStyle *old = ctk_css_style_change_get_old_style (change);
119 CtkCssStyle *new = ctk_css_style_change_get_new_style (change);
120
121 for (i = 0; i < CTK_CSS_PROPERTY_N_PROPERTIES; i ++)
122 {
123 if (ctk_css_style_change_changes_property (change, i))
124 {
125 CtkCssStyleProperty *prop;
126 CtkCssValue *value;
127 const char *name;
128
129 prop = _ctk_css_style_property_lookup_by_id (i);
130 name = _ctk_style_property_get_name (CTK_STYLE_PROPERTY (prop)((((CtkStyleProperty*) (void *) g_type_check_instance_cast ((
GTypeInstance*) (prop), ((_ctk_style_property_get_type ()))))
))
);
131
132 value = ctk_css_style_get_value (old, i);
133 _ctk_css_value_print (value, string);
134
135 g_string_append_printf (string, "%s: ", name);
136 _ctk_css_value_print (value, string);
137 g_string_append (string, "\n")(__builtin_constant_p ("\n") ? __extension__ ({ const char * const
__val = ("\n"); g_string_append_len_inline (string, __val, (
__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val)))
: (gssize) -1); }) : g_string_append_len_inline (string, "\n"
, (gssize) -1))
;
138
139 g_string_append_printf (string, "%s: ", name);
140 value = ctk_css_style_get_value (new, i);
141 _ctk_css_value_print (value, string);
142 g_string_append (string, "\n")(__builtin_constant_p ("\n") ? __extension__ ({ const char * const
__val = ("\n"); g_string_append_len_inline (string, __val, (
__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val)))
: (gssize) -1); }) : g_string_append_len_inline (string, "\n"
, (gssize) -1))
;
143 }
144 }
145
146}
147
148char *
149ctk_css_style_change_to_string (CtkCssStyleChange *change)
150{
151 GString *string = g_string_new ("");
152
153 ctk_css_style_change_print (change, string);
154
155 return g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
156}