Skip to contentSkip to conversation

hw/display/sm501: Remove unneeded increment from loop

PATCH Applied BALATON Zoltan 3 participants 3 messages Apr 5, 2023 – Apr 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display/sm501: Remove unneeded increment from loop

As Coverity points out (CID 1508621) the calculation to increment i in the fill fallback loop is ineffective as it is overwritten in next statement. This was left there by mistake from a previous version but is not needed in the current approach so remove the superfluous increment statement.

---
 hw/display/sm501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/sm501.c +1 -1
index dbabbc4339..0eecd00701 100644
@@ -901,7 +901,7 @@ static void sm501_2d_operation(SM501State *s)
             /* fallback when pixman failed or we don't want to call it */
             uint8_t *d = s->local_mem + dst_base;
             unsigned int x, y, i;
-            for (y = 0; y < height; y++, i += dst_pitch * bypp) {
+            for (y = 0; y < height; y++) {
                 i = (dst_x + (dst_y + y) * dst_pitch) * bypp;
                 for (x = 0; x < width; x++, i += bypp) {
                     stn_he_p(&d[i], bypp, color);
Signature · 1 line
2.30.8
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · BALATON Zoltan

As Coverity points out (CID 1508621) the calculation to increment i in the fill fallback loop is ineffective as it is overwritten in next statement. This was left there by mistake from a previous version but is not needed in the current approach so remove the superfluous increment statement.

---
  hw/display/sm501.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw
In reply to BALATON Zoltan
Quoted 9 lines · BALATON Zoltan

As Coverity points out (CID 1508621) the calculation to increment i in the fill fallback loop is ineffective as it is overwritten in next statement. This was left there by mistake from a previous version but is not needed in the current approach so remove the superfluous increment statement.

---

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. I'll send it out as soon as 8.1 dev window opens up.

Thanks,

Daniel

Quoted 16 lines
  hw/display/sm501.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/sm501.c +1 -1
index dbabbc4339..0eecd00701 100644
@@ -901,7 +901,7 @@ static void sm501_2d_operation(SM501State *s)
              /* fallback when pixman failed or we don't want to call it */
              uint8_t *d = s->local_mem + dst_base;
              unsigned int x, y, i;
-            for (y = 0; y < height; y++, i += dst_pitch * bypp) {
+            for (y = 0; y < height; y++) {
                  i = (dst_x + (dst_y + y) * dst_pitch) * bypp;
                  for (x = 0; x < width; x++, i += bypp) {
                      stn_he_p(&d[i], bypp, color);