Skip to content

Commit

Permalink
util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
Browse files Browse the repository at this point in the history
Writing QEMU_STRTOSZ_DEFSUFFIX_* instead of '*' gains nothing.  Get
rid of these eyesores.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1487708048-2131-18-git-send-email-armbru@redhat.com>
  • Loading branch information
Markus Armbruster committed Feb 23, 2017
1 parent 466dea1 commit 17f9425
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions util/cutils.c
Expand Up @@ -178,30 +178,22 @@ int fcntl_setfl(int fd, int flag)
}
#endif

#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E'
#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P'
#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T'
#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G'
#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M'
#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K'
#define QEMU_STRTOSZ_DEFSUFFIX_B 'B'

static int64_t suffix_mul(char suffix, int64_t unit)
{
switch (qemu_toupper(suffix)) {
case QEMU_STRTOSZ_DEFSUFFIX_B:
case 'B':
return 1;
case QEMU_STRTOSZ_DEFSUFFIX_KB:
case 'K':
return unit;
case QEMU_STRTOSZ_DEFSUFFIX_MB:
case 'M':
return unit * unit;
case QEMU_STRTOSZ_DEFSUFFIX_GB:
case 'G':
return unit * unit * unit;
case QEMU_STRTOSZ_DEFSUFFIX_TB:
case 'T':
return unit * unit * unit * unit;
case QEMU_STRTOSZ_DEFSUFFIX_PB:
case 'P':
return unit * unit * unit * unit * unit;
case QEMU_STRTOSZ_DEFSUFFIX_EB:
case 'E':
return unit * unit * unit * unit * unit * unit;
}
return -1;
Expand Down Expand Up @@ -258,17 +250,17 @@ static int64_t do_strtosz(const char *nptr, char **end,

int64_t qemu_strtosz(const char *nptr, char **end)
{
return do_strtosz(nptr, end, QEMU_STRTOSZ_DEFSUFFIX_B, 1024);
return do_strtosz(nptr, end, 'B', 1024);
}

int64_t qemu_strtosz_MiB(const char *nptr, char **end)
{
return do_strtosz(nptr, end, QEMU_STRTOSZ_DEFSUFFIX_MB, 1024);
return do_strtosz(nptr, end, 'M', 1024);
}

int64_t qemu_strtosz_metric(const char *nptr, char **end)
{
return do_strtosz(nptr, end, QEMU_STRTOSZ_DEFSUFFIX_B, 1000);
return do_strtosz(nptr, end, 'B', 1000);
}

/**
Expand Down

0 comments on commit 17f9425

Please sign in to comment.