qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Jes.Sorensen@redhat.com
Subject: [Qemu-devel] [PATCH 1/6] cutils: Drop broken support for zero strtosz default_suffix
Date: Tue, 22 Nov 2011 09:46:01 +0100	[thread overview]
Message-ID: <1321951566-11667-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1321951566-11667-1-git-send-email-armbru@redhat.com>

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 <armbru@redhat.com>
---
 cutils.c |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/cutils.c b/cutils.c
index 5d995bc..55b0596 100644
--- a/cutils.c
+++ b/cutils.c
@@ -317,10 +317,9 @@ int fcntl_setfl(int fd, int flag)
 
 /*
  * 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_unit(const char *nptr, char **end,
                             const char default_suffix, int64_t unit)
@@ -349,11 +348,7 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end,
     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:
@@ -365,10 +360,6 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end,
     case STRTOSZ_DEFSUFFIX_KB:
         mul = unit;
         break;
-    case 0:
-        if (mul_required) {
-            goto fail;
-        }
     case STRTOSZ_DEFSUFFIX_MB:
         mul = unit * unit;
         break;
-- 
1.7.6.4

  reply	other threads:[~2011-11-22  8:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22  8:46 [Qemu-devel] [PATCH 0/6] Fix strtosz users, clean up its implementation Markus Armbruster
2011-11-22  8:46 ` Markus Armbruster [this message]
2011-11-22  8:46 ` [Qemu-devel] [PATCH 2/6] vl: Tighten parsing of -numa's parameter mem Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 3/6] vl: Tighten parsing of -m argument Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 4/6] x86/cpuid: Tighten parsing of tsc_freq=FREQ Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 5/6] qemu-img: Tighten parsing of size arguments Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 6/6] cutils: Make strtosz & friends leave follow set to callers Markus Armbruster
2011-11-28 22:33 ` [Qemu-devel] [PATCH 0/6] Fix strtosz users, clean up its implementation Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321951566-11667-2-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).