qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char
@ 2011-01-17 14:56 Jes.Sorensen
  2011-01-17 14:56 ` [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simply switch statement Jes.Sorensen
  0 siblings, 1 reply; 4+ messages in thread
From: Jes.Sorensen @ 2011-01-17 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Alex.Williamson, eblake

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Bug pointed out by Erik Blake, thanks!

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 cutils.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cutils.c b/cutils.c
index 7984bc1..f97ef39 100644
--- a/cutils.c
+++ b/cutils.c
@@ -294,7 +294,8 @@ int fcntl_setfl(int fd, int flag)
 ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
 {
     ssize_t retval = -1;
-    char *endptr, c, d;
+    char *endptr;
+    unsigned char c, d;
     int mul_required = 0;
     double val, mul, integral, fraction;
 
-- 
1.7.3.4

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

* [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simply switch statement
  2011-01-17 14:56 [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char Jes.Sorensen
@ 2011-01-17 14:56 ` Jes.Sorensen
  0 siblings, 0 replies; 4+ messages in thread
From: Jes.Sorensen @ 2011-01-17 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Alex.Williamson, eblake

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 cutils.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/cutils.c b/cutils.c
index f97ef39..f7aa90c 100644
--- a/cutils.c
+++ b/cutils.c
@@ -323,16 +323,14 @@ ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
             d = c;
         }
     }
-    switch (d) {
+    switch (toupper(d)) {
     case 'B':
-    case 'b':
         mul = 1;
         if (mul_required) {
             goto fail;
         }
         break;
     case 'K':
-    case 'k':
         mul = 1 << 10;
         break;
     case 0:
@@ -340,15 +338,12 @@ ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
             goto fail;
         }
     case 'M':
-    case 'm':
         mul = 1ULL << 20;
         break;
     case 'G':
-    case 'g':
         mul = 1ULL << 30;
         break;
     case 'T':
-    case 't':
         mul = 1ULL << 40;
         break;
     default:
-- 
1.7.3.4

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

* [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char
  2011-01-17 15:14 [Qemu-devel] [PATCH v2 0/2] strtosz() cleanup Jes.Sorensen
@ 2011-01-17 15:14 ` Jes.Sorensen
  2011-01-17 19:59   ` Blue Swirl
  0 siblings, 1 reply; 4+ messages in thread
From: Jes.Sorensen @ 2011-01-17 15:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Alex.Williamson, eblake

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Bug pointed out by Eric Blake, thanks!

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 cutils.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cutils.c b/cutils.c
index 7984bc1..f97ef39 100644
--- a/cutils.c
+++ b/cutils.c
@@ -294,7 +294,8 @@ int fcntl_setfl(int fd, int flag)
 ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
 {
     ssize_t retval = -1;
-    char *endptr, c, d;
+    char *endptr;
+    unsigned char c, d;
     int mul_required = 0;
     double val, mul, integral, fraction;
 
-- 
1.7.3.4

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

* Re: [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char
  2011-01-17 15:14 ` [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char Jes.Sorensen
@ 2011-01-17 19:59   ` Blue Swirl
  0 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2011-01-17 19:59 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: kwolf, Alex.Williamson, eblake, qemu-devel

On Mon, Jan 17, 2011 at 3:14 PM,  <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>

This is exactly why we have qemu_isspace().

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

end of thread, other threads:[~2011-01-17 19:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-17 14:56 [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char Jes.Sorensen
2011-01-17 14:56 ` [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simply switch statement Jes.Sorensen
  -- strict thread matches above, loose matches on Subject: below --
2011-01-17 15:14 [Qemu-devel] [PATCH v2 0/2] strtosz() cleanup Jes.Sorensen
2011-01-17 15:14 ` [Qemu-devel] [PATCH 1/2] strtosz() use unsigned char as isspace() is not defined for signed char Jes.Sorensen
2011-01-17 19:59   ` Blue Swirl

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).