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