Skip to contentSkip to conversation

libxc/arm: remove useless conditional in meminit

PATCH In review Wei Liu 3 participants 4 messages Mar 14, 2018

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxc/arm: remove useless conditional in meminit

The variable named ramsize is always non-zero at that point because there is a check for zero a few lines before.

---
 tools/libxc/xc_dom_arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_dom_arm.c +1 -1
index 5b9eca6087..5acb32148e 100644
@@ -425,7 +425,7 @@ static int meminit(struct xc_dom_image *dom)
     if ( rc )
         return rc;
 
-    for ( i = 0; ramsize && i < GUEST_RAM_BANKS; i++ )
+    for ( i = 0; i < GUEST_RAM_BANKS; i++ )
     {
         uint64_t banksize = ramsize > bankmax[i] ? bankmax[i] : ramsize;
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 2 lines · Wei Liu

The variable named ramsize is always non-zero at that point because there is a check for zero a few lines before.

But this is a loop, and ramsize is modified during the loop. if bankmax[i] > ramsize, then banksize is set to ramsize, and the loop should terminate next time around.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Wei Liu
Quoted 2 lines · Wei Liu

The variable named ramsize is always non-zero at that point because there is a check for zero a few lines before.

The body of the loop has:

ramsize -= ...

We want to exit the loop either when we have no more banks left or we fulfilled all the RAM requested.

Cheers,

Quoted 20 lines
---
  tools/libxc/xc_dom_arm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_dom_arm.c +1 -1
index 5b9eca6087..5acb32148e 100644
@@ -425,7 +425,7 @@ static int meminit(struct xc_dom_image *dom)
      if ( rc )
          return rc;
 
-    for ( i = 0; ramsize && i < GUEST_RAM_BANKS; i++ )
+    for ( i = 0; i < GUEST_RAM_BANKS; i++ )
      {
          uint64_t banksize = ramsize > bankmax[i] ? bankmax[i] : ramsize;
 
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#3 lore raw
Quoted 6 lines · Julien Grall
Quoted 2 lines · Wei Liu

The variable named ramsize is always non-zero at that point because there is a check for zero a few lines before.

Quoted 6 lines

The body of the loop has:

ramsize -= ...

We want to exit the loop either when we have no more banks left or we fulfilled all the RAM requested.

Right. Please ignore this patch. -ENOCOFFEE.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel