From c3b912d7db34c5881cf14725b7d29266cbf24877 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 8 Aug 2006 01:16:49 -0700 Subject: Eliminate most compiler warnings from the test suite --- src/cairo-paginated-surface.c | 2 +- test/bitmap-font.c | 2 +- test/buffer-diff.c | 2 +- test/cairo-test.c | 16 ++++++++++------ test/cairo-test.h | 3 ++- test/clip-operator.c | 2 +- test/create-for-stream.c | 4 +++- test/degenerate-path.c | 2 +- test/fallback-resolution.c | 2 +- test/mask.c | 2 +- test/multi-page.c | 2 +- test/operator-clear.c | 2 +- test/operator-source.c | 2 +- test/pdf-features.c | 4 ++-- test/ps-features.c | 4 ++-- test/push-group.c | 1 - test/read-png.c | 4 ++-- test/svg-surface.c | 2 ++ test/trap-clip.c | 2 +- test/unbounded-operator.c | 2 +- test/write-png.c | 2 +- 21 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 79b39560..d4977786 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -176,7 +176,7 @@ _cairo_paginated_surface_create_image_surface (void *abstract_surface, width, height); - cairo_surface_get_font_options (surface, &options); + cairo_surface_get_font_options (&surface->base, &options); _cairo_surface_set_font_options (image, &options); return image; diff --git a/test/bitmap-font.c b/test/bitmap-font.c index bf8f109e..16ad52ca 100644 --- a/test/bitmap-font.c +++ b/test/bitmap-font.c @@ -50,7 +50,7 @@ draw (cairo_t *cr, int width, int height) FcPattern *pattern; cairo_font_face_t *font_face; cairo_status_t status; - char *srcdir = getenv ("srcdir"); + const char *srcdir = getenv ("srcdir"); char *filename; struct stat stat_buf; diff --git a/test/buffer-diff.c b/test/buffer-diff.c index 0244ecd0..5463c298 100644 --- a/test/buffer-diff.c +++ b/test/buffer-diff.c @@ -92,7 +92,7 @@ buffer_diff_core (unsigned char *_buf_a, for (channel = 0; channel < 4; channel++) { unsigned char value_a = (row_a[x] >> (channel*8)); unsigned char value_b = (row_b[x] >> (channel*8)); - unsigned char diff; + unsigned int diff; diff = value_a - value_b; diff *= 4; /* emphasize */ if (diff > 255) diff --git a/test/cairo-test.c b/test/cairo-test.c index dee30a94..eb358d82 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -104,13 +104,13 @@ static const char *fail_face = "", *normal_face = ""; /* A fake format we use for the flattened ARGB output of the PS and * PDF surfaces. */ -#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED -1 +#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1) /* Static data is messy, but we're coding for tests here, not a * general-purpose library, and it keeps the tests cleaner to avoid a * context object there, (though not a whole lot). */ FILE *cairo_test_log_file = NULL; -char *srcdir; +const char *srcdir; /* Used to catch crashes in a test, such that we report it as such and * continue testing, although one crasher may already have corrupted memory in @@ -230,6 +230,7 @@ _cairo_test_content_name (cairo_content_t content) case CAIRO_CONTENT_COLOR_ALPHA: case CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED: return "argb32"; + case CAIRO_CONTENT_ALPHA: default: assert (0); /* not reached */ return "---"; @@ -347,6 +348,7 @@ test_paginated_write_to_png (cairo_surface_t *surface, case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break; + case CAIRO_CONTENT_ALPHA: default: assert (0); /* not reached */ return CAIRO_STATUS_NO_MEMORY; @@ -511,7 +513,7 @@ create_glitz_glx_surface (glitz_format_name_t formatname, static cairo_surface_t * create_cairo_glitz_glx_surface (cairo_test_t *test, cairo_content_t content, - void **closure) + void **closure) { int width = test->width; int height = test->height; @@ -1108,6 +1110,7 @@ create_xlib_surface (cairo_test_t *test, case CAIRO_CONTENT_COLOR: xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24); break; + case CAIRO_CONTENT_ALPHA: default: cairo_test_log ("Invalid content for xlib test: %d\n", content); return NULL; @@ -1470,7 +1473,7 @@ cleanup_svg (void *closure) } #endif /* CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE */ -const char * +static char * cairo_ref_name_for_test_target_format (const char *test_name, const char *target_name, const char *format) @@ -1521,6 +1524,7 @@ cairo_ref_name_for_test_target_format (const char *test_name, cairo_test_log ("Error: Cannot find reference image for %s/%s-%s-%s%s\n",srcdir, test_name, target_name, + format, CAIRO_TEST_REF_SUFFIX); done: @@ -1528,7 +1532,7 @@ done: } static cairo_test_status_t -cairo_test_for_target (cairo_test_t *test, +cairo_test_for_target (cairo_test_t *test, cairo_test_target_t *target, int dev_offset) { @@ -1691,7 +1695,7 @@ cairo_test_expecting (cairo_test_t *test, { /* we use volatile here to make sure values are not clobbered * by longjmp */ - volatile int i, j, num_targets; + volatile size_t i, j, num_targets; volatile cairo_bool_t limited_targets = FALSE, print_fail_on_stdout = TRUE; const char *tname; void (*old_segfault_handler)(int); diff --git a/test/cairo-test.h b/test/cairo-test.h index 3694f35d..8402d13a 100644 --- a/test/cairo-test.h +++ b/test/cairo-test.h @@ -30,6 +30,7 @@ #include "config.h" #endif +#include #include #include @@ -135,7 +136,7 @@ cairo_status_t cairo_test_paint_checkered (cairo_t *cr); void -xasprintf (char **strp, const char *fmt, ...); +xasprintf (char **strp, const char *fmt, ...) CAIRO_PRINTF_FORMAT(2, 3); CAIRO_END_DECLS diff --git a/test/clip-operator.c b/test/clip-operator.c index 4d262f85..631a59d7 100644 --- a/test/clip-operator.c +++ b/test/clip-operator.c @@ -142,7 +142,7 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - int j, x, y; + size_t j, x, y; cairo_operator_t op; cairo_pattern_t *pattern; diff --git a/test/create-for-stream.c b/test/create-for-stream.c index b2137cec..cbe82004 100644 --- a/test/create-for-stream.c +++ b/test/create-for-stream.c @@ -68,6 +68,8 @@ draw (cairo_t *cr, int width, int height) cairo_fill (cr); cairo_show_page (cr); + + return CAIRO_TEST_SUCCESS; } static void @@ -84,7 +86,7 @@ draw_to (cairo_surface_t *surface) typedef struct _write_closure { char buffer[MAX_OUTPUT_SIZE]; - int index; + size_t index; cairo_test_status_t status; } write_closure_t; diff --git a/test/degenerate-path.c b/test/degenerate-path.c index ab6a34d7..964500fc 100644 --- a/test/degenerate-path.c +++ b/test/degenerate-path.c @@ -43,7 +43,7 @@ static cairo_test_status_t draw (cairo_t *cr, int width, int height) { const cairo_line_cap_t cap[] = { CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_SQUARE, CAIRO_LINE_CAP_BUTT }; - int i; + size_t i; cairo_set_source_rgb (cr, 1, 0, 0); diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c index 3d4b4921..25cdcdc4 100644 --- a/test/fallback-resolution.c +++ b/test/fallback-resolution.c @@ -85,7 +85,7 @@ static const char *backend_filename[NUM_BACKENDS] = { int main (void) { - cairo_surface_t *surface; + cairo_surface_t *surface = NULL; cairo_t *cr; cairo_status_t status; double ppi[] = { 600., 300., 150., 75., 37.5 }; diff --git a/test/mask.c b/test/mask.c index ed328199..84ebf386 100644 --- a/test/mask.c +++ b/test/mask.c @@ -193,7 +193,7 @@ draw (cairo_t *cr, int width, int height) { cairo_surface_t *tmp_surface; cairo_pattern_t *tmp_pattern; - int i, j, k; + size_t i, j, k; cairo_t *cr2; /* Some of our drawing is unbounded, so we draw each test to diff --git a/test/multi-page.c b/test/multi-page.c index 05230c79..86cf188b 100644 --- a/test/multi-page.c +++ b/test/multi-page.c @@ -132,7 +132,7 @@ main (void) { cairo_surface_t *surface; cairo_status_t status; - char *filename; + const char *filename; cairo_test_init ("multi-page"); diff --git a/test/operator-clear.c b/test/operator-clear.c index ea9fcf8f..74d767bb 100644 --- a/test/operator-clear.c +++ b/test/operator-clear.c @@ -158,7 +158,7 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - int i, j, x, y; + size_t i, j, x, y; cairo_pattern_t *pattern; cairo_select_font_face (cr, "Bitstream Vera Sans", diff --git a/test/operator-source.c b/test/operator-source.c index 4bea7935..662df5b5 100644 --- a/test/operator-source.c +++ b/test/operator-source.c @@ -197,7 +197,7 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - int i, j, x, y; + size_t i, j, x, y; cairo_pattern_t *pattern; cairo_select_font_face (cr, "Bitstream Vera Sans", diff --git a/test/pdf-features.c b/test/pdf-features.c index a46500f0..f7904997 100644 --- a/test/pdf-features.c +++ b/test/pdf-features.c @@ -92,8 +92,8 @@ main (void) cairo_surface_t *surface; cairo_t *cr; cairo_status_t status; - char *filename; - int i; + const char *filename; + size_t i; cairo_test_init ("pdf-features"); diff --git a/test/ps-features.c b/test/ps-features.c index 331aa539..e2882ffe 100644 --- a/test/ps-features.c +++ b/test/ps-features.c @@ -95,8 +95,8 @@ main (void) cairo_surface_t *surface; cairo_t *cr; cairo_status_t status; - char *filename; - int i; + const char *filename; + size_t i; char dsc[255]; cairo_test_init ("ps-features"); diff --git a/test/push-group.c b/test/push-group.c index 738df6f1..0c6e50b6 100644 --- a/test/push-group.c +++ b/test/push-group.c @@ -56,7 +56,6 @@ draw (cairo_t *cr, int width, int height) for (i = 0; i < 1; i++) { double x = (i * UNIT_SIZE) + (i + 1) * PAD; double y = (j * UNIT_SIZE) + (j + 1) * PAD; - cairo_pattern_t *group_pattern; cairo_save (cr); diff --git a/test/read-png.c b/test/read-png.c index f5d80b5c..bb02e50b 100644 --- a/test/read-png.c +++ b/test/read-png.c @@ -64,7 +64,7 @@ premultiply_data (png_structp png, png_row_infop row_info, png_bytep data) { - int i; + size_t i; for (i = 0; i < row_info->rowbytes; i += 4) { uint8_t *base = &data[i]; @@ -89,7 +89,7 @@ read_png_argb32 (const char *filename, unsigned int *height, unsigned int *stride) { - int i; + size_t i; FILE *file; #define PNG_SIG_SIZE 8 unsigned char png_sig[PNG_SIG_SIZE]; diff --git a/test/svg-surface.c b/test/svg-surface.c index 305227c5..355394c6 100644 --- a/test/svg-surface.c +++ b/test/svg-surface.c @@ -82,6 +82,8 @@ draw (cairo_t *cr, int width, int height) 0.6, 0.8, 0.7, 0.7); cairo_stroke (cr); + + return CAIRO_TEST_SUCCESS; } int diff --git a/test/trap-clip.c b/test/trap-clip.c index a1483de0..3737e5a3 100644 --- a/test/trap-clip.c +++ b/test/trap-clip.c @@ -176,7 +176,7 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - int i, j, k, x, y; + size_t i, j, k, x, y; for (k = 0; k < ARRAY_SIZE (clip_funcs); k++) { for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) { diff --git a/test/unbounded-operator.c b/test/unbounded-operator.c index d3a6f354..5e01acd1 100644 --- a/test/unbounded-operator.c +++ b/test/unbounded-operator.c @@ -144,7 +144,7 @@ cairo_test_t test = { static cairo_test_status_t draw (cairo_t *cr, int width, int height) { - int i, j, x, y; + size_t i, j, x, y; cairo_pattern_t *pattern; cairo_select_font_face (cr, "Bitstream Vera Sans", diff --git a/test/write-png.c b/test/write-png.c index 83ba2b5c..c906df5f 100644 --- a/test/write-png.c +++ b/test/write-png.c @@ -34,7 +34,7 @@ static void unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data) { - int i; + size_t i; for (i = 0; i < row_info->rowbytes; i += 4) { unsigned char *b = &data[i]; -- cgit v1.2.3