pixman: Branch 'master' - 5 commits
Andrea Canciani
ranma42 at kemper.freedesktop.org
Wed Nov 9 00:40:04 PST 2011
demos/composite-test.c | 2 +-
pixman/pixman-image.c | 7 ++-----
pixman/pixman-region.c | 9 +++------
test/a1-trap-test.c | 2 +-
test/alphamap.c | 2 --
test/blitters-test.c | 3 +--
test/composite-traps-test.c | 1 -
test/composite.c | 2 --
test/fetch-test.c | 8 ++------
test/gradient-crash-test.c | 6 +++---
test/lowlevel-blt-bench.c | 6 +-----
test/oob-test.c | 4 ++--
test/region-contains-test.c | 1 -
test/region-translate-test.c | 2 +-
test/scaling-crash-test.c | 7 +++----
test/scaling-test.c | 1 -
test/stress-test.c | 1 +
test/trap-crasher.c | 4 ++--
test/utils.c | 1 +
test/utils.h | 1 -
20 files changed, 24 insertions(+), 46 deletions(-)
New commits:
commit b31da39f6f65d1784fc2f6915c30eb011cc2893b
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Nov 3 11:07:25 2011 +0100
demos: Consistently use G_N_ELEMENTS()
Instead of open-coding G_N_ELEMENTS(), just use it.
diff --git a/demos/composite-test.c b/demos/composite-test.c
index f5f352f..bba90c5 100644
--- a/demos/composite-test.c
+++ b/demos/composite-test.c
@@ -123,7 +123,7 @@ main (int argc, char **argv)
table = gtk_table_new (G_N_ELEMENTS (operators) / 6, 6, TRUE);
src_img = pixman_image_create_linear_gradient (&p1, &p2, stops,
- sizeof (stops) / sizeof (stops[0]));
+ G_N_ELEMENTS (stops));
pixman_image_set_repeat (src_img, PIXMAN_REPEAT_PAD);
commit 1662c94348eda19ec35db2625749febd1dceb35e
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Nov 3 10:53:10 2011 +0100
test: Reuse the ARRAY_LENGTH() macro
It is provided by utils.h, there is no need to redefine it.
diff --git a/test/alphamap.c b/test/alphamap.c
index 554b309..24a350e 100644
--- a/test/alphamap.c
+++ b/test/alphamap.c
@@ -139,8 +139,6 @@ get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
return r;
}
-#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
-
static int
run_test (int s, int d, int sa, int da, int soff, int doff)
{
diff --git a/test/scaling-crash-test.c b/test/scaling-crash-test.c
index 50d445d..ed57ae0 100644
--- a/test/scaling-crash-test.c
+++ b/test/scaling-crash-test.c
@@ -130,12 +130,11 @@ do_test (int32_t dst_size,
int32_t src_offs,
int32_t scale_factor)
{
-#define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
int i, j;
- for (i = 0; i < N_ELEMENTS(filters); ++i)
+ for (i = 0; i < ARRAY_LENGTH (filters); ++i)
{
- for (j = 0; j < N_ELEMENTS (repeats); ++j)
+ for (j = 0; j < ARRAY_LENGTH (repeats); ++j)
{
/* horizontal test */
if (run_test (dst_size, 1,
commit 97b9fa090c54f6feab54bde272df374a13c0c84d
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Nov 3 10:51:27 2011 +0100
Use the ARRAY_LENGTH() macro when possible
This patch has been generated by the following Coccinelle semantic patch:
// Use the ARRAY_LENGTH() macro when possible
//
// Replace open-coded array length computations with the
// ARRAY_LENGTH() macro
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_LENGTH (E)
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 6355632..55b6c73 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -280,7 +280,7 @@ test_composite (int testnum, int verbose)
lcg_srand (testnum);
- op = op_list[lcg_rand_n (sizeof (op_list) / sizeof (op_list[0]))];
+ op = op_list[lcg_rand_n (ARRAY_LENGTH (op_list))];
if (lcg_rand_n (8))
{
diff --git a/test/fetch-test.c b/test/fetch-test.c
index fa79ad7..04e8cc5 100644
--- a/test/fetch-test.c
+++ b/test/fetch-test.c
@@ -103,7 +103,7 @@ static testcase_t testcases[] =
},
};
-int n_test_cases = sizeof(testcases)/sizeof(testcases[0]);
+int n_test_cases = ARRAY_LENGTH (testcases);
static uint32_t
diff --git a/test/gradient-crash-test.c b/test/gradient-crash-test.c
index c85712d..73e5bbc 100644
--- a/test/gradient-crash-test.c
+++ b/test/gradient-crash-test.c
@@ -106,17 +106,17 @@ main (int argc, char **argv)
if (i == 0)
{
stops = onestop;
- num_stops = sizeof(onestop) / sizeof(onestop[0]);
+ num_stops = ARRAY_LENGTH (onestop);
}
else if (i == 1)
{
stops = subsetstops;
- num_stops = sizeof(subsetstops) / sizeof(subsetstops[0]);
+ num_stops = ARRAY_LENGTH (subsetstops);
}
else
{
stops = stops01;
- num_stops = sizeof(stops01) / sizeof(stops01[0]);
+ num_stops = ARRAY_LENGTH (stops01);
}
for (j = 0; j < 3; ++j)
diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 67cd939..ba7f307 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -703,7 +703,7 @@ main (int argc, char *argv[])
x / 1000000., x / 4000000);
printf ("---\n");
- for (i = 0; i < sizeof(tests_tbl) / sizeof(tests_tbl[0]); i++)
+ for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
{
if (strcmp (pattern, "all") == 0 || strstr (tests_tbl[i].testname, pattern))
{
diff --git a/test/oob-test.c b/test/oob-test.c
index 9c1a25d..0d19b50 100644
--- a/test/oob-test.c
+++ b/test/oob-test.c
@@ -94,7 +94,7 @@ main (int argc, char **argv)
{
int i;
- for (i = 0; i < sizeof (info) / sizeof (info[0]); ++i)
+ for (i = 0; i < ARRAY_LENGTH (info); ++i)
test_composite (&info[i]);
return 0;
diff --git a/test/trap-crasher.c b/test/trap-crasher.c
index db7e01a..4e4cac2 100644
--- a/test/trap-crasher.c
+++ b/test/trap-crasher.c
@@ -22,6 +22,6 @@ main()
dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1);
- pixman_add_trapezoids (dst, 0, 0, sizeof (traps)/sizeof (traps[0]), traps);
+ pixman_add_trapezoids (dst, 0, 0, ARRAY_LENGTH (traps), traps);
return (0);
}
commit 06760f5cb069bdc041af7a0e73c9d5fc08741f28
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Nov 3 10:40:24 2011 +0100
test: Cleanup includes
All the tests are linked to libutil, hence it makes sence to always
include utils.h and reuse what it provides (config.h inclusion, access
to private pixman APIs, ARRAY_LENGTH, ...).
diff --git a/test/a1-trap-test.c b/test/a1-trap-test.c
index 6163e7c..93c6caa 100644
--- a/test/a1-trap-test.c
+++ b/test/a1-trap-test.c
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "pixman.h"
+#include "utils.h"
int
main (int argc, char **argv)
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 4f931c4..6355632 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -5,7 +5,6 @@
* Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
* the case of test failure.
*/
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "utils.h"
diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c
index fa6d8a9..ff03b50 100644
--- a/test/composite-traps-test.c
+++ b/test/composite-traps-test.c
@@ -1,6 +1,5 @@
/* Based loosely on scaling-test */
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "utils.h"
diff --git a/test/composite.c b/test/composite.c
index 408c363..fe59eae 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -22,8 +22,6 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-#define PIXMAN_USE_INTERNAL_API
-#include <pixman.h>
#include <stdio.h>
#include <stdlib.h> /* abort() */
#include <math.h>
diff --git a/test/fetch-test.c b/test/fetch-test.c
index 9f80eec..fa79ad7 100644
--- a/test/fetch-test.c
+++ b/test/fetch-test.c
@@ -1,11 +1,7 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
-#include "pixman.h"
+#include "utils.h"
#define SIZE 1024
diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index bdafb35..67cd939 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -25,10 +25,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-#define PIXMAN_USE_INTERNAL_API
-#include <pixman.h>
-
#include "utils.h"
#define SOLID_FLAG 1
diff --git a/test/oob-test.c b/test/oob-test.c
index 4f9e5a2..9c1a25d 100644
--- a/test/oob-test.c
+++ b/test/oob-test.c
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include "pixman.h"
+#include "utils.h"
typedef struct
{
diff --git a/test/region-contains-test.c b/test/region-contains-test.c
index b660fdf..2372686 100644
--- a/test/region-contains-test.c
+++ b/test/region-contains-test.c
@@ -1,4 +1,3 @@
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "utils.h"
diff --git a/test/region-translate-test.c b/test/region-translate-test.c
index 0e96a5e..5a03027 100644
--- a/test/region-translate-test.c
+++ b/test/region-translate-test.c
@@ -1,5 +1,5 @@
-#include <pixman.h>
#include <assert.h>
+#include "utils.h"
/* Pixman had a bug where 32bit regions where clipped to 16bit sizes when
* pixman_region32_translate() was called. This test exercises that bug.
diff --git a/test/scaling-crash-test.c b/test/scaling-crash-test.c
index 40323d4..50d445d 100644
--- a/test/scaling-crash-test.c
+++ b/test/scaling-crash-test.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include "pixman.h"
+#include "utils.h"
/*
* We have a source image filled with solid color, set NORMAL or PAD repeat,
diff --git a/test/scaling-test.c b/test/scaling-test.c
index 82370f7..6f2da14 100644
--- a/test/scaling-test.c
+++ b/test/scaling-test.c
@@ -7,7 +7,6 @@
* Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
* the case of test failure.
*/
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "utils.h"
diff --git a/test/stress-test.c b/test/stress-test.c
index 571420a..08bf1d4 100644
--- a/test/stress-test.c
+++ b/test/stress-test.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include "utils.h"
#include <sys/types.h>
diff --git a/test/trap-crasher.c b/test/trap-crasher.c
index 7485e62..db7e01a 100644
--- a/test/trap-crasher.c
+++ b/test/trap-crasher.c
@@ -1,5 +1,5 @@
#include <stdlib.h>
-#include <pixman.h>
+#include "utils.h"
int
main()
diff --git a/test/utils.c b/test/utils.c
index adabd75..204066f 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -2,6 +2,7 @@
#include "utils.h"
#include <signal.h>
+#include <stdlib.h>
#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
diff --git a/test/utils.h b/test/utils.h
index b23925c..3bff78e 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -2,7 +2,6 @@
#include <config.h>
#endif
-#include <stdlib.h>
#include <assert.h>
#include "pixman-private.h" /* For 'inline' definition */
commit cbd88a9416d9b33e6589e3f857ee839559a7e4de
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Nov 3 10:21:41 2011 +0100
Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it
@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free(E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
- free (E);
- }
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 09d7cbc..913853c 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -145,11 +145,8 @@ _pixman_image_fini (pixman_image_t *image)
pixman_region32_fini (&common->clip_region);
- if (common->transform)
- free (common->transform);
-
- if (common->filter_params)
- free (common->filter_params);
+ free (common->transform);
+ free (common->filter_params);
if (common->alpha_map)
pixman_image_unref ((pixman_image_t *)common->alpha_map);
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 47beb52..80219c6 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -828,8 +828,7 @@ pixman_op (region_type_t * new_reg, /* Place to store result
{
if (!pixman_rect_alloc (new_reg, new_size))
{
- if (old_data)
- free (old_data);
+ free (old_data);
return FALSE;
}
}
@@ -1005,8 +1004,7 @@ pixman_op (region_type_t * new_reg, /* Place to store result
APPEND_REGIONS (new_reg, r2_band_end, r2_end);
}
- if (old_data)
- free (old_data);
+ free (old_data);
if (!(numRects = new_reg->data->numRects))
{
@@ -1027,8 +1025,7 @@ pixman_op (region_type_t * new_reg, /* Place to store result
return TRUE;
bail:
- if (old_data)
- free (old_data);
+ free (old_data);
return pixman_break (new_reg);
}
More information about the xorg-commit
mailing list