Bug Summary

File:cafe-panel/libpanel-util/panel-xdg.c
Warning:line 121, column 4
Value stored to 'current' is never read

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 panel-xdg.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/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/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-02-11-192722-55971-1 -x c panel-xdg.c
1/*
2 * panel-xdg.c: miscellaneous XDG-related functions.
3 *
4 * Copyright (C) 2010 Novell, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors:
22 * Vincent Untz <vuntz@gnome.org>
23 */
24
25#include <string.h>
26
27#include <glib.h>
28#include <gio/gio.h>
29#include <ctk/ctk.h>
30
31#include "panel-xdg.h"
32
33#define DEFAULT_THEME_NAME"hicolor" "hicolor"
34
35/*
36 * Originally based on code from panel-util.c. This part of the code was:
37 * Copyright (C) 2006 Vincent Untz <vuntz@gnome.org>
38 */
39
40char *
41panel_xdg_icon_remove_extension (const char *icon)
42{
43 char *icon_no_extension;
44 char *p;
45
46 icon_no_extension = g_strdup (icon)g_strdup_inline (icon);
47 p = strrchr (icon_no_extension, '.');
48 if (p &&
49 (strcmp (p, ".png") == 0 ||
50 strcmp (p, ".xpm") == 0 ||
51 strcmp (p, ".svg") == 0)) {
52 *p = 0;
53 }
54
55 return icon_no_extension;
56}
57
58/*
59 * End of code coming from panel-util.c
60 */
61
62char *
63panel_xdg_icon_name_from_icon_path (const char *path,
64 CdkScreen *screen)
65{
66 CtkIconTheme *theme;
67 CtkSettings *settings;
68 char *theme_name;
69 char *icon;
70 char **paths;
71 int n_paths;
72 int i;
73 GFile *file;
74
75 /* we look if the icon comes from the current icon theme */
76 if (!screen)
77 screen = cdk_screen_get_default ();
78
79 settings = ctk_settings_get_for_screen (screen);
80 g_object_get (settings,
81 "ctk-icon-theme-name", &theme_name,
82 NULL((void*)0));
83
84 theme = ctk_icon_theme_get_for_screen (screen);
85 ctk_icon_theme_get_search_path (theme, &paths, &n_paths);
86
87 file = g_file_new_for_path (path);
88 icon = NULL((void*)0);
89
90 for (i = 0; i < n_paths; i++) {
91 GFile *parent;
92 char *basename;
93
94 parent = g_file_new_for_path (paths[i]);
95
96 if (!g_file_has_prefix (file, parent)) {
97 g_object_unref (parent);
98 continue;
99 }
100
101 basename = g_file_get_basename (parent);
102
103 if (g_strcmp0 (basename, "pixmaps") == 0) {
104 char *relative_path;
105
106 relative_path = g_file_get_relative_path (parent, file);
107
108 /* if the icon is in a subdir of pixmaps, then it's not
109 * a real icon name */
110 if (!strchr (relative_path, G_DIR_SEPARATOR'/'))
111 icon = panel_xdg_icon_remove_extension (relative_path);
112
113 g_free (relative_path);
114 } else {
115 /* real icon theme; but is it the current one? */
116 GFile *theme_dir;
117 gboolean current;
118
119 theme_dir = g_file_get_child (parent, theme_name);
120
121 current = FALSE(0);
Value stored to 'current' is never read
122 if (g_file_has_prefix (file, theme_dir)) {
123 /* it's the current one */
124 current = TRUE(!(0));
125 } else {
126 /* it's the default one */
127 g_object_unref (theme_dir);
128 theme_dir = g_file_get_child (parent, DEFAULT_THEME_NAME"hicolor");
129 current = g_file_has_prefix (file, theme_dir);
130 }
131
132 g_object_unref (theme_dir);
133
134 if (current) {
135 char *buffer;
136
137 buffer = g_file_get_basename (file);
138 icon = panel_xdg_icon_remove_extension (buffer);
139 g_free (buffer);
140 }
141 }
142
143 g_free (basename);
144 g_object_unref (parent);
145
146 break;
147 }
148
149 g_object_unref (file);
150 g_free (theme_name);
151
152 return icon;
153}