mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 09:08:16 +02:00
test: Silence gcc warnings
warning: cannot optimize possibly infinite loops gcc does not detect that the "infinite" loops are actually just one or two iterations, depending on the has_similar value being FALSE or TRUE. It realizes it if the iteration variable and the iteration stop value are both enum values.
This commit is contained in:
parent
d6efb2a0b7
commit
4ef32a36ba
3 changed files with 21 additions and 13 deletions
|
|
@ -36,7 +36,12 @@
|
|||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_bool_t
|
||||
typedef enum {
|
||||
DIRECT,
|
||||
SIMILAR
|
||||
} cairo_test_similar_t;
|
||||
|
||||
cairo_test_similar_t
|
||||
cairo_test_target_has_similar (const cairo_test_context_t *ctx,
|
||||
const cairo_boilerplate_target_t *target);
|
||||
|
||||
|
|
|
|||
|
|
@ -909,18 +909,18 @@ main (int argc, char **argv)
|
|||
target_error = FALSE,
|
||||
target_crashed = FALSE,
|
||||
target_skipped = TRUE;
|
||||
int has_similar;
|
||||
cairo_test_similar_t has_similar;
|
||||
|
||||
target = ctx.targets_to_test[n];
|
||||
|
||||
has_similar = runner.full_test ?
|
||||
cairo_test_target_has_similar (&ctx, target) :
|
||||
0;
|
||||
DIRECT;
|
||||
for (m = 0; m < runner.num_device_offsets; m++) {
|
||||
int dev_offset = m * 25;
|
||||
int similar;
|
||||
cairo_test_similar_t similar;
|
||||
|
||||
for (similar = 0; similar <= has_similar; similar++) {
|
||||
for (similar = DIRECT; similar <= has_similar; similar++) {
|
||||
status = _cairo_test_runner_draw (&runner, &ctx, target,
|
||||
similar, dev_offset);
|
||||
switch (status) {
|
||||
|
|
|
|||
|
|
@ -454,12 +454,12 @@ _cairo_test_mkdir (const char *path)
|
|||
return errno == EEXIST;
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
cairo_test_similar_t
|
||||
cairo_test_target_has_similar (const cairo_test_context_t *ctx,
|
||||
const cairo_boilerplate_target_t *target)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_bool_t has_similar;
|
||||
cairo_test_similar_t has_similar;
|
||||
cairo_t * cr;
|
||||
cairo_surface_t *similar;
|
||||
cairo_status_t status;
|
||||
|
|
@ -468,16 +468,16 @@ cairo_test_target_has_similar (const cairo_test_context_t *ctx,
|
|||
|
||||
/* ignore image intermediate targets */
|
||||
if (target->expected_type == CAIRO_SURFACE_TYPE_IMAGE)
|
||||
return FALSE;
|
||||
return DIRECT;
|
||||
|
||||
if (getenv ("CAIRO_TEST_IGNORE_SIMILAR"))
|
||||
return FALSE;
|
||||
return DIRECT;
|
||||
|
||||
xasprintf (&path, "%s/%s",
|
||||
_cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".",
|
||||
ctx->test_name);
|
||||
|
||||
has_similar = FALSE;
|
||||
has_similar = DIRECT;
|
||||
do {
|
||||
do {
|
||||
surface = (target->create_surface) (path,
|
||||
|
|
@ -502,7 +502,10 @@ cairo_test_target_has_similar (const cairo_test_context_t *ctx,
|
|||
similar = cairo_get_group_target (cr);
|
||||
status = cairo_surface_status (similar);
|
||||
|
||||
has_similar = cairo_surface_get_type (similar) == cairo_surface_get_type (surface);
|
||||
if (cairo_surface_get_type (similar) == cairo_surface_get_type (surface))
|
||||
has_similar = SIMILAR;
|
||||
else
|
||||
has_similar = DIRECT;
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
|
@ -1813,10 +1816,10 @@ _cairo_test_context_run (cairo_test_context_t *ctx)
|
|||
|
||||
for (j = 0; j < NUM_DEVICE_OFFSETS; j++) {
|
||||
int dev_offset = ((j + ctx->thread) % NUM_DEVICE_OFFSETS) * 25;
|
||||
int similar, has_similar;
|
||||
cairo_test_similar_t similar, has_similar;
|
||||
|
||||
has_similar = cairo_test_target_has_similar (ctx, target);
|
||||
for (similar = 0; similar <= has_similar ; similar++) {
|
||||
for (similar = DIRECT; similar <= has_similar; similar++) {
|
||||
cairo_status_t status;
|
||||
|
||||
status = _cairo_test_context_run_for_target (ctx,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue