aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2013-06-05 14:19:28 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-06-06 11:27:03 +0200
commitb6e356aa25c81d928e1c463292048d29cf25f04e (patch)
tree1fcb52cdfa72cac2c0730ac7dba6cc555abc29bc /cmd.c
parent5e00984aef7c1c317e27c0e8acf66526513c770f (diff)
qemu-io: Make cvtnum() a wrapper around strtosz_suffix()
No reason to implement the same thing multiple times. A nice side effect is that fractional numbers like 0.5M can be used in qemu-io now. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c37
1 files changed, 0 insertions, 37 deletions
diff --git a/cmd.c b/cmd.c
index 4e7579b982..214c6f757d 100644
--- a/cmd.c
+++ b/cmd.c
@@ -344,43 +344,6 @@ doneline(
#define MEGABYTES(x) ((long long)(x) << 20)
#define KILOBYTES(x) ((long long)(x) << 10)
-long long
-cvtnum(
- char *s)
-{
- long long i;
- char *sp;
- int c;
-
- i = strtoll(s, &sp, 0);
- if (i == 0 && sp == s)
- return -1LL;
- if (*sp == '\0')
- return i;
-
- if (sp[1] != '\0')
- return -1LL;
-
- c = qemu_tolower(*sp);
- switch (c) {
- default:
- return i;
- case 'k':
- return KILOBYTES(i);
- case 'm':
- return MEGABYTES(i);
- case 'g':
- return GIGABYTES(i);
- case 't':
- return TERABYTES(i);
- case 'p':
- return PETABYTES(i);
- case 'e':
- return EXABYTES(i);
- }
- return -1LL;
-}
-
#define TO_EXABYTES(x) ((x) / EXABYTES(1))
#define TO_PETABYTES(x) ((x) / PETABYTES(1))
#define TO_TERABYTES(x) ((x) / TERABYTES(1))