File: | test/region-test.c |
Location: | line 80, column 5 |
Description: | Value stored to 'b' is never read |
1 | #include <assert.h> |
2 | #include <stdlib.h> |
3 | #include <stdio.h> |
4 | #include "utils.h" |
5 | |
6 | int |
7 | main () |
8 | { |
9 | pixman_region32_t r1; |
10 | pixman_region32_t r2; |
11 | pixman_region32_t r3; |
12 | pixman_box32_t boxes[] = { |
13 | { 10, 10, 20, 20 }, |
14 | { 30, 30, 30, 40 }, |
15 | { 50, 45, 60, 44 }, |
16 | }; |
17 | pixman_box32_t boxes2[] = { |
18 | { 2, 6, 7, 6 }, |
19 | { 4, 1, 6, 7 }, |
20 | }; |
21 | pixman_box32_t boxes3[] = { |
22 | { 2, 6, 7, 6 }, |
23 | { 4, 1, 6, 1 }, |
24 | }; |
25 | int i, j; |
26 | pixman_box32_t *b; |
27 | pixman_image_t *image, *fill; |
28 | pixman_color_t white = { |
29 | 0xffff, |
30 | 0xffff, |
31 | 0xffff, |
32 | 0xffff |
33 | }; |
34 | |
35 | /* This used to go into an infinite loop before pixman-region.c |
36 | * was fixed to not use explict "short" variables |
37 | */ |
38 | pixman_region32_init_rect (&r1, 0, 0, 20, 64000); |
39 | pixman_region32_init_rect (&r2, 0, 0, 20, 64000); |
40 | pixman_region32_init_rect (&r3, 0, 0, 20, 64000); |
41 | |
42 | pixman_region32_subtract (&r1, &r2, &r3); |
43 | |
44 | |
45 | /* This would produce a region containing an empty |
46 | * rectangle in it. Such regions are considered malformed, |
47 | * but using an empty rectangle for initialization should |
48 | * work. |
49 | */ |
50 | pixman_region32_init_rects (&r1, boxes, 3); |
51 | |
52 | b = pixman_region32_rectangles (&r1, &i); |
53 | |
54 | assert (i == 1)((i == 1) ? (void) (0) : __assert_fail ("i == 1", "region-test.c" , 54, __PRETTY_FUNCTION__)); |
55 | |
56 | while (i--) |
57 | { |
58 | assert (b[i].x1 < b[i].x2)((b[i].x1 < b[i].x2) ? (void) (0) : __assert_fail ("b[i].x1 < b[i].x2" , "region-test.c", 58, __PRETTY_FUNCTION__)); |
59 | assert (b[i].y1 < b[i].y2)((b[i].y1 < b[i].y2) ? (void) (0) : __assert_fail ("b[i].y1 < b[i].y2" , "region-test.c", 59, __PRETTY_FUNCTION__)); |
60 | } |
61 | |
62 | /* This would produce a rectangle containing the bounding box |
63 | * of the two rectangles. The correct result is to eliminate |
64 | * the broken rectangle. |
65 | */ |
66 | pixman_region32_init_rects (&r1, boxes2, 2); |
67 | |
68 | b = pixman_region32_rectangles (&r1, &i); |
69 | |
70 | assert (i == 1)((i == 1) ? (void) (0) : __assert_fail ("i == 1", "region-test.c" , 70, __PRETTY_FUNCTION__)); |
71 | |
72 | assert (b[0].x1 == 4)((b[0].x1 == 4) ? (void) (0) : __assert_fail ("b[0].x1 == 4", "region-test.c", 72, __PRETTY_FUNCTION__)); |
73 | assert (b[0].y1 == 1)((b[0].y1 == 1) ? (void) (0) : __assert_fail ("b[0].y1 == 1", "region-test.c", 73, __PRETTY_FUNCTION__)); |
74 | assert (b[0].x2 == 6)((b[0].x2 == 6) ? (void) (0) : __assert_fail ("b[0].x2 == 6", "region-test.c", 74, __PRETTY_FUNCTION__)); |
75 | assert (b[0].y2 == 7)((b[0].y2 == 7) ? (void) (0) : __assert_fail ("b[0].y2 == 7", "region-test.c", 75, __PRETTY_FUNCTION__)); |
76 | |
77 | /* This should produce an empty region */ |
78 | pixman_region32_init_rects (&r1, boxes3, 2); |
79 | |
80 | b = pixman_region32_rectangles (&r1, &i); |
Value stored to 'b' is never read | |
81 | |
82 | assert (i == 0)((i == 0) ? (void) (0) : __assert_fail ("i == 0", "region-test.c" , 82, __PRETTY_FUNCTION__)); |
83 | |
84 | fill = pixman_image_create_solid_fill (&white); |
85 | for (i = 0; i < 100; i++) |
86 | { |
87 | int image_size = 128; |
88 | |
89 | pixman_region32_init (&r1); |
90 | |
91 | /* Add some random rectangles */ |
92 | for (j = 0; j < 64; j++) |
93 | pixman_region32_union_rect (&r1, &r1, |
94 | lcg_rand_n (image_size), |
95 | lcg_rand_n (image_size), |
96 | lcg_rand_n (25), |
97 | lcg_rand_n (25)); |
98 | |
99 | /* Clip to image size */ |
100 | pixman_region32_init_rect (&r2, 0, 0, image_size, image_size); |
101 | pixman_region32_intersect (&r1, &r1, &r2); |
102 | pixman_region32_fini (&r2); |
103 | |
104 | /* render region to a1 mask */ |
105 | image = pixman_image_create_bits (PIXMAN_a1, image_size, image_size, NULL((void*)0), 0); |
106 | pixman_image_set_clip_region32 (image, &r1); |
107 | pixman_image_composite32 (PIXMAN_OP_SRC, |
108 | fill, NULL((void*)0), image, |
109 | 0, 0, 0, 0, 0, 0, |
110 | image_size, image_size); |
111 | pixman_region32_init_from_image (&r2, image); |
112 | |
113 | pixman_image_unref (image); |
114 | |
115 | assert (pixman_region32_equal (&r1, &r2))((pixman_region32_equal (&r1, &r2)) ? (void) (0) : __assert_fail ("pixman_region32_equal (&r1, &r2)", "region-test.c" , 115, __PRETTY_FUNCTION__)); |
116 | pixman_region32_fini (&r1); |
117 | pixman_region32_fini (&r2); |
118 | |
119 | } |
120 | pixman_image_unref (fill); |
121 | |
122 | return 0; |
123 | } |