Bug Summary

File:wm-tester/test-resizing.c
Warning:line 139, column 3
Value stored to 'mask' 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 test-resizing.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/src/wm-tester -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -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 -D _REENTRANT -D _REENTRANT -I /usr/include/startup-notification-1.0 -I /usr/include/libgtop-2.0 -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/src/wm-tester -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-14-225616-31151-1 -x c test-resizing.c
1#include <X11/Xlib.h>
2#include <X11/Xutil.h>
3#include <stdlib.h>
4#include <glib.h>
5
6static void
7calc_rects (XRectangle *rects, int width, int height)
8{
9 int w = (width - 21) / 3;
10 int h = (height - 21) / 3;
11 int i;
12
13 i = 0;
14 while (i < 9)
15 {
16 rects[i].width = w;
17 rects[i].height = h;
18 ++i;
19 }
20
21 /* NW */
22 rects[0].x = 0;
23 rects[0].y = 0;
24
25 /* N */
26 rects[1].x = width / 2 - w / 2;
27 rects[1].y = 0;
28
29 /* NE */
30 rects[2].x = width - w;
31 rects[2].y = 0;
32
33 /* E */
34 rects[3].x = width - w;
35 rects[3].y = height / 2 - h / 2;
36
37 /* SE */
38 rects[4].x = width - w;
39 rects[4].y = height - h;
40
41 /* S */
42 rects[5].x = width / 2 - w / 2;
43 rects[5].y = height - h;
44
45 /* SW */
46 rects[6].x = 0;
47 rects[6].y = height - h;
48
49 /* W */
50 rects[7].x = 0;
51 rects[7].y = height / 2 - h / 2;
52
53 /* Center */
54 rects[8].x = width / 2 - w / 2;
55 rects[8].y = height / 2 - h / 2;
56}
57
58static Boolint
59all_events (Display *display,
60 XEvent *event,
61 XPointer arg)
62{
63 return True1;
64}
65
66static void
67get_size (Display *d, Drawable draw,
68 int *xp, int *yp, int *widthp, int *heightp)
69{
70 int x, y;
71 unsigned int width=0, height=0, border=0, depth=0;
72 Window root;
73
74 XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);
75
76 if (xp)
77 *xp = x;
78 if (yp)
79 *yp = y;
80 if (widthp)
81 *widthp = width;
82 if (heightp)
83 *heightp = height;
84}
85
86int
87main (int argc, char **argv)
88{
89 Display *d;
90 Window w, cw;
91 XSizeHints hints;
92 int screen;
93 XEvent ev;
94 int x, y, width, height;
95 Pixmap pix;
96 GC gc;
97 XGCValues gc_vals;
98 XSetWindowAttributes set_attrs;
99 XWindowChanges changes;
100 XRectangle rects[9];
101 gboolean redraw_pending;
102 unsigned int mask;
103
104 d = XOpenDisplay (NULL((void*)0));
105
106 screen = DefaultScreen (d)(((_XPrivDisplay)(d))->default_screen);
107
108 /* Print some debug spew to show how StaticGravity works */
109 w = XCreateSimpleWindow (d, RootWindow (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->root),
110 0, 0, 100, 100, 0,
111 WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
,
112 WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
);
113 cw = XCreateSimpleWindow (d, w,
114 0, 0, 100, 100, 0,
115 WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
,
116 WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
);
117 set_attrs.win_gravity = StaticGravity10;
118
119 XChangeWindowAttributes (d, cw,
120 CWWinGravity(1L<<5),
121 &set_attrs);
122
123 get_size (d, w, &x, &y, &width, &height);
124
125 g_print ("Parent is %d,%d %d x %d before configuring parent\n",
126 x, y, width, height);
127
128 get_size (d, cw, &x, &y, &width, &height);
129
130 g_print ("Child is %d,%d %d x %d before configuring parent\n",
131 x, y, width, height);
132
133 changes.x = 10;
134 changes.y = 10;
135 changes.width = 110;
136 changes.height = 110;
137 /* last mask wins */
138 mask = CWX(1<<0) | CWY(1<<1);
139 mask = CWWidth(1<<2) | CWHeight(1<<3);
Value stored to 'mask' is never read
140 mask = CWX(1<<0) | CWY(1<<1) | CWWidth(1<<2) | CWHeight(1<<3);
141
142 XConfigureWindow (d, w, mask, &changes);
143 XSync (d, False0);
144
145 get_size (d, w, &x, &y, &width, &height);
146
147 g_print ("Parent is %d,%d %d x %d after configuring parent\n",
148 x, y, width, height);
149
150 get_size (d, cw, &x, &y, &width, &height);
151
152 g_print ("Child is %d,%d %d x %d after configuring parent\n",
153 x, y, width, height);
154
155 XDestroyWindow (d, w);
156
157 /* The window that gets displayed */
158
159 x = 20;
160 y = 20;
161 width = 100;
162 height = 100;
163
164 calc_rects (rects, width, height);
165
166 w = XCreateSimpleWindow (d, RootWindow (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->root),
167 x, y, width, height, 0,
168 WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
,
169 WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
);
170
171 set_attrs.bit_gravity = StaticGravity10;
172
173 XChangeWindowAttributes (d, w,
174 CWBitGravity(1L<<4),
175 &set_attrs);
176
177 XSelectInput (d, w,
178 ButtonPressMask(1L<<2) | ExposureMask(1L<<15) | StructureNotifyMask(1L<<17));
179
180 hints.flags = PMinSize(1L << 4);
181
182 hints.min_width = 100;
183 hints.min_height = 100;
184
185 XSetWMNormalHints (d, w, &hints);
186 XMapWindow (d, w);
187
188 redraw_pending = FALSE(0);
189 while (1)
190 {
191 XNextEvent (d, &ev);
192
193 switch (ev.xany.type)
194 {
195 case ButtonPress4:
196 if (ev.xbutton.button == 3)
197 {
198 g_print ("Exiting on button 3 press\n");
199 exit (0);
200 }
201 break;
202
203 case ConfigureNotify22:
204 x = ev.xconfigure.x;
205 y = ev.xconfigure.y;
206 width = ev.xconfigure.width;
207 height = ev.xconfigure.height;
208
209 redraw_pending = TRUE(!(0));
210 break;
211
212 case Expose12:
213 redraw_pending = TRUE(!(0));
214 break;
215
216 default:
217 break;
218 }
219
220 /* Primitive event compression */
221 if (XCheckIfEvent (d, &ev, all_events, NULL((void*)0)))
222 {
223 XPutBackEvent (d, &ev);
224 }
225 else if (redraw_pending)
226 {
227 calc_rects (rects, width, height);
228
229 pix = XCreatePixmap (d, w, width, height,
230 DefaultDepth (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->root_depth
)
);
231
232 gc_vals.foreground = WhitePixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->white_pixel
)
;
233
234 gc = XCreateGC (d, pix, GCForeground(1L<<2), &gc_vals);
235
236 XFillRectangle (d, pix, gc, 0, 0, width, height);
237
238 /* Draw rectangles at each gravity point */
239 gc_vals.foreground = BlackPixel (d, screen)((&((_XPrivDisplay)(d))->screens[screen])->black_pixel
)
;
240 XChangeGC (d, gc, GCForeground(1L<<2), &gc_vals);
241
242 XFillRectangles (d, pix, gc, rects, G_N_ELEMENTS (rects)(sizeof (rects) / sizeof ((rects)[0])));
243
244 XCopyArea (d, pix, w, gc, 0, 0, width, height, 0, 0);
245
246 XFreePixmap (d, pix);
247 XFreeGC (d, gc);
248
249 redraw_pending = FALSE(0);
250 }
251 }
252
253 /* This program has an infinite loop above so a return statement would
254 * just cause compiler warnings.
255 */
256}
257