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 xsettings-common.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/plugins/xsettings -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../../cafe-settings-daemon -D CAFE_SETTINGS_LOCALEDIR="/usr/share/locale" -I /usr/include/ctk-3.0 -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/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/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -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/freetype2 -I /usr/include/libpng16 -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/13/../../../../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/plugins/xsettings -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-04-16-113529-65591-1 -x c xsettings-common.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | #include "string.h" |
24 | #include "stdlib.h" |
25 | |
26 | #include <X11/Xlib.h> |
27 | #include <X11/Xmd.h> /* For CARD32 */ |
28 | |
29 | #include "xsettings-common.h" |
30 | |
31 | XSettingsSetting * |
32 | xsettings_setting_copy (XSettingsSetting *setting) |
33 | { |
34 | XSettingsSetting *result; |
35 | size_t str_len; |
36 | |
37 | result = malloc (sizeof *result); |
38 | if (!result) |
| 6 | | Assuming 'result' is non-null | |
|
| |
39 | return NULL; |
40 | |
41 | str_len = strlen (setting->name); |
42 | result->name = malloc (str_len + 1); |
43 | if (!result->name) |
| 8 | | Assuming field 'name' is non-null | |
|
| |
44 | goto err; |
45 | |
46 | memcpy (result->name, setting->name, str_len + 1); |
47 | |
48 | result->type = setting->type; |
49 | |
50 | switch (setting->type) |
| 10 | | Control jumps to 'case XSETTINGS_TYPE_COLOR:' at line 55 | |
|
51 | { |
52 | case XSETTINGS_TYPE_INT: |
53 | result->data.v_int = setting->data.v_int; |
54 | break; |
55 | case XSETTINGS_TYPE_COLOR: |
56 | result->data.v_color = setting->data.v_color; |
57 | break; |
| 11 | | Execution continues on line 68 | |
|
58 | case XSETTINGS_TYPE_STRING: |
59 | str_len = strlen (setting->data.v_string); |
60 | result->data.v_string = malloc (str_len + 1); |
61 | if (!result->data.v_string) |
62 | goto err; |
63 | |
64 | memcpy (result->data.v_string, setting->data.v_string, str_len + 1); |
65 | break; |
66 | } |
67 | |
68 | result->last_change_serial = setting->last_change_serial; |
69 | |
70 | return result; |
| 12 | | Returning pointer (loaded from 'result'), which participates in a condition later | |
|
71 | |
72 | err: |
73 | if (result->name) |
74 | free (result->name); |
75 | free (result); |
76 | |
77 | return NULL; |
78 | } |
79 | |
80 | XSettingsList * |
81 | xsettings_list_copy (XSettingsList *list) |
82 | { |
83 | XSettingsList *new = NULL; |
84 | XSettingsList *old_iter = list; |
85 | XSettingsList *new_iter = NULL; |
86 | |
87 | while (old_iter) |
| 1 | Loop condition is true. Entering loop body | |
|
| 16 | | Loop condition is true. Entering loop body | |
|
88 | { |
89 | XSettingsList *new_node; |
90 | |
91 | new_node = malloc (sizeof *new_node); |
| 2 | | Uninitialized value stored to field 'next' | |
|
92 | if (!new_node) |
| 3 | | Assuming 'new_node' is non-null | |
|
| |
| 17 | | Assuming 'new_node' is null | |
|
| |
93 | goto error; |
| 19 | | Control jumps to line 115 | |
|
94 | |
95 | new_node->setting = xsettings_setting_copy (old_iter->setting); |
| 5 | | Calling 'xsettings_setting_copy' | |
|
| 13 | | Returning from 'xsettings_setting_copy' | |
|
96 | if (!new_node->setting) |
| |
97 | { |
98 | free (new_node); |
99 | goto error; |
100 | } |
101 | |
102 | if (new_iter) |
| |
103 | new_iter->next = new_node; |
104 | else |
105 | new = new_node; |
106 | |
107 | new_iter = new_node; |
108 | |
109 | old_iter = old_iter->next; |
110 | } |
111 | |
112 | return new; |
113 | |
114 | error: |
115 | xsettings_list_free (new); |
| 20 | | Calling 'xsettings_list_free' | |
|
116 | return NULL; |
117 | } |
118 | |
119 | int |
120 | xsettings_setting_equal (XSettingsSetting *setting_a, |
121 | XSettingsSetting *setting_b) |
122 | { |
123 | if (setting_a->type != setting_b->type) |
124 | return 0; |
125 | |
126 | if (strcmp (setting_a->name, setting_b->name) != 0) |
127 | return 0; |
128 | |
129 | switch (setting_a->type) |
130 | { |
131 | case XSETTINGS_TYPE_INT: |
132 | return setting_a->data.v_int == setting_b->data.v_int; |
133 | case XSETTINGS_TYPE_COLOR: |
134 | return (setting_a->data.v_color.red == setting_b->data.v_color.red && |
135 | setting_a->data.v_color.green == setting_b->data.v_color.green && |
136 | setting_a->data.v_color.blue == setting_b->data.v_color.blue && |
137 | setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); |
138 | case XSETTINGS_TYPE_STRING: |
139 | return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0; |
140 | } |
141 | |
142 | return 0; |
143 | } |
144 | |
145 | void |
146 | xsettings_setting_free (XSettingsSetting *setting) |
147 | { |
148 | if (setting->type == XSETTINGS_TYPE_STRING) |
149 | free (setting->data.v_string); |
150 | |
151 | if (setting->name) |
152 | free (setting->name); |
153 | |
154 | free (setting); |
155 | } |
156 | |
157 | void |
158 | xsettings_list_free (XSettingsList *list) |
159 | { |
160 | while (list) |
| 21 | | Loop condition is true. Entering loop body | |
|
161 | { |
162 | XSettingsList *next = list->next; |
| 22 | | Assigned value is garbage or undefined |
|
163 | |
164 | xsettings_setting_free (list->setting); |
165 | free (list); |
166 | |
167 | list = next; |
168 | } |
169 | } |
170 | |
171 | XSettingsResult |
172 | xsettings_list_insert (XSettingsList **list, |
173 | XSettingsSetting *setting) |
174 | { |
175 | XSettingsList *node; |
176 | XSettingsList *iter; |
177 | XSettingsList *last = NULL; |
178 | |
179 | node = malloc (sizeof *node); |
180 | if (!node) |
181 | return XSETTINGS_NO_MEM; |
182 | node->setting = setting; |
183 | |
184 | iter = *list; |
185 | while (iter) |
186 | { |
187 | int cmp = strcmp (setting->name, iter->setting->name); |
188 | |
189 | if (cmp < 0) |
190 | break; |
191 | else if (cmp == 0) |
192 | { |
193 | free (node); |
194 | return XSETTINGS_DUPLICATE_ENTRY; |
195 | } |
196 | |
197 | last = iter; |
198 | iter = iter->next; |
199 | } |
200 | |
201 | if (last) |
202 | last->next = node; |
203 | else |
204 | *list = node; |
205 | |
206 | node->next = iter; |
207 | |
208 | return XSETTINGS_SUCCESS; |
209 | } |
210 | |
211 | XSettingsResult |
212 | xsettings_list_delete (XSettingsList **list, |
213 | const char *name) |
214 | { |
215 | XSettingsList *iter; |
216 | XSettingsList *last = NULL; |
217 | |
218 | iter = *list; |
219 | while (iter) |
220 | { |
221 | if (strcmp (name, iter->setting->name) == 0) |
222 | { |
223 | if (last) |
224 | last->next = iter->next; |
225 | else |
226 | *list = iter->next; |
227 | |
228 | xsettings_setting_free (iter->setting); |
229 | free (iter); |
230 | |
231 | return XSETTINGS_SUCCESS; |
232 | } |
233 | |
234 | last = iter; |
235 | iter = iter->next; |
236 | } |
237 | |
238 | return XSETTINGS_FAILED; |
239 | } |
240 | |
241 | XSettingsSetting * |
242 | xsettings_list_lookup (XSettingsList *list, |
243 | const char *name) |
244 | { |
245 | XSettingsList *iter; |
246 | |
247 | iter = list; |
248 | while (iter) |
249 | { |
250 | if (strcmp (name, iter->setting->name) == 0) |
251 | return iter->setting; |
252 | |
253 | iter = iter->next; |
254 | } |
255 | |
256 | return NULL; |
257 | } |
258 | |
259 | char |
260 | xsettings_byte_order (void) |
261 | { |
262 | CARD32 myint = 0x01020304; |
263 | return (*(char *)&myint == 1) ? MSBFirst : LSBFirst; |
264 | } |