Bug Summary

File:testsuite/cdk/rectangle.c
Warning:line 38, column 3
Value stored to 'res' 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 rectangle.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/testsuite/cdk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -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/sysprof-6 -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 ../.. -I ../../cdk -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../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/testsuite/cdk -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-09-19-172619-43637-1 -x c rectangle.c
1#include <cdk/cdk.h>
2
3static void
4test_rectangle_equal (void)
5{
6 CdkRectangle a = { 0, 0, 1, 1 };
7 CdkRectangle b = { 1, 1, 2, 2 };
8 CdkRectangle c = { 0, 0, 2, 2 };
9 CdkRectangle d = { 0, 0, 1, 1 };
10 CdkRectangle e = { 0, 0, 0, 0 };
11 CdkRectangle f = { 1, 1, 0, 0 };
12
13 g_assert_true (!cdk_rectangle_equal (&a, &b))do { if (!cdk_rectangle_equal (&a, &b)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 13, ((const char*) (__func__))
, "'" "!cdk_rectangle_equal (&a, &b)" "' should be TRUE"
); } while (0)
;
14 g_assert_true (!cdk_rectangle_equal (&a, &c))do { if (!cdk_rectangle_equal (&a, &c)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 14, ((const char*) (__func__))
, "'" "!cdk_rectangle_equal (&a, &c)" "' should be TRUE"
); } while (0)
;
15 g_assert_true (!cdk_rectangle_equal (&b, &c))do { if (!cdk_rectangle_equal (&b, &c)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 15, ((const char*) (__func__))
, "'" "!cdk_rectangle_equal (&b, &c)" "' should be TRUE"
); } while (0)
;
16 g_assert_true ( cdk_rectangle_equal (&a, &d))do { if (cdk_rectangle_equal (&a, &d)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 16, ((const char*) (__func__))
, "'" "cdk_rectangle_equal (&a, &d)" "' should be TRUE"
); } while (0)
;
17 g_assert_true (!cdk_rectangle_equal (&e, &f))do { if (!cdk_rectangle_equal (&e, &f)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 17, ((const char*) (__func__))
, "'" "!cdk_rectangle_equal (&e, &f)" "' should be TRUE"
); } while (0)
;
18}
19
20static void
21test_rectangle_intersect (void)
22{
23 CdkRectangle a = { 0, 0, 10, 10 };
24 CdkRectangle b = { 5, 5, 10, 10 };
25 CdkRectangle c = { 0, 0, 0, 0 };
26 CdkRectangle d = { 5, 5, 5, 5 };
27 CdkRectangle e = { 0, 0, 10, 10 };
28 CdkRectangle f = { 20, 20, 10, 10 };
29 CdkRectangle g = { 0, 0, 0, 0 };
30 CdkRectangle h = { 10, 10, 0, 0 };
31 gboolean res;
32
33 res = cdk_rectangle_intersect (&a, &b, &c);
34 g_assert_true (res)do { if (res) ; else g_assertion_message (((gchar*) 0), "rectangle.c"
, 34, ((const char*) (__func__)), "'" "res" "' should be TRUE"
); } while (0)
;
35 g_assert_true (cdk_rectangle_equal (&c, &d))do { if (cdk_rectangle_equal (&c, &d)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 35, ((const char*) (__func__))
, "'" "cdk_rectangle_equal (&c, &d)" "' should be TRUE"
); } while (0)
;
36
37 /* non-empty, non-intersecting rectangles */
38 res = cdk_rectangle_intersect (&e, &f, &f);
Value stored to 'res' is never read
39 g_assert_cmpint (f.width, ==, 0)do { gint64 __n1 = (f.width), __n2 = (0); if (__n1 == __n2) ;
else g_assertion_message_cmpint (((gchar*) 0), "rectangle.c"
, 39, ((const char*) (__func__)), "f.width" " " "==" " " "0",
(guint64)__n1, "==", (guint64)__n2, 'i'); } while (0)
;
40 g_assert_cmpint (f.height, ==, 0)do { gint64 __n1 = (f.height), __n2 = (0); if (__n1 == __n2) ;
else g_assertion_message_cmpint (((gchar*) 0), "rectangle.c"
, 40, ((const char*) (__func__)), "f.height" " " "==" " " "0"
, (guint64)__n1, "==", (guint64)__n2, 'i'); } while (0)
;
41
42 /* empty rectangles */
43 res = cdk_rectangle_intersect (&g, &h, NULL((void*)0));
44 g_assert_true (!res)do { if (!res) ; else g_assertion_message (((gchar*) 0), "rectangle.c"
, 44, ((const char*) (__func__)), "'" "!res" "' should be TRUE"
); } while (0)
;
45}
46
47static void
48test_rectangle_union (void)
49{
50 CdkRectangle a = { 0, 0, 10, 10 };
51 CdkRectangle b = { 5, 5, 10, 10 };
52 CdkRectangle c = { 0, 0, 0, 0 };
53 CdkRectangle d = { 0, 0, 15, 15 };
54 CdkRectangle e = { 0, 0, 0, 0 };
55 CdkRectangle f = { 50, 50, 0, 0 };
56 CdkRectangle g = { 0, 0, 50, 50 };
57
58 cdk_rectangle_union (&a, &b, &c);
59 g_assert_true (cdk_rectangle_equal (&c, &d))do { if (cdk_rectangle_equal (&c, &d)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 59, ((const char*) (__func__))
, "'" "cdk_rectangle_equal (&c, &d)" "' should be TRUE"
); } while (0)
;
60
61 cdk_rectangle_union (&a, &b, &b);
62 g_assert_true (cdk_rectangle_equal (&b, &d))do { if (cdk_rectangle_equal (&b, &d)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 62, ((const char*) (__func__))
, "'" "cdk_rectangle_equal (&b, &d)" "' should be TRUE"
); } while (0)
;
63
64 cdk_rectangle_union (&e, &f, &f);
65 g_assert_true (cdk_rectangle_equal (&f, &g))do { if (cdk_rectangle_equal (&f, &g)) ; else g_assertion_message
(((gchar*) 0), "rectangle.c", 65, ((const char*) (__func__))
, "'" "cdk_rectangle_equal (&f, &g)" "' should be TRUE"
); } while (0)
;
66}
67
68int
69main (int argc, char *argv[])
70{
71 g_test_init (&argc, &argv, NULL((void*)0));
72
73 cdk_init (NULL((void*)0), NULL((void*)0));
74
75 g_test_bug_base ("http://bugzilla.gnome.org/");
76
77 g_test_add_func ("/rectangle/equal", test_rectangle_equal);
78 g_test_add_func ("/rectangle/intersect", test_rectangle_intersect);
79 g_test_add_func ("/rectangle/union", test_rectangle_union);
80
81 return g_test_run ();
82}