diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2015-09-16 18:02:56 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-09-25 12:04:41 +0200 |
commit | 4677bb40f809394bef5fa07329dea855c0371697 (patch) | |
tree | 7e5eeddf664f1a99802d69e3acf3d8879f9e54fc | |
parent | 48bec07e8de2782fea2ea293998044bef2ab676d (diff) |
utils: rename strtosz to use qemu prefix
Not only it makes sense, but it gets rid of checkpatch warning:
WARNING: consider using qemu_strtosz in preference to strtosz
Also remove get rid of tabs to please checkpatch.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1442419377-9309-1-git-send-email-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | include/qemu-common.h | 27 | ||||
-rw-r--r-- | monitor.c | 2 | ||||
-rw-r--r-- | qapi/opts-visitor.c | 4 | ||||
-rw-r--r-- | qemu-img.c | 5 | ||||
-rw-r--r-- | qemu-io-cmds.c | 2 | ||||
-rw-r--r-- | target-i386/cpu.c | 4 | ||||
-rw-r--r-- | util/cutils.c | 25 |
7 files changed, 36 insertions, 33 deletions
diff --git a/include/qemu-common.h b/include/qemu-common.h index 01d29dd45a..0bd212b218 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -217,22 +217,23 @@ int parse_uint(const char *s, unsigned long long *value, char **endptr, int parse_uint_full(const char *s, unsigned long long *value, int base); /* - * strtosz() suffixes used to specify the default treatment of an - * argument passed to strtosz() without an explicit suffix. + * qemu_strtosz() suffixes used to specify the default treatment of an + * argument passed to qemu_strtosz() without an explicit suffix. * These should be defined using upper case characters in the range - * A-Z, as strtosz() will use qemu_toupper() on the given argument + * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument * prior to comparison. */ -#define STRTOSZ_DEFSUFFIX_EB 'E' -#define STRTOSZ_DEFSUFFIX_PB 'P' -#define STRTOSZ_DEFSUFFIX_TB 'T' -#define STRTOSZ_DEFSUFFIX_GB 'G' -#define STRTOSZ_DEFSUFFIX_MB 'M' -#define STRTOSZ_DEFSUFFIX_KB 'K' -#define STRTOSZ_DEFSUFFIX_B 'B' -int64_t strtosz(const char *nptr, char **end); -int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix); -int64_t strtosz_suffix_unit(const char *nptr, char **end, +#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' +int64_t qemu_strtosz(const char *nptr, char **end); +int64_t qemu_strtosz_suffix(const char *nptr, char **end, + const char default_suffix); +int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end, const char default_suffix, int64_t unit); #define K_BYTE (1ULL << 10) #define M_BYTE (1ULL << 20) @@ -2697,7 +2697,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, break; } } - val = strtosz(p, &end); + val = qemu_strtosz(p, &end); if (val < 0) { monitor_printf(mon, "invalid size\n"); goto fail; diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 7ae33b311e..cd10392f18 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -474,8 +474,8 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) return; } - val = strtosz_suffix(opt->str ? opt->str : "", &endptr, - STRTOSZ_DEFSUFFIX_B); + val = qemu_strtosz_suffix(opt->str ? opt->str : "", &endptr, + QEMU_STRTOSZ_DEFSUFFIX_B); if (val < 0 || *endptr) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, "a size value representible as a non-negative int64"); diff --git a/qemu-img.c b/qemu-img.c index 6ff4e852b1..7d65c0a78c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -338,7 +338,8 @@ static int img_create(int argc, char **argv) if (optind < argc) { int64_t sval; char *end; - sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B); + sval = qemu_strtosz_suffix(argv[optind++], &end, + QEMU_STRTOSZ_DEFSUFFIX_B); if (sval < 0 || *end) { if (sval == -ERANGE) { error_report("Image size must be less than 8 EiB!"); @@ -1607,7 +1608,7 @@ static int img_convert(int argc, char **argv) { int64_t sval; char *end; - sval = strtosz_suffix(optarg, &end, STRTOSZ_DEFSUFFIX_B); + sval = qemu_strtosz_suffix(optarg, &end, QEMU_STRTOSZ_DEFSUFFIX_B); if (sval < 0 || *end) { error_report("Invalid minimum zero buffer size for sparse output specified"); ret = -1; diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index d6572a8585..6e5d1e4d38 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -136,7 +136,7 @@ static char **breakline(char *input, int *count) static int64_t cvtnum(const char *s) { char *end; - return strtosz_suffix(s, &end, STRTOSZ_DEFSUFFIX_B); + return qemu_strtosz_suffix(s, &end, QEMU_STRTOSZ_DEFSUFFIX_B); } #define EXABYTES(x) ((long long)(x) << 60) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 7c52714014..d2b6bc5aa2 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1893,8 +1893,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, char *err; char num[32]; - tsc_freq = strtosz_suffix_unit(val, &err, - STRTOSZ_DEFSUFFIX_B, 1000); + tsc_freq = qemu_strtosz_suffix_unit(val, &err, + QEMU_STRTOSZ_DEFSUFFIX_B, 1000); if (tsc_freq < 0 || *err) { error_setg(errp, "bad numerical value %s", val); return; diff --git a/util/cutils.c b/util/cutils.c index ae351984d9..cfeb848d19 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -276,19 +276,19 @@ int fcntl_setfl(int fd, int flag) static int64_t suffix_mul(char suffix, int64_t unit) { switch (qemu_toupper(suffix)) { - case STRTOSZ_DEFSUFFIX_B: + case QEMU_STRTOSZ_DEFSUFFIX_B: return 1; - case STRTOSZ_DEFSUFFIX_KB: + case QEMU_STRTOSZ_DEFSUFFIX_KB: return unit; - case STRTOSZ_DEFSUFFIX_MB: + case QEMU_STRTOSZ_DEFSUFFIX_MB: return unit * unit; - case STRTOSZ_DEFSUFFIX_GB: + case QEMU_STRTOSZ_DEFSUFFIX_GB: return unit * unit * unit; - case STRTOSZ_DEFSUFFIX_TB: + case QEMU_STRTOSZ_DEFSUFFIX_TB: return unit * unit * unit * unit; - case STRTOSZ_DEFSUFFIX_PB: + case QEMU_STRTOSZ_DEFSUFFIX_PB: return unit * unit * unit * unit * unit; - case STRTOSZ_DEFSUFFIX_EB: + case QEMU_STRTOSZ_DEFSUFFIX_EB: return unit * unit * unit * unit * unit * unit; } return -1; @@ -300,7 +300,7 @@ static int64_t suffix_mul(char suffix, int64_t unit) * in *end, if not NULL. Return -ERANGE on overflow, Return -EINVAL on * other error. */ -int64_t strtosz_suffix_unit(const char *nptr, char **end, +int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end, const char default_suffix, int64_t unit) { int64_t retval = -EINVAL; @@ -343,14 +343,15 @@ fail: return retval; } -int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) +int64_t qemu_strtosz_suffix(const char *nptr, char **end, + const char default_suffix) { - return strtosz_suffix_unit(nptr, end, default_suffix, 1024); + return qemu_strtosz_suffix_unit(nptr, end, default_suffix, 1024); } -int64_t strtosz(const char *nptr, char **end) +int64_t qemu_strtosz(const char *nptr, char **end) { - return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB); + return qemu_strtosz_suffix(nptr, end, QEMU_STRTOSZ_DEFSUFFIX_MB); } /** |