qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [ [PATCH 1/2] cutils:change strtosz_suffix_unit function
@ 2012-12-07  3:49 liguang
  2012-12-07  3:49 ` [Qemu-devel] [ [PATCH 2/2] qemu-img:report size overflow error message liguang
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: liguang @ 2012-12-07  3:49 UTC (permalink / raw)
  To: kwolf, stefanha, qemu-devel; +Cc: liguang

if value to be translated is larger than INT64_MAX,
this function will not be convenient for caller to
be aware of it, so change a little for this.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 cutils.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cutils.c b/cutils.c
index 4f0692f..8905b5e 100644
--- a/cutils.c
+++ b/cutils.c
@@ -219,11 +219,11 @@ static int64_t suffix_mul(char suffix, int64_t unit)
 int64_t strtosz_suffix_unit(const char *nptr, char **end,
                             const char default_suffix, int64_t unit)
 {
-    int64_t retval = -1;
+    int64_t retval = -1, mul;
     char *endptr;
     unsigned char c;
     int mul_required = 0;
-    double val, mul, integral, fraction;
+    double val, integral, fraction;
 
     errno = 0;
     val = strtod(nptr, &endptr);
@@ -246,6 +246,7 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end,
         goto fail;
     }
     if ((val * mul >= INT64_MAX) || val < 0) {
+        retval = 0;
         goto fail;
     }
     retval = val * mul;
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 1/2] cutils:change strtosz_suffix_unit function
@ 2012-12-14  4:08 liguang
  2012-12-14 12:09 ` Markus Armbruster
  0 siblings, 1 reply; 17+ messages in thread
From: liguang @ 2012-12-14  4:08 UTC (permalink / raw)
  To: kwolf, stefanha, armbru, imammedo, qemu-devel; +Cc: liguang

if value to be translated is larger than INT64_MAX,
this function will not be convenient for caller to
be aware of it, so change a little for this.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 cutils.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cutils.c b/cutils.c
index 4f0692f..da05c9e 100644
--- a/cutils.c
+++ b/cutils.c
@@ -219,7 +219,7 @@ static int64_t suffix_mul(char suffix, int64_t unit)
 int64_t strtosz_suffix_unit(const char *nptr, char **end,
                             const char default_suffix, int64_t unit)
 {
-    int64_t retval = -1;
+    int64_t retval = EINVAL;
     char *endptr;
     unsigned char c;
     int mul_required = 0;
@@ -246,6 +246,7 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end,
         goto fail;
     }
     if ((val * mul >= INT64_MAX) || val < 0) {
+        retval = ERANGE;
         goto fail;
     }
     retval = val * mul;
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-12-17  1:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07  3:49 [Qemu-devel] [ [PATCH 1/2] cutils:change strtosz_suffix_unit function liguang
2012-12-07  3:49 ` [Qemu-devel] [ [PATCH 2/2] qemu-img:report size overflow error message liguang
2012-12-11 15:11   ` Markus Armbruster
2012-12-12  0:59     ` li guang
2012-12-11  9:52 ` [Qemu-devel] [ [PATCH 1/2] cutils:change strtosz_suffix_unit function Stefan Hajnoczi
2012-12-11 15:06   ` Markus Armbruster
2012-12-12  0:58   ` li guang
2012-12-12  8:18     ` Stefan Hajnoczi
2012-12-12 10:12 ` Igor Mammedov
2012-12-13  8:03   ` Markus Armbruster
2012-12-13  9:11     ` Igor Mammedov
2012-12-13 12:09       ` Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2012-12-14  4:08 [Qemu-devel] " liguang
2012-12-14 12:09 ` Markus Armbruster
2012-12-14 13:45   ` Igor Mammedov
2012-12-17  1:09     ` li guang
2012-12-17  0:35   ` li guang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).