use a do-while() loop in pnv_phbX_translate_tve()
v2 cover use a do-while() loop in pnv_phbX_translate_tve()
Hi,
This second version implemented Matheus' suggestion of using a do-while() loop instead of initializing variables.
v1 link: https://lists.gnu.org/archive/html/qemu-devel/2022-01/msg05475.html
Daniel Henrique Barboza (2):
ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve() ppc/pnv: use a do-while() loop in pnv_phb4_translate_tve()
hw/pci-host/pnv_phb3.c | 4 ++-- hw/pci-host/pnv_phb4.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 2/2 ppc/pnv: use a do-while() loop in pnv_phb4_translate_tve()
pnv_phb4_translate_tve() is quite similar to pnv_phb3_translate_tve(), and that includes the fact that 'taddr' can be considered uninitialized when throwing the "TCE access fault" error because, in theory, the loop that sets 'taddr' can be skippable due to 'lev' being an signed int.
No one complained about this specific case yet, but since we took the time to handle the same situtation in pnv_phb3_translate_tve(), let's replicate it here as well.
--- hw/pci-host/pnv_phb4.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/pci-host/pnv_phb4.c +10 -2
@@ -1261,13 +1261,21 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr,/* Top level table base address */ base = tta <<12 ; +/* +* There were reports of compilers complaining about 'taddr' +* being used uninitialized in pnv_phb3_translate_tve(), and +* the same scenario is happening here. Initialize 'taddr' +* just in case. +*/ + taddr = base; +/* Total shift to first level */ sh = tbl_shift * lev + tce_shift;/* TODO: Limit to support IO page sizes */ /* TODO: Multi-level untested */ -while ((lev--) >=0 ) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,
@@ -1288,7 +1296,7 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull ; - } + }while ((lev--) >=0 );/* We exit the loop with TCE being the final TCE */ tce_mask = ~((1ull << tce_shift) -1 );
Signature · 1 line
2.34.1
PATCH v2 1/2 ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve()
In reply to Daniel Henrique BarbozaThe 'taddr' variable is left unintialized, being set only inside the "while ((lev--) >= 0)" loop where we get the TCE address. The 'lev' var is an int32_t that is being initiliazed by the GETFIELD() macro, which returns an uint64_t.
For a human reader this means that 'lev' will always be positive or zero. But some compilers may beg to differ. 'lev' being an int32_t can in theory be set as negative, and the "while ((lev--) >= 0)" loop might never be reached, and 'taddr' will be left unitialized. This can cause phb3_error() to use 'taddr' uninitialized down below:
if ((is_write & !(tce & 2)) || ((!is_write) && !(tce & 1))) {
phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);A quick way of fixing it is to use a do/while() loop. This will keep the same semanting as the existing while() loop does and the compiler will understand that 'taddr' will be initialized at least once.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/573
--- hw/pci-host/pnv_phb3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/pnv_phb3.c +2 -2
@@ -792,7 +792,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, sh = tbl_shift * lev + tce_shift;/* TODO: Multi-level untested */ -while ((lev--) >=0 ) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,
@@ -813,7 +813,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull ; - } + }while ((lev--) >=0 );/* We exit the loop with TCE being the final TCE */ tce_mask = ~((1ull << tce_shift) -1 );
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] ppc/pnv: use a do-while() loop in pnv_phb4_translate_tve()
In reply to Matheus K. FerstQuoted 23 lines · Matheus K. Ferst
Quoted 22 lines · Daniel Henrique Barboza
pnv_phb4_translate_tve()is quite similar topnv_phb3_translate_tve(), and that includes the fact that 'taddr' can be considered uninitialized when throwing the "TCE access fault" error because, in theory, the loop that sets 'taddr' can be skippable due to 'lev' being an signed int.No one complained about this specific case yet, but since we took the time to handle the same situtation in
pnv_phb3_translate_tve(), let's replicate it here as well.Signed-off-by Daniel Henrique Barboza <[email protected]>---
hw/pci-host/pnv_phb4.c| 12 ++++++++++--1 file changed, 10 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb4.c +0
-0@@ -1261,13 +1261,21 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, /* Top level table base address */ base = tta << 12;
Quoted 10 lines
hw/pci-host/pnv_phb4.c static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, · line 1271
Quoted 8 lines
hw/pci-host/pnv_phb4.c +8
-0+ /* + * There were reports of compilers complaining about 'taddr' + * being used uninitialized in pnv_phb3_translate_tve(), and + * the same scenario is happening here. Initialize 'taddr' + * just in case. + */ + taddr = base; +Do we still need this initialization?
Nah, that was a spill from the previous patch that I forgot to remove.
Thanks,
Daniel
Quoted 26 lines
Quoted 13 lines
hw/pci-host/pnv_phb4.c +1
-1/* Total shift to first level */ sh = tbl_shift * lev + tce_shift; /* TODO: Limit to support IO page sizes */ /* TODO: Multi-level untested */ - while ((lev--) >= 0) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,hw/pci-host/pnv_phb4.c static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, · line 1299
Quoted 5 lines
hw/pci-host/pnv_phb4.c +1
-1@@ -1288,7 +1296,7 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull; - } + } while ((lev--) >= 0);The same comments from the other patch apply here, this changes the number of iterations in this loop.
Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Re: [PATCH v2 1/2] ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve()
In reply to Daniel Henrique BarbozaQuoted 39 lines · Daniel Henrique Barboza
The 'taddr' variable is left unintialized, being set only inside the "while ((lev--) >= 0)" loop where we get the TCE address. The 'lev' var is an
int32_tthat is being initiliazed by theGETFIELD()macro, which returns anuint64_t.For a human reader this means that 'lev' will always be positive or zero. But some compilers may beg to differ. 'lev' being an
int32_tcan in theory be set as negative, and the "while ((lev--) >= 0)" loop might never be reached, and 'taddr' will be left unitialized. This can causephb3_error()to use 'taddr' uninitialized down below:if ((is_write & !(tce & 2)) || ((!is_write) && !(tce & 1))) { phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);A quick way of fixing it is to use a do/while() loop. This will keep the same semanting as the existing
while()loop does and the compiler will understand that 'taddr' will be initialized at least once.Suggested-by Matheus K. Ferst <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/573
Signed-off-by Daniel Henrique Barboza <[email protected]>--- hw/pci-host/pnv_phb3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb3.c +1
-1@@ -792,7 +792,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, sh = tbl_shift * lev + tce_shift;/* TODO: Multi-level untested */ -while ((lev--) >=0 ) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,
hw/pci-host/pnv_phb3.c static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, · line 816
Quoted 5 lines
hw/pci-host/pnv_phb3.c +1
-1@@ -813,7 +813,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull ; - } + }while ((lev--) >=0 );
This changes the number of iterations in this loop. We'd need "while ((--lev) >= 0)" to keep it the same, but then we would be checking "!(tce & 3)" for the last iteration. Is that a problem?
Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Re: [PATCH v2 2/2] ppc/pnv: use a do-while() loop in pnv_phb4_translate_tve()
In reply to Daniel Henrique BarbozaQuoted 20 lines · Daniel Henrique Barboza
pnv_phb4_translate_tve()is quite similar topnv_phb3_translate_tve(), and that includes the fact that 'taddr' can be considered uninitialized when throwing the "TCE access fault" error because, in theory, the loop that sets 'taddr' can be skippable due to 'lev' being an signed int.No one complained about this specific case yet, but since we took the time to handle the same situtation in
pnv_phb3_translate_tve(), let's replicate it here as well.Signed-off-by Daniel Henrique Barboza <[email protected]>--- hw/pci-host/pnv_phb4.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb4.c +0
-0@@ -1261,13 +1261,21 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr,/* Top level table base address */
hw/pci-host/pnv_phb4.c static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, · line 1271
Quoted 10 lines
hw/pci-host/pnv_phb4.c +8
-0base = tta <<12 ; +/* +* There were reports of compilers complaining about 'taddr' +* being used uninitialized in pnv_phb3_translate_tve(), and +* the same scenario is happening here. Initialize 'taddr' +* just in case. +*/ + taddr = base; +
Do we still need this initialization?
Quoted 12 lines
hw/pci-host/pnv_phb4.c +1
-1/* Total shift to first level */ sh = tbl_shift * lev + tce_shift;/* TODO: Limit to support IO page sizes */ /* TODO: Multi-level untested */ -while ((lev--) >=0 ) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,
hw/pci-host/pnv_phb4.c static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, · line 1299
Quoted 5 lines
hw/pci-host/pnv_phb4.c +1
-1@@ -1288,7 +1296,7 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull ; - } + }while ((lev--) >=0 );
The same comments from the other patch apply here, this changes the number of iterations in this loop.
Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Re: [PATCH v2 1/2] ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve()
In reply to Daniel Henrique BarbozaQuoted 51 lines · Daniel Henrique Barboza
Quoted 34 lines · Matheus K. Ferst
Quoted 33 lines · Daniel Henrique Barboza
The 'taddr' variable is left unintialized, being set only inside the "while ((lev--) >= 0)" loop where we get the TCE address. The 'lev' var is an
int32_tthat is being initiliazed by theGETFIELD()macro, which returns anuint64_t.For a human reader this means that 'lev' will always be positive or zero. But some compilers may beg to differ. 'lev' being an
int32_tcan in theory be set as negative, and the "while ((lev--) >= 0)" loop might never be reached, and 'taddr' will be left unitialized. This can causephb3_error()to use 'taddr' uninitialized down below:if ((
is_write& !(tce & 2)) || ((!is_write) && !(tce & 1))) {phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);A quick way of fixing it is to use a do/while() loop. This will keep the same semanting as the existing
while()loop does and the compiler will understand that 'taddr' will be initialized at least once.Suggested-by Matheus K. Ferst <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/573
Signed-off-by Daniel Henrique Barboza <[email protected]>---
hw/pci-host/pnv_phb3.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb3.c +0
-0@@ -792,7 +792,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, sh = tbl_shift * lev + tce_shift;Quoted 15 lines
hw/pci-host/pnv_phb3.c static void · line 817
Quoted 13 lines
hw/pci-host/pnv_phb3.c +1
-1/* TODO: Multi-level untested */ - while ((lev--) >= 0) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3);if (dma_memory_read(&address_space_memory, taddr, &tce,
hw/pci-host/pnv_phb3.c +1
-1@@ -813,7 +813,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull; - } + } while ((lev--) >= 0);This changes the number of iterations in this loop.
Quoted 6 lines
ooofff
Quoted 1 line
We'd need "while ((--lev) >= 0)" to keep it the same, but then we would be checking "!(tce & 3)" for the last iteration. Is that a problem?
I don't think that's a problem because then (lev >= 0) will not be true
That holds for "while ((lev--) >= 0)", where the last iteration has "lev=-1", but "while ((--lev) >= 0)" would make lev=0 in the last execution of this loop. I guess we need to either decrement lev elsewhere or adjust its use inside the loop (e.g.: if (lev > 0 && !(tce & 3)))
Quoted 3 lines
and we'll
not going to check !(tce &3), so even if 'tce' has a bogus value it's fine.
Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Re: [PATCH v2 1/2] ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve()
In reply to Daniel Henrique BarbozaQuoted 51 lines · Daniel Henrique Barboza
Quoted 34 lines · Matheus K. Ferst
Quoted 33 lines · Daniel Henrique Barboza
The 'taddr' variable is left unintialized, being set only inside the "while ((lev--) >= 0)" loop where we get the TCE address. The 'lev' var is an
int32_tthat is being initiliazed by theGETFIELD()macro, which returns anuint64_t.For a human reader this means that 'lev' will always be positive or zero. But some compilers may beg to differ. 'lev' being an
int32_tcan in theory be set as negative, and the "while ((lev--) >= 0)" loop might never be reached, and 'taddr' will be left unitialized. This can causephb3_error()to use 'taddr' uninitialized down below:if ((
is_write& !(tce & 2)) || ((!is_write) && !(tce & 1))) {phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);A quick way of fixing it is to use a do/while() loop. This will keep the same semanting as the existing
while()loop does and the compiler will understand that 'taddr' will be initialized at least once.Suggested-by Matheus K. Ferst <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/573
Signed-off-by Daniel Henrique Barboza <[email protected]>---
hw/pci-host/pnv_phb3.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb3.c +0
-0@@ -792,7 +792,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, sh = tbl_shift * lev + tce_shift;Quoted 15 lines
hw/pci-host/pnv_phb3.c static void pnv_phb3_translate_tve(PnvPhb3DMASpace · line 817
Quoted 13 lines
hw/pci-host/pnv_phb3.c +1
-1/* TODO: Multi-level untested */ - while ((lev--) >= 0) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3);if (dma_memory_read(&address_space_memory, taddr, &tce,
hw/pci-host/pnv_phb3.c +1
-1@@ -813,7 +813,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull; - } + } while ((lev--) >= 0);This changes the number of iterations in this loop.
Quoted 3 lines
ooofff
Quoted 1 line
We'd need "while ((--lev) >= 0)" to keep it the same, but then we would be checking "!(tce & 3)" for the last iteration. Is that a problem?
When you're at it, you could also drop the extra () around lev--. I don't think we need that and does not add to readability IMO.
I don't really know what's the original problem but if it's a while with missing init then often what you want is for (init, while clause, inc) instead but not sure that's applicable in this case so just disregard this comment if not relevant.
Regards,
BALATON Zoltan
Re: [PATCH v2 1/2] ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve()
In reply to Matheus K. FerstQuoted 33 lines · Matheus K. Ferst
Quoted 32 lines · Daniel Henrique Barboza
The 'taddr' variable is left unintialized, being set only inside the "while ((lev--) >= 0)" loop where we get the TCE address. The 'lev' var is an
int32_tthat is being initiliazed by theGETFIELD()macro, which returns anuint64_t.For a human reader this means that 'lev' will always be positive or zero. But some compilers may beg to differ. 'lev' being an
int32_tcan in theory be set as negative, and the "while ((lev--) >= 0)" loop might never be reached, and 'taddr' will be left unitialized. This can causephb3_error()to use 'taddr' uninitialized down below:if ((
is_write& !(tce & 2)) || ((!is_write) && !(tce & 1))) {phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);A quick way of fixing it is to use a do/while() loop. This will keep the same semanting as the existing
while()loop does and the compiler will understand that 'taddr' will be initialized at least once.Suggested-by Matheus K. Ferst <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/573
Signed-off-by Daniel Henrique Barboza <[email protected]>---
hw/pci-host/pnv_phb3.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb3.c +0
-0@@ -792,7 +792,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, sh = tbl_shift * lev + tce_shift;
Quoted 14 lines
hw/pci-host/pnv_phb3.c static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, · line 816
Quoted 12 lines
hw/pci-host/pnv_phb3.c +2
-2/* TODO: Multi-level untested */ - while ((lev--) >= 0) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,@@ -813,7 +813,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull; - } + } while ((lev--) >= 0);This changes the number of iterations in this loop.
ooofff
Quoted 1 line
We'd need "while ((--lev) >= 0)" to keep it the same, but then we would be checking "!(tce & 3)" for the last iteration. Is that a problem?
I don't think that's a problem because then (lev >= 0) will not be true and we'll not going to check !(tce &3), so even if 'tce' has a bogus value it's fine.
Daniel
Quoted 6 lines
Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Re: [PATCH v2 1/2] ppc/pnv: use a do-while() loop in pnv_phb3_translate_tve()
In reply to Matheus K. FerstQuoted 50 lines · Matheus K. Ferst
Quoted 49 lines · Daniel Henrique Barboza
Quoted 47 lines · Matheus K. Ferst
Quoted 39 lines · Daniel Henrique Barboza
The 'taddr' variable is left unintialized, being set only inside the "while ((lev--) >= 0)" loop where we get the TCE address. The 'lev' var is an
int32_tthat is being initiliazed by theGETFIELD()macro, which returns anuint64_t.For a human reader this means that 'lev' will always be positive or zero. But some compilers may beg to differ. 'lev' being an
int32_tcan in theory be set as negative, and the "while ((lev--) >= 0)" loop might never be reached, and 'taddr' will be left unitialized. This can causephb3_error()to use 'taddr' uninitialized down below:if ((
is_write& !(tce & 2)) || ((!is_write) && !(tce & 1))) {phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);A quick way of fixing it is to use a do/while() loop. This will keep the same semanting as the existing
while()loop does and the compiler will understand that 'taddr' will be initialized at least once.Suggested-by Matheus K. Ferst <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/573
Signed-off-by Daniel Henrique Barboza <[email protected]>---
hw/pci-host/pnv_phb3.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)hw/pci-host/pnv_phb3.c +1
-1@@ -792,7 +792,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, sh = tbl_shift * lev + tce_shift; /* TODO: Multi-level untested */ - while ((lev--) >= 0) { + do { /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce,hw/pci-host/pnv_phb3.c static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, · line 816
Quoted 5 lines
hw/pci-host/pnv_phb3.c +1
-1@@ -813,7 +813,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, } sh -= tbl_shift; base = tce & ~0xfffull; - } + } while ((lev--) >= 0);This changes the number of iterations in this loop.
Quoted 8 lines
Quoted 6 lines
ooofff
Quoted 1 line
We'd need "while ((--lev) >= 0)" to keep it the same, but then we would be checking "!(tce & 3)" for the last iteration. Is that a problem?
I don't think that's a problem because then (lev >= 0) will not be true
That holds for "while ((lev--) >= 0)", where the last iteration has "lev=-1", but "while ((--lev) >= 0)" would make lev=0 in the last execution of this loop. I guess we need to either decrement lev elsewhere or adjust its use inside the loop (e.g.: if (lev > 0 && !(tce & 3)))
Oh, I mentioned that considering that I screwed up and the decrement should be done at the start of the loop.
Changing the logic to accommodate the lev decrement at the end seems too much trouble. I'd rather keep the same original logic.
Daniel
Quoted 10 lines
Quoted 4 lines
and we'll
not going to check !(tce &3), so even if 'tce' has a bogus value it's fine.Thanks,
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>