22.02.2024 00:16, Michael Tokarev wrote:
-static int64_t cvtnum_full(const char *name, const char *value, int64_t min,
- int64_t max)
+static int64_t cvtnum_full(const char *name, const char *value,
+ bool issize, int64_t min, int64_t max)
{
int err;
uint64_t res;
- err = qemu_strtosz(value, NULL, &res);
+ err = issize ? qemu_strtosz(value, NULL, &res) :
+ qemu_strtou64(value, NULL, 0, &res);
if (err < 0 && err != -ERANGE) {
- error_report("Invalid %s specified. You may use "
- "k, M, G, T, P or E suffixes for", name);
- error_report("kilobytes, megabytes, gigabytes, terabytes, "
- "petabytes and exabytes.");
+ if (issize) {
+ error_report("Invalid %s specified. You may use "
+ "k, M, G, T, P or E suffixes for", name);
+ error_report("kilobytes, megabytes, gigabytes, terabytes, "
+ "petabytes and exabytes.");
+ } else {
+ error_report("Invalid %s specified.", name);
+ }
I've added actual value supplied to these error messages now.
And I think the list of possible suffixes makes little sense here.
@@ -5090,7 +5060,7 @@ static int img_bitmap(const img_cmd_t *ccmd, int argc,
char **argv)
src_fmt = optarg;
break;
case 'g':
- granularity = cvtnum("granularity", optarg);
+ granularity = cvtnum("granularity", optarg, false);
Here, this is a size, so last arg should be true. In the tests (190),
we already use -g 2M. I didn't really knew what a granularity is while
converting it.
/mjt