Re: [PATCH 13/72] tests: fixed warnings on unused variables
Bryce Harrington <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Dec 29, 2015 at 10:16:51AM +0100, Enrico Weigelt, metux IT consult wrote: > Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]> > --- > test/any2ppm.c | 3 +++ > test/create-for-stream.c | 23 +++++++++++++++++++++-- > 2 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/test/any2ppm.c b/test/any2ppm.c > index b60b4d9..8ceacc1 100644 > --- a/test/any2ppm.c > +++ b/test/any2ppm.c > @@ -102,6 +102,7 @@ > > #define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0]))) > > +#if CAIRO_HAS_INTERPRETER || CAIRO_CAN_TEST_PDF_SURFACE || CAIRO_CAN_TEST_SVG_SURFACE || CAIRO_HAS_SPECTRE > static int > _cairo_writen (int fd, char *buf, int len) > { > @@ -267,6 +268,8 @@ _create_image (void *closure, > *out = cairo_image_surface_create (format, width, height); > return cairo_surface_reference (*out); > } > +#endif /* CAIRO_HAS_INTERPRETER || CAIRO_CAN_TEST_PDF_SURFACE || CAIRO_CAN_TEST_SVG_SURFACE || CAIRO_HAS_SPECTRE */ > + If I am understanding it correctly, the above chunk is dealing more with unused functions rather than unused variables? Seems distinct enough that probably should be handled as a separate patch from the following bits. Also, I'm not sure this is the right approach. I gather that the intent here is to avoid warnings in situations where these helper routines are not actually used, but #ifdef'ing them out seems a bit clunky to me. The routines themselves seem not to be doing anything terribly exotic and I gather they should still compile just fine even when the interpreter is disabled or whatever. Seems like a more robust solution would be to move them elsewhere and let the linker take care of sorting out whether to include them? > #if CAIRO_HAS_INTERPRETER > static const char * > diff --git a/test/create-for-stream.c b/test/create-for-stream.c > index af1632f..aafb97c 100644 > --- a/test/create-for-stream.c > +++ b/test/create-for-stream.c > @@ -59,6 +59,8 @@ > > #define BASENAME "create-for-stream.out" > > +#if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE > static cairo_test_status_t > draw (cairo_t *cr, int width, int height) > { > @@ -238,14 +240,15 @@ static cairo_test_status_t > preamble (cairo_test_context_t *ctx) > { > cairo_test_status_t status = CAIRO_TEST_UNTESTED; > - cairo_test_status_t test_status; > - char *filename; > const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : "."; This change seems like a sensible warnings fix. > #if CAIRO_HAS_PS_SURFACE > if (cairo_test_is_target_enabled (ctx, "ps2") || > cairo_test_is_target_enabled (ctx, "ps3")) > { > + cairo_test_status_t test_status; > + char *filename; > + > if (status == CAIRO_TEST_UNTESTED) > status = CAIRO_TEST_SUCCESS; > > @@ -264,6 +267,9 @@ preamble (cairo_test_context_t *ctx) > > #if CAIRO_HAS_PDF_SURFACE > if (cairo_test_is_target_enabled (ctx, "pdf")) { > + cairo_test_status_t test_status; > + char *filename; > + > if (status == CAIRO_TEST_UNTESTED) > status = CAIRO_TEST_SUCCESS; > > @@ -284,6 +290,9 @@ preamble (cairo_test_context_t *ctx) > if (cairo_test_is_target_enabled (ctx, "svg11") || > cairo_test_is_target_enabled (ctx, "svg12")) > { > + cairo_test_status_t test_status; > + char *filename; > + > if (status == CAIRO_TEST_UNTESTED) > status = CAIRO_TEST_SUCCESS; > > @@ -303,6 +312,16 @@ preamble (cairo_test_context_t *ctx) > return status; > } > > +#else /* CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE */ > + > +static cairo_test_status_t > +preamble (cairo_test_context_t *ctx) > +{ > + return CAIRO_TEST_UNTESTED; > +} > + > +#endif /* CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE */ > + > CAIRO_TEST (create_for_stream, > "Checks creating vector surfaces with user defined I/O\n", > "stream", /* keywords */ > -- > 2.6.4.442.g545299f > > -- > cairo mailing list > [email protected] > http://lists.cairographics.org/mailman/listinfo/cairo -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo