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>
This commit is contained in:
parent
48bec07e8d
commit
4677bb40f8
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user