From: Christian Gmeiner Date: Tue, 31 Jan 2017 08:10:27 +0000 (+0100) Subject: etnaviv: Avoid infinite loop in find_frame() X-Git-Tag: android-x86-6.0-r3~201 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f3b7a513835605e340cbea351937969a9a420ef6;p=android-x86%2Fexternal-mesa.git etnaviv: Avoid infinite loop in find_frame() Use of unsigned loop control variable with '>= 0' would lead to infinite loop. Reported by clang: etnaviv_compiler.c:1024:39: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] for (unsigned sp = c->frame_sp; sp >= 0; sp--) ~~ ^ ~ v2: Simply use the same datatype as c->frame_sp is using. CC: Reported-by: Rhys Kidd Signed-off-by: Christian Gmeiner Reviewed-by: Rhys Kidd (cherry picked from commit 82fe240a9912d78bc2eec513c1139c918c5f189f) --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index 59e1452d801..dc9af57bcf2 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -1021,7 +1021,7 @@ label_mark_use(struct etna_compile *c, struct etna_compile_label *label) static struct etna_compile_frame * find_frame(struct etna_compile *c, enum etna_compile_frame_type type) { - for (unsigned sp = c->frame_sp; sp >= 0; sp--) + for (int sp = c->frame_sp; sp >= 0; sp--) if (c->frame_stack[sp].type == type) return &c->frame_stack[sp];