From 26e77be17defa4d16bb2c3a3bdc1c66449cdc18f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 18 Jan 2012 10:38:43 +0100 Subject: [PATCH 49/52] cutils: Drop broken support for zero strtosz default_suffix RH-Author: Markus Armbruster Message-id: <1326883126-22053-50-git-send-email-armbru@redhat.com> Patchwork-id: 36612 O-Subject: [RHEL-6.3 PATCH qemu-kvm 49/52] cutils: Drop broken support for zero strtosz default_suffix Bugzilla: 758194 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Laszlo Ersek RH-Acked-by: Amit Shah Commit 9f9b17a4's strtosz() defaults a missing suffix to 'M', except it rejects fractions then (switch case 0). When commit d8427002 introduced strtosz_suffix(), that changed: fractions are no longer rejected, because we go to switch case 'M' on missing suffix now. Not mentioned in commit message, probably unintentional. Not worth changing back now. Because case 0 is still around, you can get the old behavior by passing a zero default_suffix to strtosz_suffix() or strtosz_suffix_unit(). Undocumented and not used. Drop. Commit d8427002 also neglected to update the function comment. Fix it up. Signed-off-by: Markus Armbruster Signed-off-by: Anthony Liguori (cherry picked from commit 8dddfb553151724a6a2110e56e8ced3213faf750) --- cutils.c | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-) Signed-off-by: Michal Novotny --- cutils.c | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cutils.c b/cutils.c index 94fa4cf..94d58da 100644 --- a/cutils.c +++ b/cutils.c @@ -305,10 +305,9 @@ void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count, /* * Convert string to bytes, allowing either B/b for bytes, K/k for KB, - * M/m for MB, G/g for GB or T/t for TB. Default without any postfix - * is MB. End pointer will be returned in *end, if not NULL. A valid - * value must be terminated by whitespace, ',' or '\0'. Return -1 on - * error. + * M/m for MB, G/g for GB or T/t for TB. End pointer will be returned + * in *end, if not NULL. A valid value must be terminated by + * whitespace, ',' or '\0'. Return -1 on error. */ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) { @@ -336,11 +335,7 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) d = c; if (qemu_isspace(c) || c == '\0' || c == ',') { c = 0; - if (default_suffix) { - d = default_suffix; - } else { - d = c; - } + d = default_suffix; } switch (qemu_toupper(d)) { case STRTOSZ_DEFSUFFIX_B: @@ -352,10 +347,6 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) case STRTOSZ_DEFSUFFIX_KB: mul = 1 << 10; break; - case 0: - if (mul_required) { - goto fail; - } case STRTOSZ_DEFSUFFIX_MB: mul = 1ULL << 20; break; -- 1.7.7.5