<div dir="ltr">On 20 January 2017 at 17:06, Christian Gmeiner <span dir="ltr"><<a href="mailto:christian.gmeiner@gmail.com" target="_blank">christian.gmeiner@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Rhys,<br>
<span class="gmail-"><br>
2017-01-19 7:02 GMT+01:00 Rhys Kidd <<a href="mailto:rhyskidd@gmail.com">rhyskidd@gmail.com</a>>:<br>
> Use of unsigned loop control variable with '>= 0' would lead to infinite loop.<br>
><br>
> Reported by clang:<br>
><br>
> etnaviv_compiler.c:1024:39: warning: comparison of unsigned expression >= 0 is<br>
> always true [-Wtautological-compare]<br>
> for (unsigned sp = c->frame_sp; sp >= 0; sp--)<br>
> ~~ ^ ~<br>
><br>
> Signed-off-by: Rhys Kidd <<a href="mailto:rhyskidd@gmail.com">rhyskidd@gmail.com</a>><br>
> ---<br>
> src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c | 2 +-<br>
> 1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> I compile tested etnaviv but have not functionally tested on real hardware.<br>
><br>
> diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c b/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
> index 59e1452..f1c6787 100644<br>
> --- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
> +++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
> @@ -1021,7 +1021,7 @@ label_mark_use(struct etna_compile *c, struct etna_compile_label *label)<br>
> static struct etna_compile_frame *<br>
> find_frame(struct etna_compile *c, enum etna_compile_frame_type type)<br>
> {<br>
> - for (unsigned sp = c->frame_sp; sp >= 0; sp--)<br>
> + for (unsigned sp = c->frame_sp + 1; sp-- > 0 ; )<br>
<br>
</span>looks quite ugly - I have a better and simpler fix.<br>
<span class="gmail-"><br>
> if (c->frame_stack[sp].type == type)<br>
> return &c->frame_stack[sp];<br>
><br>
> --<br>
> 2.9.3<br>
><br>
<br>
</span>------------8<----------------<wbr>---<br>
<br>
Subject: [PATCH] etnaviv: Avoid infinite loop in find_frame()<br>
<span class="gmail-"><br>
Use of unsigned loop control variable with '>= 0' would lead to infinite<br>
loop.<br>
<br>
Reported by clang:<br>
<br>
etnaviv_compiler.c:1024:39: warning: comparison of unsigned expression<br>
>= 0 is always true [-Wtautological-compare]<br>
for (unsigned sp = c->frame_sp; sp >= 0; sp--)<br>
~~ ^ ~<br>
<br>
</span>v2: Simply use the same datatype as c->frame_sp is using.<br>
<br>
Reported-by: Rhys Kidd <<a href="mailto:rhyskidd@gmail.com">rhyskidd@gmail.com</a>><br>
Signed-off-by: Christian Gmeiner <<a href="mailto:christian.gmeiner@gmail.com">christian.gmeiner@gmail.com</a>><br>
<span class="gmail-">---<br>
src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c | 2 +-<br>
1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
</span>diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
b/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
index 59e1452..dc9af57 100644<br>
<span class="gmail-">--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_compiler.c<br>
@@ -1021,7 +1021,7 @@ label_mark_use(struct etna_compile *c, struct<br>
etna_compile_label *label)<br>
static struct etna_compile_frame *<br>
find_frame(struct etna_compile *c, enum etna_compile_frame_type type)<br>
{<br>
- for (unsigned sp = c->frame_sp; sp >= 0; sp--)<br>
</span>+ for (int sp = c->frame_sp; sp >= 0; sp--)<br>
<span class="gmail-"> if (c->frame_stack[sp].type == type)<br>
return &c->frame_stack[sp];<br>
<br>
--<br>
2.9.3<br>
</span>------------8<----------------<wbr>---<br>
<br>
If you are okay with that I will push it in the next days.<br>
<br></blockquote><div><br>Reviewed-by: Rhys Kidd <<a href="mailto:rhyskidd@gmail.com">rhyskidd@gmail.com</a>><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
greets<br>
--<br>
Christian Gmeiner, MSc<br>
<br>
<a href="https://www.youtube.com/user/AloryOFFICIAL" rel="noreferrer" target="_blank">https://www.youtube.com/user/<wbr>AloryOFFICIAL</a><br>
<a href="https://soundcloud.com/christian-gmeiner" rel="noreferrer" target="_blank">https://soundcloud.com/<wbr>christian-gmeiner</a><br>
</blockquote></div><br></div></div>