Patchwork [1/2] i should be uint32_t rather than int

login
register
mail settings
Submitter Stefano Stabellini
Date Sept. 10, 2012, 6:06 p.m.
Message ID <1347300383-9089-1-git-send-email-stefano.stabellini@eu.citrix.com>
Download mbox | patch
Permalink /patch/182939/
State New
Headers show

Comments

Stefano Stabellini - Sept. 10, 2012, 6:06 p.m.
The current code compare i (int) with req->count (uint32_t) in a for
loop, risking an infinite loop if req->count is equal to UINT_MAX.

Also i is only used in comparisons or multiplications with unsigned
integers.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 i386-dm/helper2.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Patch

diff --git a/i386-dm/helper2.c b/i386-dm/helper2.c
index c6d049c..8f2a893 100644
--- a/i386-dm/helper2.c
+++ b/i386-dm/helper2.c
@@ -351,7 +351,8 @@  static inline void write_physical(uint64_t addr, unsigned long size, void *val)
 
 static void cpu_ioreq_pio(CPUState *env, ioreq_t *req)
 {
-    int i, sign;
+    uint32_t i;
+    int sign;
 
     sign = req->df ? -1 : 1;
 
@@ -386,7 +387,8 @@  static void cpu_ioreq_pio(CPUState *env, ioreq_t *req)
 
 static void cpu_ioreq_move(CPUState *env, ioreq_t *req)
 {
-    int i, sign;
+    uint32_t i;
+    int sign;
 
     sign = req->df ? -1 : 1;