[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-commits] [qemu/qemu] 694baf: test-qemu-opts: Cover qemu_opts_parse
From: |
GitHub |
Subject: |
[Qemu-commits] [qemu/qemu] 694baf: test-qemu-opts: Cover qemu_opts_parse() |
Date: |
Sat, 25 Feb 2017 08:45:09 -0800 |
Branch: refs/heads/master
Home: https://github.com/qemu/qemu
Commit: 694baf57ae103954e2337d1fa22d1dcdfa8e2f5a
https://github.com/qemu/qemu/commit/694baf57ae103954e2337d1fa22d1dcdfa8e2f5a
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-qemu-opts.c
Log Message:
-----------
test-qemu-opts: Cover qemu_opts_parse()
The new tests demonstrate a few bugs, all clearly marked.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
[A few additional test cases squashed in, see
Message-ID: <address@hidden>]
Commit: 8ee8409eff5643c677d6e5dce6620355a89c80f8
https://github.com/qemu/qemu/commit/8ee8409eff5643c677d6e5dce6620355a89c80f8
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M util/qemu-option.c
Log Message:
-----------
option: Assert value string isn't null
Plenty of code relies on QemuOpt member @str not being null, including
qemu_opts_print(), qemu_opts_to_qdict(), and callbacks passed to
qemu_opt_foreach().
Begs the question whether it can be null. Only opt_set() creates
QemuOpt. It sets member @str to its argument @value. Passing null
for @value would plant a time bomb. Callers:
* opts_do_parse() can't pass null.
* qemu_opt_set() passes its argument @value. Callers:
- qemu_opts_from_qdict_1() can't pass null
- qemu_opts_set() passes its argument @value, but none of its
callers pass null.
- Many more outside qemu-option.c, but they shouldn't pass null,
either.
Assert member @str isn't null, so that misuse is caught right away.
Simplify parse_option_bool(), parse_option_number() and
parse_option_size() accordingly. Best viewed with whitespace changes
ignored.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 73245450b302931ad291de5d8d0f0cb5e9ca3ee6
https://github.com/qemu/qemu/commit/73245450b302931ad291de5d8d0f0cb5e9ca3ee6
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Add missing qemu_strtol()... endptr checks
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Commit: bc7c08a2c375acb7ae4d433054415588b176d34c
https://github.com/qemu/qemu/commit/bc7c08a2c375acb7ae4d433054415588b176d34c
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Clean up qemu_strtoul() result checks
Use unsigned comparisons to check the result of qemu_strtoul() and
strtoull().
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 4295f879becfbbb9f4330489311586b96915d920
https://github.com/qemu/qemu/commit/4295f879becfbbb9f4330489311586b96915d920
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M util/cutils.c
Log Message:
-----------
util/cutils: Rewrite documentation of qemu_strtol() & friends
Fixes the following documentation bugs:
* Fails to document that null @nptr is safe.
* Fails to document that we return -EINVAL when no conversion could be
performed (commit 47d4be1).
* Confuses long long with int64_t, and unsigned long long with
uint64_t.
* Claims the unsigned conversions can underflow. They can't.
While there, mark problematic assumptions that int64_t is long long,
and uint64_t is unsigned long long with FIXME comments.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Commit: b30d188677456b17c1cd68969e08ddc634cef644
https://github.com/qemu/qemu/commit/b30d188677456b17c1cd68969e08ddc634cef644
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M include/qemu/cutils.h
M qobject/qdict.c
M qtest.c
M tests/test-cutils.c
M util/cutils.c
M util/log.c
Log Message:
-----------
util/cutils: Rename qemu_strtoll(), qemu_strtoull()
The name qemu_strtoll() suggests conversion to long long, but it
actually converts to int64_t. Rename to qemu_strtoi64().
The name qemu_strtoull() suggests conversion to unsigned long long,
but it actually converts to uint64_t. Rename to qemu_strtou64().
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Commit: 717adf960933da0650d995f050d457063d591914
https://github.com/qemu/qemu/commit/717adf960933da0650d995f050d457063d591914
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M util/cutils.c
Log Message:
-----------
util/cutils: Clean up variable names around qemu_strtol()
Name same things the same, different things differently.
* qemu_strtol()'s parameter @nptr is called @p in
check_strtox_error(). Rename the latter.
* qemu_strtol()'s parameter @endptr is called @next in
check_strtox_error(). Rename the latter.
* qemu_strtol()'s variable @p is called @endptr in
check_strtox_error(). Rename both to @ep.
* qemu_strtol()'s variable @err is *negative* errno,
check_strtox_error()'s parameter @err is *positive*. Rename the
latter to @libc_errno.
Same for qemu_strtoul(), qemu_strtoi64(), qemu_strtou64(), of course.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 4baef2679e029c76707be1e2ed54bf3dd21693fe
https://github.com/qemu/qemu/commit/4baef2679e029c76707be1e2ed54bf3dd21693fe
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M util/cutils.c
Log Message:
-----------
util/cutils: Clean up control flow around qemu_strtol() a bit
Reorder check_strtox_error() to make it obvious that we always store
through a non-null @endptr.
Transform
if (some error) {
error case ...
err = value for error case;
} else {
normal case ...
err = value for normal case;
}
return err;
to
if (some error) {
error case ...
return value for error case;
}
normal case ...
return value for normal case;
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 3403e5eb884f3a74c40fe7cccc103f848c040215
https://github.com/qemu/qemu/commit/3403e5eb884f3a74c40fe7cccc103f848c040215
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-qemu-opts.c
M util/qemu-option.c
Log Message:
-----------
option: Fix to reject invalid and overflowing numbers
parse_option_number() fails to check for these errors after
strtoull(). Has always been broken. Fix that.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 019144b2866f38884fe9996d8738c50e680e3bfa
https://github.com/qemu/qemu/commit/019144b2866f38884fe9996d8738c50e680e3bfa
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Add missing qemu_strtosz()... endptr checks
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Commit: 18aec47967814f4a6261edd0130f7e9da985f65b
https://github.com/qemu/qemu/commit/18aec47967814f4a6261edd0130f7e9da985f65b
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Cover qemu_strtosz() invalid input
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: a6b4373fa257fdd7139a74187851575709a5ecb6
https://github.com/qemu/qemu/commit/a6b4373fa257fdd7139a74187851575709a5ecb6
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Cover qemu_strtosz() with trailing crap
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 0b742797aaada3a2e243175a69d542d2ed997aac
https://github.com/qemu/qemu/commit/0b742797aaada3a2e243175a69d542d2ed997aac
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Cover qemu_strtosz() around range limits
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: d2734d2629266006b0413433778474d5801c60be
https://github.com/qemu/qemu/commit/d2734d2629266006b0413433778474d5801c60be
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M include/qemu/cutils.h
M target/i386/cpu.c
M tests/test-cutils.c
M util/cutils.c
Log Message:
-----------
util/cutils: New qemu_strtosz_metric()
To parse numbers with metric suffixes, we use
qemu_strtosz_suffix_unit(nptr, &eptr, QEMU_STRTOSZ_DEFSUFFIX_B, 1000)
Capture this in a new function for legibility:
qemu_strtosz_metric(nptr, &eptr)
Replace test_qemu_strtosz_suffix_unit() by test_qemu_strtosz_metric().
Rename qemu_strtosz_suffix_unit() to do_strtosz() and give it internal
linkage.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: e591591b323772eea733de6027f5e8b50692d0ff
https://github.com/qemu/qemu/commit/e591591b323772eea733de6027f5e8b50692d0ff
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M hmp.c
M hw/misc/ivshmem.c
M include/qemu/cutils.h
M monitor.c
M tests/test-cutils.c
M util/cutils.c
Log Message:
-----------
util/cutils: Rename qemu_strtosz() to qemu_strtosz_MiB()
With qemu_strtosz(), no suffix means mebibytes. It's used rarely.
I'm going to add a similar function where no suffix means bytes.
Rename qemu_strtosz() to qemu_strtosz_MiB() to make the name
qemu_strtosz() available for the new function.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 466dea14e677555dd24465aca75d00a3537ad062
https://github.com/qemu/qemu/commit/466dea14e677555dd24465aca75d00a3537ad062
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M include/qemu/cutils.h
M qapi/opts-visitor.c
M qemu-img.c
M qemu-io-cmds.c
M tests/test-cutils.c
M util/cutils.c
Log Message:
-----------
util/cutils: New qemu_strtosz()
Most callers of qemu_strtosz_suffix() pass QEMU_STRTOSZ_DEFSUFFIX_B.
Capture the pattern in new qemu_strtosz().
Inline qemu_strtosz_suffix() into its only remaining caller.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 17f942560e54f8ee72996bc3276c697503606d7b
https://github.com/qemu/qemu/commit/17f942560e54f8ee72996bc3276c697503606d7b
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M util/cutils.c
Log Message:
-----------
util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
Writing QEMU_STRTOSZ_DEFSUFFIX_* instead of '*' gains nothing. Get
rid of these eyesores.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Commit: 753f8da0e082eac66d4c86168e14f1c55c09aa44
https://github.com/qemu/qemu/commit/753f8da0e082eac66d4c86168e14f1c55c09aa44
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Use qemu_strtosz() more often
Use qemu_strtosz() instead of qemu_strtosz_MiB() where it doesn't
really make a difference.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: dab9cc9237e3e1794053780e43787be8a07b22db
https://github.com/qemu/qemu/commit/dab9cc9237e3e1794053780e43787be8a07b22db
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-cutils.c
Log Message:
-----------
test-cutils: Drop suffix from test_qemu_strtosz_simple()
Leave testing unit suffixes to test_qemu_strtosz_units().
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 606caa0a2abdb8ff9174bb5bd5861ed2b63d1de2
https://github.com/qemu/qemu/commit/606caa0a2abdb8ff9174bb5bd5861ed2b63d1de2
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M qemu-img.c
Log Message:
-----------
qemu-img: Wrap cvtnum() around qemu_strtosz()
Cc: Kevin Wolf <address@hidden>
Cc: Max Reitz <address@hidden>
Cc: address@hidden
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: 4fcdf65ae2c00ae69f7625f26ed41f37d77b403c
https://github.com/qemu/qemu/commit/4fcdf65ae2c00ae69f7625f26ed41f37d77b403c
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M hmp.c
M hw/misc/ivshmem.c
M qapi/opts-visitor.c
M qemu-img.c
M qemu-io-cmds.c
M target/i386/cpu.c
M tests/test-cutils.c
M util/cutils.c
Log Message:
-----------
util/cutils: Let qemu_strtosz*() optionally reject trailing crap
Change the qemu_strtosz() & friends to return -EINVAL when @endptr is
null and the conversion doesn't consume the string completely.
Matches how qemu_strtol() & friends work.
Only test_qemu_strtosz_simple() passes a null @endptr. No functional
change there, because its conversion consumes the string.
Simplify callers that use @endptr only to fail when it doesn't point
to '\0' to pass a null @endptr instead.
Cc: Dr. David Alan Gilbert <address@hidden>
Cc: Eduardo Habkost <address@hidden> (maintainer:X86)
Cc: Kevin Wolf <address@hidden> (supporter:Block layer core)
Cc: Max Reitz <address@hidden> (supporter:Block layer core)
Cc: address@hidden (open list:Block layer core)
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Commit: f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7
https://github.com/qemu/qemu/commit/f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M hmp.c
M hw/misc/ivshmem.c
M include/qemu/cutils.h
M monitor.c
M qapi/opts-visitor.c
M qemu-img.c
M qemu-io-cmds.c
M target/i386/cpu.c
M tests/test-cutils.c
M util/cutils.c
Log Message:
-----------
util/cutils: Return qemu_strtosz*() error and value separately
This makes qemu_strtosz(), qemu_strtosz_mebi() and
qemu_strtosz_metric() similar to qemu_strtoi64(), except negative
values are rejected.
Cc: Dr. David Alan Gilbert <address@hidden>
Cc: Eduardo Habkost <address@hidden> (maintainer:X86)
Cc: Kevin Wolf <address@hidden> (supporter:Block layer core)
Cc: Max Reitz <address@hidden> (supporter:Block layer core)
Cc: address@hidden (open list:Block layer core)
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Commit: f46bfdbfc8f95cf65d7818ef68a801e063c40332
https://github.com/qemu/qemu/commit/f46bfdbfc8f95cf65d7818ef68a801e063c40332
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M hmp.c
M hw/misc/ivshmem.c
M include/qemu/cutils.h
M monitor.c
M qapi/opts-visitor.c
M qemu-img.c
M qemu-io-cmds.c
M target/i386/cpu.c
M tests/test-cutils.c
M util/cutils.c
Log Message:
-----------
util/cutils: Change qemu_strtosz*() from int64_t to uint64_t
This will permit its use in parse_option_size().
Cc: Dr. David Alan Gilbert <address@hidden>
Cc: Eduardo Habkost <address@hidden> (maintainer:X86)
Cc: Kevin Wolf <address@hidden> (supporter:Block layer core)
Cc: Max Reitz <address@hidden> (supporter:Block layer core)
Cc: address@hidden (open list:Block layer core)
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Commit: 75cdcd1553e74b5edc58aed23e3b2da8dabb1876
https://github.com/qemu/qemu/commit/75cdcd1553e74b5edc58aed23e3b2da8dabb1876
Author: Markus Armbruster <address@hidden>
Date: 2017-02-23 (Thu, 23 Feb 2017)
Changed paths:
M tests/test-qemu-opts.c
M util/qemu-option.c
Log Message:
-----------
option: Fix checking of sizes for overflow and trailing crap
parse_option_size()'s checking for overflow and trailing crap is
wrong. Has always been that way. qemu_strtosz() gets it right, so
use that.
This adds support for size suffixes 'P', 'E', and ignores case for all
suffixes, not just 'k'.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Commit: d7941f4eed5fe6fe4aca6e4123bd70123c9e6080
https://github.com/qemu/qemu/commit/d7941f4eed5fe6fe4aca6e4123bd70123c9e6080
Author: Peter Maydell <address@hidden>
Date: 2017-02-24 (Fri, 24 Feb 2017)
Changed paths:
M hmp.c
M hw/misc/ivshmem.c
M include/qemu/cutils.h
M monitor.c
M qapi/opts-visitor.c
M qemu-img.c
M qemu-io-cmds.c
M qobject/qdict.c
M qtest.c
M target/i386/cpu.c
M tests/test-cutils.c
M tests/test-qemu-opts.c
M util/cutils.c
M util/log.c
M util/qemu-option.c
Log Message:
-----------
Merge remote-tracking branch 'remotes/armbru/tags/pull-util-2017-02-23' into
staging
option cutils: Fix and clean up number conversions
# gpg: Signature made Thu 23 Feb 2017 19:41:17 GMT
# gpg: using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <address@hidden>"
# gpg: aka "Markus Armbruster <address@hidden>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-util-2017-02-23: (24 commits)
option: Fix checking of sizes for overflow and trailing crap
util/cutils: Change qemu_strtosz*() from int64_t to uint64_t
util/cutils: Return qemu_strtosz*() error and value separately
util/cutils: Let qemu_strtosz*() optionally reject trailing crap
qemu-img: Wrap cvtnum() around qemu_strtosz()
test-cutils: Drop suffix from test_qemu_strtosz_simple()
test-cutils: Use qemu_strtosz() more often
util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
util/cutils: New qemu_strtosz()
util/cutils: Rename qemu_strtosz() to qemu_strtosz_MiB()
util/cutils: New qemu_strtosz_metric()
test-cutils: Cover qemu_strtosz() around range limits
test-cutils: Cover qemu_strtosz() with trailing crap
test-cutils: Cover qemu_strtosz() invalid input
test-cutils: Add missing qemu_strtosz()... endptr checks
option: Fix to reject invalid and overflowing numbers
util/cutils: Clean up control flow around qemu_strtol() a bit
util/cutils: Clean up variable names around qemu_strtol()
util/cutils: Rename qemu_strtoll(), qemu_strtoull()
util/cutils: Rewrite documentation of qemu_strtol() & friends
...
Signed-off-by: Peter Maydell <address@hidden>
Compare: https://github.com/qemu/qemu/compare/6959e4523e51...d7941f4eed5f
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-commits] [qemu/qemu] 694baf: test-qemu-opts: Cover qemu_opts_parse(),
GitHub <=