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 panel-glib.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/cafe-panel/libpanel-util -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -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/gdk-pixbuf-2.0 -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/ctk-3.0 -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/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cafe-menus -I /usr/include/dconf -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 -I . -I . -I ../../cafe-panel/libpanel-util -D DATADIR="/usr/share" -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/cafe-panel/libpanel-util -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-07-20-021807-56096-1 -x c panel-glib.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | #include <string.h> |
31 | |
32 | #include <glib.h> |
33 | |
34 | #include "panel-glib.h" |
35 | |
36 | typedef char * (*LookupInDir) (const char *basename, const char *dir); |
37 | |
38 | static char * |
39 | _lookup_in_dir (const char *basename, |
40 | const char *dir) |
41 | { |
42 | char *path; |
43 | |
44 | path = g_build_filename (dir, basename, NULL); |
45 | if (!g_file_test (path, G_FILE_TEST_EXISTS)) { |
46 | g_free (path); |
47 | return NULL; |
48 | } |
49 | |
50 | return path; |
51 | } |
52 | |
53 | static char * |
54 | _lookup_in_applications_subdir (const char *basename, |
55 | const char *dir) |
56 | { |
57 | char *path; |
58 | |
59 | path = g_build_filename (dir, "applications", basename, NULL); |
60 | if (!g_file_test (path, G_FILE_TEST_EXISTS)) { |
61 | g_free (path); |
62 | return NULL; |
63 | } |
64 | |
65 | return path; |
66 | } |
67 | |
68 | static char * |
69 | _panel_g_lookup_in_data_dirs_internal (const char *basename, |
70 | LookupInDir lookup) |
71 | { |
72 | const char * const *system_data_dirs; |
73 | const char *user_data_dir; |
74 | char *retval; |
75 | int i; |
76 | |
77 | user_data_dir = g_get_user_data_dir (); |
78 | system_data_dirs = g_get_system_data_dirs (); |
79 | |
80 | if ((retval = lookup (basename, user_data_dir))) |
81 | return retval; |
82 | |
83 | for (i = 0; system_data_dirs[i]; i++) |
84 | if ((retval = lookup (basename, system_data_dirs[i]))) |
85 | return retval; |
86 | |
87 | return NULL; |
88 | } |
89 | |
90 | char * |
91 | panel_g_lookup_in_data_dirs (const char *basename) |
92 | { |
93 | return _panel_g_lookup_in_data_dirs_internal (basename, |
94 | _lookup_in_dir); |
95 | } |
96 | |
97 | char * |
98 | panel_g_lookup_in_applications_dirs (const char *basename) |
99 | { |
100 | return _panel_g_lookup_in_data_dirs_internal (basename, |
101 | _lookup_in_applications_subdir); |
102 | } |
103 | |
104 | |
105 | |
106 | static char * |
107 | _unicode_get_utf8 (const char *text, gunichar *out) |
108 | { |
109 | *out = g_utf8_get_char (text); |
| 17 | | Value assigned to 'unival', which participates in a condition later | |
|
110 | return (*out == (gunichar)-1) ? NULL : g_utf8_next_char (text); |
| 10 | | Assuming the condition is false | |
|
| |
| 12 | | Returning pointer, which participates in a condition later | |
|
| 18 | | Assuming the condition is false | |
|
| |
| 20 | | Returning pointer, which participates in a condition later | |
|
111 | } |
112 | |
113 | |
114 | |
115 | const char * |
116 | panel_g_utf8_strstrcase (const char *haystack, const char *needle) |
117 | { |
118 | gunichar *nuni; |
119 | gunichar unival; |
120 | gint nlen; |
121 | const char *o, *p; |
122 | |
123 | if (haystack == NULL) return NULL; |
| 1 | Assuming 'haystack' is not equal to NULL | |
|
| |
124 | if (needle == NULL) return NULL; |
| 3 | | Assuming 'needle' is not equal to NULL | |
|
| |
125 | if (strlen (needle) == 0) return haystack; |
| 5 | | Assuming the condition is false | |
|
| |
126 | if (strlen (haystack) == 0) return NULL; |
| 7 | | Assuming the condition is false | |
|
| |
127 | |
128 | nuni = g_alloca (sizeof (gunichar) * strlen (needle)); |
129 | |
130 | nlen = 0; |
131 | for (p = _unicode_get_utf8 (needle, &unival); |
| 9 | | Calling '_unicode_get_utf8' | |
|
| 13 | | Returning from '_unicode_get_utf8' | |
|
| 14 | | Loop condition is false. Execution continues on line 137 | |
|
132 | p && unival; |
133 | p = _unicode_get_utf8 (p, &unival)) { |
134 | nuni[nlen++] = g_unichar_tolower (unival); |
135 | } |
136 | |
137 | if (!p) return NULL; |
| |
138 | |
139 | o = haystack; |
140 | for (p = _unicode_get_utf8 (o, &unival); |
| 16 | | Calling '_unicode_get_utf8' | |
|
| 21 | | Returning from '_unicode_get_utf8' | |
|
| 22 | | Loop condition is true. Entering loop body | |
|
141 | p && unival; |
142 | p = _unicode_get_utf8 (p, &unival)) { |
143 | gint sc; |
144 | sc = g_unichar_tolower (unival); |
145 | |
146 | if (sc == nuni[0]) { |
| 23 | | The right operand of '==' is a garbage value |
|
147 | const char *q = p; |
148 | gint npos = 1; |
149 | while (npos < nlen) { |
150 | q = _unicode_get_utf8 (q, &unival); |
151 | if (!q || !unival) return NULL; |
152 | sc = g_unichar_tolower (unival); |
153 | if (sc != nuni[npos]) break; |
154 | npos++; |
155 | } |
156 | if (npos == nlen) { |
157 | return o; |
158 | } |
159 | } |
160 | o = p; |
161 | } |
162 | |
163 | return NULL; |
164 | } |