* [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
2011-01-17 15:14 ` [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simplify switch statement Jes.Sorensen
2011-01-17 15:24 ` [Qemu-devel] Re: [PATCH v2 0/2] strtosz() cleanup Alex Williamson
2 siblings, 1 reply; 7+ 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] 7+ messages in thread
* [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simplify switch statement
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 15:14 ` Jes.Sorensen
2011-01-17 19:57 ` Blue Swirl
2011-01-17 15:24 ` [Qemu-devel] Re: [PATCH v2 0/2] strtosz() cleanup Alex Williamson
2 siblings, 1 reply; 7+ 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>
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] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simplify switch statement
2011-01-17 15:14 ` [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simplify switch statement Jes.Sorensen
@ 2011-01-17 19:57 ` Blue Swirl
0 siblings, 0 replies; 7+ messages in thread
From: Blue Swirl @ 2011-01-17 19:57 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>
>
> 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)) {
qemu_toupper()
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] Re: [PATCH v2 0/2] strtosz() cleanup
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 15:14 ` [Qemu-devel] [PATCH 2/2] strtosz() use toupper() to simplify switch statement Jes.Sorensen
@ 2011-01-17 15:24 ` Alex Williamson
2011-01-17 17:07 ` Alex Williamson
2 siblings, 1 reply; 7+ messages in thread
From: Alex Williamson @ 2011-01-17 15:24 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: kwolf, eblake, qemu-devel
On Mon, 2011-01-17 at 16:14 +0100, Jes.Sorensen@redhat.com wrote:
> 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(-)
>
And the modf() usage? Or using STRTOSZ_DEFSUFFIX_* in the switch? Or
avoiding the extra variable in 13/18? Thanks,
Alex
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] Re: [PATCH v2 0/2] strtosz() cleanup
2011-01-17 15:24 ` [Qemu-devel] Re: [PATCH v2 0/2] strtosz() cleanup Alex Williamson
@ 2011-01-17 17:07 ` Alex Williamson
0 siblings, 0 replies; 7+ messages in thread
From: Alex Williamson @ 2011-01-17 17:07 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: kwolf, eblake, qemu-devel
On Mon, 2011-01-17 at 08:24 -0700, Alex Williamson wrote:
> On Mon, 2011-01-17 at 16:14 +0100, Jes.Sorensen@redhat.com wrote:
> > 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(-)
> >
>
> And the modf() usage? Or using STRTOSZ_DEFSUFFIX_* in the switch? Or
> avoiding the extra variable in 13/18? Thanks,
Sorry, I'm crossing my mailing lists. These are a fine first step.
Acked-by: Alex Williamson <alex.williamson@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread