Bug Summary

File:capplets/keyboard/cafe-keyboard-properties-xkbpv.c
Warning:line 93, column 10
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'

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 cafe-keyboard-properties-xkbpv.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 -pic-is-pie -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/capplets/keyboard -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -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/libxml2 -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I ../../ -D G_LOG_DOMAIN="keyboard-properties" -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/polkit-1 -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 /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -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/libxml2 -D CAFECC_DATA_DIR="/usr/share/cafe-control-center" -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/capplets/keyboard -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-091552-112930-1 -x c cafe-keyboard-properties-xkbpv.c
1/* -*- mode: c; style: linux -*- */
2
3/* cafe-keyboard-properties-xkbpv.c
4 * Copyright (C) 2003-2007 Sergey V. Udaltsov
5 *
6 * Written by: Sergey V. Udaltsov <svu@gnome.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23
24#ifdef HAVE_CONFIG_H1
25# include <config.h>
26#endif
27
28#include <libcafekbd/cafekbd-keyboard-drawing.h>
29
30#include "capplet-util.h"
31#include "cafe-keyboard-properties-xkb.h"
32
33#ifdef HAVE_X11_EXTENSIONS_XKB_H1
34#include "X11/XKBlib.h"
35/**
36 * BAD STYLE: Taken from xklavier_private_xkb.h
37 * Any ideas on architectural improvements are WELCOME
38 */
39extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
40 const XklConfigRec * data,
41 XkbComponentNamesPtr
42 component_names);
43
44extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
45 XkbComponentNamesPtr
46 component_names);
47
48/* */
49#endif
50
51static CafekbdKeyboardDrawingGroupLevel groupsLevels[] =
52 { {0, 1}, {0, 3}, {0, 0}, {0, 2} };
53static CafekbdKeyboardDrawingGroupLevel *pGroupsLevels[] = {
54 groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3
55};
56
57CtkWidget *
58xkb_layout_preview_create_widget (CtkBuilder * chooserDialog)
59{
60 CtkWidget *kbdraw = cafekbd_keyboard_drawing_new ();
61
62 cafekbd_keyboard_drawing_set_groups_levels (CAFEKBD_KEYBOARD_DRAWING((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type
())))))
63 (kbdraw)((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type
())))))
, pGroupsLevels);
64 return kbdraw;
65}
66
67void
68xkb_layout_preview_update (CtkBuilder * chooser_dialog)
69{
70#ifdef HAVE_X11_EXTENSIONS_XKB_H1
71 CtkWidget *chooser = CWID ("xkb_layout_chooser")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((ctk_widget_get_type ()))))))
;
72 CtkWidget *kbdraw =
73 CTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((chooser)), (((GType) ((20) << (2))
)))))), "kbdraw"))), ((ctk_widget_get_type ()))))))
;
74 gchar *id = xkb_layout_chooser_get_selected_id (chooser_dialog);
75 xkb_layout_preview_set_drawing_layout (kbdraw, id);
76 g_free (id);
77#endif
78}
79
80void
81xkb_layout_preview_set_drawing_layout (CtkWidget * kbdraw,
82 const gchar * id)
83{
84#ifdef HAVE_X11_EXTENSIONS_XKB_H1
85 if (kbdraw != NULL((void*)0)) {
86 if (id != NULL((void*)0)) {
87 XklConfigRec *data;
88 char **p, *layout, *variant;
89 XkbComponentNamesRec component_names;
90
91 data = xkl_config_rec_new ();
92 if (xkl_config_rec_get_from_server (data, engine)) {
93 if ((p = data->layouts) != NULL((void*)0))
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'
94 g_strfreev (data->layouts);
95
96 if ((p = data->variants) != NULL((void*)0))
97 g_strfreev (data->variants);
98
99 data->layouts = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *)));
100 data->variants = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *)));
101 if (cafekbd_keyboard_config_split_items
102 (id, &layout, &variant)
103 && variant != NULL((void*)0)) {
104 data->layouts[0] =
105 (layout ==
106 NULL((void*)0)) ? NULL((void*)0) :
107 g_strdup (layout)g_strdup_inline (layout);
108 data->variants[0] =
109 (variant ==
110 NULL((void*)0)) ? NULL((void*)0) :
111 g_strdup (variant)g_strdup_inline (variant);
112 } else {
113 data->layouts[0] =
114 (id ==
115 NULL((void*)0)) ? NULL((void*)0) : g_strdup (id)g_strdup_inline (id);
116 data->variants[0] = NULL((void*)0);
117 }
118
119 if (xkl_xkb_config_native_prepare
120 (engine, data, &component_names)) {
121 cafekbd_keyboard_drawing_set_keyboard
122 (CAFEKBD_KEYBOARD_DRAWING((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type
())))))
123 (kbdraw)((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type
())))))
, &component_names);
124
125 xkl_xkb_config_native_cleanup
126 (engine, &component_names);
127 }
128 }
129 g_object_unref (G_OBJECT (data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (((GType) ((20) << (2))))))))
);
130 } else
131 cafekbd_keyboard_drawing_set_keyboard
132 (CAFEKBD_KEYBOARD_DRAWING (kbdraw)((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type
())))))
, NULL((void*)0));
133
134 }
135#endif
136}