* [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 v2 0/2] strtosz() cleanup
@ 2011-01-17 15:14 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
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>
Fix issue with signed char and isspace() as well as clean up switch
statement using toupper().
V2 of the patch fixes some types in the commit messages and spells
Eric correctly. My apologies for getting it wrong.
Jes Sorensen (2):
strtosz() use unsigned char as isspace() is not defined for signed
char
strtosz() use toupper() to simplify switch statement
cutils.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
--
1.7.3.4
^ permalink raw reply [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
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).