diff options
author | Michael Tokarev <mjt@tls.msk.ru> | 2025-05-31 20:16:09 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2025-07-15 20:49:01 +0200 |
commit | d7bd47bf84707d21324ad079c5aa8cca16fd138f (patch) | |
tree | 879aabadae53547c6e92466354e585b452df1f88 /scripts/rust/rustc_args.py | |
parent | bf5647ae24f3a539eb40003f3d3db95b9484b978 (diff) | |
download | qemu-d7bd47bf84707d21324ad079c5aa8cca16fd138f.zip qemu-d7bd47bf84707d21324ad079c5aa8cca16fd138f.tar.gz qemu-d7bd47bf84707d21324ad079c5aa8cca16fd138f.tar.bz2 |
qemu-img: extend cvtnum() and use it in more places
cvtnum() expects input string to specify some sort of size
(optionally with KMG... suffix). However, there are a lot
of other number conversions in there (using qemu_strtol &Co),
also, not all conversions which use cvtnum, actually expects
size, - like dd count=nn.
Add bool is_size argument to cvtnum() to specify if it should
treat the argument as a size or something else, - this changes
conversion routine in use and error text.
Use the new cvtnum() in more places (like where strtol were used),
since it never return negative number in successful conversion.
When it makes sense, also specify upper or lower bounds at the
same time. This simplifies option processing in multiple places,
removing the need of local temporary variables and longer error
reporting code.
While at it, fix errors, like depth in measure must be >= 1,
while the previous code allowed it to be 0.
In a few places, change unsigned variables (like of type size_t)
to be signed instead, - to avoid the need of temporary conversion
variable. All these variables are okay to be signed, we never
assign <0 value to them except of the cases of conversion error,
where we return immediately.
While at it, remove allowed size suffixes from the error message
as it makes no sense most of the time (should be in help instead).
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20250531171609.197078-28-mjt@tls.msk.ru>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'scripts/rust/rustc_args.py')
0 files changed, 0 insertions, 0 deletions