<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 22, 2016 at 10:25 AM, Martin Galvan <span dir="ltr"><<a href="mailto:martin.galvan@tallertechnologies.com" target="_blank">martin.galvan@tallertechnologies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, Mar 19, 2016 at 15:59, Joel Sherrill <<a href="mailto:joel@rtems.org">joel@rtems.org</a>> wrote:<br>
> Hi<br>
><br>
> GCC 6.0 previews give the indentation warning below<br>
><br>
> ../../../../../rtems/c/src/libchip/network/sonic.c:837:11: warning:<br>
> statement is indented as if it were guarded by... [-Wmisleading-indentation]<br>
><br>
> on this code from sonic.c.<br>
><br>
> for (i = 0 ; i < 2 ; i++) {<br>
> if ((*sc->read_register)( rp, SONIC_REG_RRP ) ==<br>
> (*sc->read_register)( rp, SONIC_REG_RSA ))<br>
> (*sc->write_register)(<br>
> rp,<br>
> SONIC_REG_RRP,<br>
> (*sc->read_register)( rp, SONIC_REG_REA )<br>
> );<br>
> (*sc->write_register)(<br>
> rp,<br>
> SONIC_REG_RRP,<br>
> (*sc->read_register)(rp, SONIC_REG_RRP) -<br>
> sizeof(ReceiveResource_t)<br>
> );<br>
> }<br>
><br>
> >From the comments, this code was written for RTEMS. Assuming it<br>
> works (and it did on both a DMV177 and erc32 Tharsys board), then<br>
> I am prone to add braces to the if and move the second write register<br>
> to the left.<br>
<br>
</span>I'd honestly rewrite that entire snippet :)<br>
<br>
for (i = 0; i < 2; ++i) {<br>
uint32_t rrp = (*sc->read_register)( rp, SONIC_REG_RRP );<br>
const uint32_t rsa = (*sc->read_register)( rp, SONIC_REG_RSA );<br>
<br>
if (rrp == rsa) {<br>
const uint32_t rea = (*sc->read_register)( rp, SONIC_REG_REA );<br>
(*sc->write_register)( rp, SONIC_REG_RRP, rea );<br>
}<br>
<br>
rrp = (*sc->read_register)(rp, SONIC_REG_RRP);<br>
(*sc->write_register)( rp, SONIC_REG_RRP, rrp - sizeof(ReceiveResource_t) );<br>
}<br>
<br>
I re-read RRP because I don't know if it can change between both calls.<br>
</blockquote></div><br></div><div class="gmail_extra">If you want to submit a patch and reference this email thread URL so</div><div class="gmail_extra">future generations know what was discussed, feel free. :)</div><div class="gmail_extra"><br></div><div class="gmail_extra">--joel</div></div>