Patchwork [2/3] fix variable type in qemu-io.c

login
register
mail settings
Submitter jschopp@austin.ibm.com
Date July 21, 2010, 8:05 p.m.
Message ID <1279742717-10804-3-git-send-email-jschopp@austin.ibm.com>
Download mbox | patch
Permalink /patch/59499/
State New
Headers show

Comments

jschopp@austin.ibm.com - July 21, 2010, 8:05 p.m.
The variable len can get a negative return value from cvtnum,
which we check for, but which is impossible with the current
unsigned variable type.  Currently the if(len < 0) check is
pointless.  This patch fixes that.

Signed-off-by: Joel Schopp <jschopp@austin.ibm.com>
---
 qemu-io.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/qemu-io.c b/qemu-io.c
index 9adda4c..1a9c13d 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -135,7 +135,7 @@  create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
 
 	for (i = 0; i < nr_iov; i++) {
 		char *arg = argv[i];
-                uint64_t len;
+                int64_t len;
 
 		len = cvtnum(arg);
 		if (len < 0) {
@@ -144,7 +144,7 @@  create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
 		}
 
 		/* should be SIZE_T_MAX, but that doesn't exist */
-		if (len > UINT_MAX) {
+		if (len > INT_MAX) {
 			printf("too large length argument -- %s\n", arg);
 			goto fail;
 		}