diff options
| author | Michael Tokarev <mjt@tls.msk.ru> | 2025-05-31 20:15:43 +0300 |
|---|---|---|
| committer | Kevin Wolf <kwolf@redhat.com> | 2025-07-15 20:49:01 +0200 |
| commit | 1c47abc5779dfaaee303f0bff144e88dc8fb74d5 (patch) | |
| tree | 7a4172fab8cb25eb1602418215f158c174817ec8 /qemu-img.c | |
| parent | 96acc034ffffc8d7dc0cf3dfbf2996cbdbe3dde2 (diff) | |
| download | focaccia-qemu-1c47abc5779dfaaee303f0bff144e88dc8fb74d5.tar.gz focaccia-qemu-1c47abc5779dfaaee303f0bff144e88dc8fb74d5.zip | |
qemu-img: measure: convert img_size to signed, simplify handling
qemu_opt_set_number() expects signed int64_t. Use int64_t instead of uint64_t for img_size, use -1 as "unset" value instead of UINT64_MAX, and do not require temporary sval for conversion from string. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20250531171609.197078-2-mjt@tls.msk.ru> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-img.c')
| -rw-r--r-- | qemu-img.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/qemu-img.c b/qemu-img.c index e75707180d..e676602fc7 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5370,7 +5370,7 @@ static int img_measure(int argc, char **argv) QemuOpts *sn_opts = NULL; QemuOptsList *create_opts = NULL; bool image_opts = false; - uint64_t img_size = UINT64_MAX; + int64_t img_size = -1; BlockMeasureInfo *info = NULL; Error *local_err = NULL; int ret = 1; @@ -5428,16 +5428,11 @@ static int img_measure(int argc, char **argv) } break; case OPTION_SIZE: - { - int64_t sval; - - sval = cvtnum("image size", optarg); - if (sval < 0) { + img_size = cvtnum("image size", optarg); + if (img_size < 0) { goto out; } - img_size = (uint64_t)sval; - } - break; + break; } } @@ -5452,11 +5447,11 @@ static int img_measure(int argc, char **argv) error_report("--image-opts, -f, and -l require a filename argument."); goto out; } - if (filename && img_size != UINT64_MAX) { + if (filename && img_size != -1) { error_report("--size N cannot be used together with a filename."); goto out; } - if (!filename && img_size == UINT64_MAX) { + if (!filename && img_size == -1) { error_report("Either --size N or one filename must be specified."); goto out; } @@ -5504,7 +5499,7 @@ static int img_measure(int argc, char **argv) goto out; } } - if (img_size != UINT64_MAX) { + if (img_size != -1) { qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size, &error_abort); } |