tests: introduce a tree-wide code style checking facility
Subsystems (7)
v3 cover tests: introduce a tree-wide code style checking facility
Update of:
v2: https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg00595.html
The first patch gives a detailed description, but the overall goal here is to provide a code style checking facility to augment (and ideally replace) checkstyle.pl. The key conceptual differences are:
- Always applies to all code in tree, not merely patches
- Failures are always fatal, exceptions must be recorded
- Always runs as part of 'make check'
The first patch introduces the infrastructure, the remaining patches illustrate its uses for some rules where we currently have violations
- Prevent initializing an 'int' variable with 'true' / 'false'
- Look for commonly repeated words (ie the the)
- Ensure qemu/osdep.h is listed first in all .c files
- Ensure qemu/osdep.h is NOT listed in .h or .c.inc file
As noted above, it integrates with 'make check' via a new test suite called 'style', so you can invoke it individually too:
$ make check-style
changing dir to build for make "check-style"...
/usr/bin/meson test --no-rebuild -t 0 --num-processes 1 --print-errorlogs --suite style
1/3 qemu:style / int_assign_bool OK 0.28s
2/3 qemu:style / prohibit_doubled_word OK 1.78s
3/3 qemu:style / c_file_osdep_h OK 0.08s Ok: 3
Expected Fail: 0
Fail: 0
Unexpected Pass: 0
Skipped: 0
Timeout: 0Example of what it looks like when it fails:
$ make check-style
changing dir to build for make "check-style"...
make[1]: Entering directory '/home/berrange/src/virt/qemu/build'
GIT ui/keycodemapdb tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 dtc slirp
/usr/bin/meson test --no-rebuild -t 0 --num-processes 1 --print-errorlogs --suite style
1/4 qemu:style / int_assign_bool OK 0.15s
2/4 qemu:style / double_words OK 1.36s
3/4 qemu:style / osdep_h_in_source FAIL 0.10s exit status 1Quoted 1 line
Quoted 1 line
Quoted 1 line
MALLOC_PERTURB_=98
/home/berrange/src/virt/qemu/tests/style.py--config/home/berrange/src/virt/qemu/build/../tests/style.ymlcheck --ruleosdep_h_in_source
――――――――――――――――――――――――――――――――――――――――――――――― ✀ ――――――――――――――――――――――――――――――――――――――――――――――――
CHECK: osdep_h_in_source: FAIL ❌ (0.04 secs)
scripts/coverity-scan/model.c
scripts/xen-detect.c
subprojects/libvduse/libvduse.c
subprojects/libvhost-user/libvhost-user-glib.c subprojects/libvhost-user/libvhost-user.c
subprojects/libvhost-user/link-test.c
ERROR: osdep_h_in_source: all C source files must include qemu/osdep.h, as the first header ❌ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
4/4 qemu:style / osdep_h_in_header OK 0.08s
Summary of Failures:
3/4 qemu:style / osdep_h_in_source FAIL 0.10s exit status 1
Ok: 3
Expected Fail: 0
Fail: 1
Unexpected Pass: 0
Skipped: 0
Timeout: 0
If debugging new tests it can be preferrable to directly invoke it bypassing meson:
$ ./tests/style.py check
CHECK: int_assign_bool: PASS ✅ (0.09 secs)
CHECK: double_words: PASS ✅ (1.31 secs)
CHECK: osdep_h_in_source: FAIL ❌ (0.03 secs)
scripts/coverity-scan/model.c
scripts/xen-detect.c
subprojects/libvduse/libvduse.c
subprojects/libvhost-user/libvhost-user-glib.c
subprojects/libvhost-user/libvhost-user.c
subprojects/libvhost-user/link-test.c
ERROR: osdep_h_in_source: all C source files must include qemu/osdep.h, as the first header ❌
CHECK: osdep_h_in_header: PASS ✅ (0.02 secs)or to run a specific test only
$ ./tests/style.py check --rule osdep_h_in_source
CHECK: osdep_h_in_source: FAIL ❌ (0.03 secs)
scripts/coverity-scan/model.c
scripts/xen-detect.c
subprojects/libvduse/libvduse.c
subprojects/libvhost-user/libvhost-user-glib.c
subprojects/libvhost-user/libvhost-user.c
subprojects/libvhost-user/link-test.c
ERROR: osdep_h_in_source: all C source files must include qemu/osdep.h, as the first header ❌The speed of the test suite is largely driven by how quickly 'grep' / 'perl' can match through *every* file in the source tree (as reported by 'git ls-tree'). Certain regex expressions can affect this by causing lots of backtracking, but generally each test is expected to be < 1 second for the whole source tree.
Changed in v3:
- Got rid of all the makefile usage, writing the test logic in python, and defining the tests in a YAML file. Logically it is doing the same as before, but should be more easy to understand.
- Check that osdep.h is /first/, not merely present, identifying a few more violations in tree.
- Check that osdep.h is NOT in .h or .c.inc files, identifynig even more violations in tree.
- Fixed a few of the fixes in the source
Daniel P. Berrangé (9):
tests: introduce tree-wide code style checking
misc: fix mixups of bool constants with int variables tests/style: check for mixups of bool constants with int variables
misc: fix commonly doubled up words
tests/style: check for commonly doubled up words
misc: ensure qemu/osdep.h is included first in all .c files tests/style: check qemu/osdep.h is included in all .c files
misc: remove qemu/osdep.h from headers / included source files tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
backends/hostmem-epc.c | 4 +-
block/export/vduse-blk.c | 3 +-
block/linux-aio.c | 2 +-
block/qcow2-bitmap.c | 8 +-
block/vhdx-log.c | 2 +-
bsd-user/arm/signal.c | 2 +
bsd-user/arm/target_arch_cpu.c | 3 +
bsd-user/{elfcore.c => elfcore.c.inc} | 0
bsd-user/elfload.c | 2 +-
bsd-user/freebsd/os-sys.c | 2 +
bsd-user/i386/signal.c | 2 +
bsd-user/i386/target_arch_cpu.c | 3 +-
bsd-user/main.c | 3 +-
bsd-user/qemu.h | 1 -
bsd-user/x86_64/signal.c | 2 +
bsd-user/x86_64/target_arch_cpu.c | 3 +-
contrib/plugins/cache.c | 2 +-
crypto/akcipher-gcrypt.c.inc | 1 -
crypto/akcipher-nettle.c.inc | 1 -
crypto/cipher-gnutls.c.inc | 1 -
crypto/rsakey-nettle.c.inc | 1 -
crypto/rsakey.c | 1 +
crypto/rsakey.h | 1 -
disas/libvixl/vixl/invalset.h | 2 +-
docs/devel/qom.rst | 4 +-
docs/interop/live-block-operations.rst | 4 +-
docs/system/arm/cpu-features.rst | 2 +-
docs/system/devices/cxl.rst | 2 +-
docs/system/s390x/bootdevices.rst | 2 +-
docs/system/tls.rst | 2 +-
docs/tools/qemu-pr-helper.rst | 4 +-
hw/core/clock.c | 2 +-
hw/hyperv/syndbg.c | 2 +-
hw/intc/arm_gicv3_redist.c | 2 +-
hw/misc/iotkit-secctl.c | 2 +-
hw/misc/iotkit-sysctl.c | 4 +-
hw/s390x/s390-ccw.c | 2 +-
hw/usb/u2f.h | 2 +-
hw/xtensa/sim.c | 4 +-
include/hw/cxl/cxl_host.h | 1 -
include/hw/qdev-core.h | 2 +-
include/hw/tricore/triboard.h | 1 -
include/qemu/userfaultfd.h | 1 -
include/user/safe-syscall.h | 2 +-
linux-user/i386/cpu_loop.c | 2 +-
meson.build | 2 +
nbd/client.c | 8 +-
net/vmnet_int.h | 1 -
pc-bios/s390-ccw/virtio-scsi.c | 2 +-
python/Makefile | 2 +-
python/qemu/utils/__init__.py | 2 +-
qga/cutils.c | 2 +
qga/cutils.h | 2 -
target/arm/translate.c | 2 +-
target/cris/translate_v10.c.inc | 1 -
target/hexagon/hex_arch_types.h | 1 -
target/hexagon/mmvec/macros.h | 1 -
target/i386/cpu-dump.c | 3 +-
target/i386/cpu.c | 2 +-
target/riscv/pmu.h | 1 -
.../xtensa/core-dc232b/xtensa-modules.c.inc | 1 -
.../xtensa/core-dc233c/xtensa-modules.c.inc | 1 -
target/xtensa/core-de212/xtensa-modules.c.inc | 1 -
target/xtensa/core-fsf/xtensa-modules.c.inc | 1 -
.../xtensa-modules.c.inc | 1 -
tcg/i386/tcg-target.c.inc | 2 +-
tests/Makefile.include | 3 +-
tests/meson.build | 17 ++
tests/qtest/microbit-test.c | 6 +-
tests/style.py | 218 ++++++++++++++++++
tests/style.yml | 150 ++++++++++++
tools/virtiofsd/fuse_virtio.c | 2 +-
ui/spice-display.c | 4 +-
...plate.h => vnc-enc-hextile-template.c.inc} | 0
ui/vnc-enc-hextile.c | 4 +-
ui/vnc-enc-zrle.c.inc | 5 +-
...mplate.c => vnc-enc-zywrle-template.c.inc} | 1 -
util/mmap-alloc.c | 3 +-
78 files changed, 470 insertions(+), 83 deletions(-)
rename bsd-user/{elfcore.c => elfcore.c.inc} (100%)
create mode 100755 tests/style.py
create mode 100644 tests/style.yml
rename ui/{vnc-enc-hextile-template.h => vnc-enc-hextile-template.c.inc} (100%)
rename ui/{vnc-enc-zywrle-template.c => vnc-enc-zywrle-template.c.inc} (99%)Signature · 1 line
2.36.1
PATCH v3 1/9 tests: introduce tree-wide code style checking
Historically QEMU has used the 'scripts/checkpatch.pl' script to validate various style rules but there are a number of issues:
- Contributors / maintainers are reluctant to add new tests to it, nor fix existint rules, because the Perl code is much too hard to understand for most people.
- It requires the contributor to remember to run it as it is not wired into 'make check'
- While it can be told to check whole files, in practice it is usually only used to check patch diffs, because the former would flag up pages of pre-existing violations that have never been fixed
- It is said to be OK to ignore some things reported by the script, but don't record these exceptional cases anywere. Thus contributors looking at existing violations in tree are never sure whether they are intentional or historical unfixed technical debt.
- There is no distinct reporting for each type of check performed and as a consequence there is also no way to mark particular files to be skipped for particular checks
This commit aims to give us a better approach to checking many types of code style problems by introducing a flexible and simple way to define whole tree style checks.
The logic provide is inspired by the GNULIB 'top/maint.mk' file, but has been re-implemented in a simple Python script, using a YAML config file, in an attempt to make it easier to understand than the make rules.
This commit does the bare minimum introducing the basic infra:
- tests/style.py - the script for evaluating coding style rules
- tests/style.yml - the config defining the coding style rules
The concept behind the style checking is to perform simple regular expression matches across the source file content.
The key benefit of regular expression matching is that it is very fast, and can match against all types of source file in the repository, regardless of whether it is used in the current build, or the language the source is written in.
The downside, compared to a compiler based approach (eg libclang) is that it does not have semantic understanding of the code, which makes some checks difficult to implement.
As such this style matching framework is not proposed as a solution for all possible coding style rules. It is general enough that it can accomplish many useful checks, and is intended to be complimentary to any style checkers with semantic knowledge of the code like libclang, or pylint/flake8.
It would be possible to use Python's regular expression engine to perform this matching directly, it instead calls out to 'grep' (for single line matches) and 'perl' (for multiline matches). These are highly optimized regex engines, so should maximise performance. They also avoid problems with python's charset encoding causing it to throw exceptions when encountering invalid utf8, rather than continue on a best effort basis.
In terms of defining checks, a short bit of yaml is all that is required. For example, consider we want to stop people using the 'bool' type entirely in C source files. A rule in tests/style.yml would say
prohibit_bool:
files: \.c$ prohibit: \bbool\b message: do not use the bool type
The 'prohibit' rule is matched line-wise across every .c source file. If any violation is found, the contents of that line are printed, and 'message' is shown as a error message.
There are many more advanced options, which are documented in comments in the style.yml file in this commit.
The tool can be invoked directly
./tests/style.py --config test/style.yml check
Or for individual checks
./tests/style.py --config test/style.yml check --rule prohibit_bool
If a file is known to intentionally violate a style check rule this can be recorded in the style.yml and will result in it being ignored. The '--ignored' flag can be used to see ignored failures.
This is all wired up into meson, such that a 'style' test suite is defined and each individual style check is exposed as a test case.
This results in creation of a 'make check-style' target that is triggerd by 'make check' by default.
Note that the checks require the use of 'git' to detect the list of source files to search. Thus the check is skipped when not running from a git repository.
--- meson.build | 2 + tests/Makefile.include | 3 +- tests/meson.build | 17 ++++ tests/style.py | 218 +++++++++++++++++++++++++++++++++++++++++ tests/style.yml | 88 +++++++++++++++++ 5 files changed, 327 insertions(+), 1 deletion(-) create mode 100755 tests/style.py create mode 100644 tests/style.yml
meson.build +2 -0
@@ -18,6 +18,8 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') enable_modules = 'CONFIG_MODULES' in config_host enable_static = 'CONFIG_STATIC' in config_host +in_gitrepo = run_command('test', '-d', '.git', check: false).returncode() == 0 + # Allow both shared and static libraries unless --enable-static static_kwargs = enable_static ? {'static': true} : {}
tests/Makefile.include +2 -1
@@ -3,12 +3,13 @@ .PHONY: check-help check-help: @echo "Regression testing targets:" - @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest and decodetree tests" + @echo " $(MAKE) check Run block, qapi-schema, unit, style, softfloat, qtest and decodetree tests" @echo " $(MAKE) bench Run speed tests" @echo @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtest Run qtest tests" + @echo " $(MAKE) check-style Run style checks" @echo " $(MAKE) check-unit Run qobject tests" @echo " $(MAKE) check-qapi-schema Run QAPI schema tests" @echo " $(MAKE) check-block Run block tests"
tests/meson.build +17 -0
@@ -89,6 +89,23 @@ if get_option('tcg').allowed() endif endif +if in_gitrepo + stylecmd = files('style.py') + stylecfg = files('style.yml') + + checks = run_command( + stylecmd, '--config', stylecfg, 'list', + check: true) + + foreach check: checks.stdout().strip().split() + test(check, + stylecmd, + args: [ '--config', stylecfg, 'check', '--rule', check ], + workdir: meson.project_source_root(), + suite: 'style') + endforeach +endif + subdir('unit') subdir('qapi-schema') subdir('qtest')
tests/style.py new file +218 -0
218 lines not on this page · raw message
tests/style.yml new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.36.1
Re: [PATCH v3 1/9] tests: introduce tree-wide code style checking
Quoted 22 lines · Daniel P. Berrangé
Historically QEMU has used the '
scripts/checkpatch.pl' script to validate various style rules but there are a number of issues:- Contributors / maintainers are reluctant to add new tests to it, nor fix existint rules, because the Perl code is much too hard to understand for most people.
- It requires the contributor to remember to run it as it is not wired into 'make check'
- While it can be told to check whole files, in practice it is usually only used to check patch diffs, because the former would flag up pages of pre-existing violations that have never been fixed
- It is said to be OK to ignore some things reported by the script, but don't record these exceptional cases anywere. Thus contributors looking at existing violations in tree are never sure whether they are intentional or historical unfixed technical debt.
Quoted 7 lines
- There is no distinct reporting for each type of check performed and as a consequence there is also no way to mark particular files to be skipped for particular checks
This commit aims to give us a better approach to checking many types of code style problems by introducing a flexible and simple way to define whole tree style checks.
Hi; thanks for doing this rewrite into Python. I think it is definitely easier to understand.
Quoted 10 lines
The logic provide is inspired by the GNULIB '
top/maint.mk' file, but has been re-implemented in a simple Python script, using a YAML config file, in an attempt to make it easier to understand than the make rules.This commit does the bare minimum introducing the basic infra:
-
tests/style.py- the script for evaluating coding style rules
-tests/style.yml- the config defining the coding style rules
Quoted 8 lines
The concept behind the style checking is to perform simple regular expression matches across the source file content.
As such this style matching framework is not proposed as a solution for all possible coding style rules. It is general enough that it can accomplish many useful checks, and is intended to be complimentary to any style checkers with semantic knowledge of the code like libclang, or pylint/flake8.
So would the intention be that we try to obsolete checkpatch, or will we still have checkpatch because it can find some style issues that this framework cannot handle?
I think that on balance I'm in favour of this patchseries if it is part of a path where we say "we are going to drop checkpatch and replace it with X, Y and Z" (and we actually implement that path and don't just end up with another half-completed transition :-)). I'm much less in favour if it's just "we added yet another thing to the pile"...
Quoted 3 lines
If a file is known to intentionally violate a style check rule this can be recorded in the style.yml and will result in it being ignored. The '--ignored' flag can be used to see ignored failures.
Is it possible to have an individual "suppress this style check in this one place" mechanism? Dropping an entire file from the style check is certainly going to be useful for some situations, but very often I would expect there might be one place in a multi-thousand line C file where we want to violate a style rule and it would be nice not to lose the coverage on all the rest of the file as a result. Plus a whole-file suppression that lives somewhere other than the source file is going to tend to hang around for ages after we refactor/delete whatever bit of source code it was that meant we needed the suppression, whereas if the suppression is in the source file itself then you see it when you're working on that bit of code.
(All comments below here are just nits.)
Quoted 5 lines
meson.build | 2 + tests/Makefile.include | 3 +- tests/meson.build | 17 ++++ tests/style.py | 218 +++++++++++++++++++++++++++++++++++++++++ tests/style.yml | 88 +++++++++++++++++
I think this should live in scripts/, same as checkpatch.
meson.build config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') · line 21
Quoted 13 lines
5 files changed, 327 insertions(+), 1 deletion(-) create mode 100755 tests/style.py create mode 100644 tests/style.ymlmeson.build +1
-0@@ -18,6 +18,8 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') enable_modules = 'CONFIG_MODULES' in config_host enable_static = 'CONFIG_STATIC' in config_host +in_gitrepo = run_command('test', '-d', '.git', check: false).returncode() == 0
Should we use Meson's fs.is_dir() rather than running a shell?
(https://mesonbuild.com/Fs-module.html)
I spotted a couple of typos just while scrolling through, but I have not attempted to actually review the Python.
meson.build config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
Quoted 11 lines
meson.build +11
-0+# Expand a regular expression from the config file which +# can be in several formats +# +# - a plain string - used as-is as a regular expression +# - a list of strings - each element is joined with '|' +# - a dict containing +# - 'terms' - interpreted as a string / list of strings +# - 'prefix' - added to the front of the regular +# - 'prefix' - added to the end of the regular +# +# Returns: a regulare expression string
"regular"
meson.build
Quoted 11 lines
meson.build +11
-0+# Take a list of source files and filter it returning a subset +# +# If @match is non-NULL, it is expanded as a regular expression +# and the source file name is included if-and-only-if it matches +# the regex. +# +# If @nonmatch is non-NULL, it is expanded as a regular expression +# and the source file name is excluded if-and-only-if it matches +# the regex. +# +# Returns: the filtered list of soruces
"sources"
tests/style.yml line 6
Quoted 12 lines
tests/style.yml new file +6
-0@@ -0,0 +1,88 @@ +# Source code style checking rules +# +# Each top level key defines a new check, that is +# exposed as a test case in the meson 'style' test +# suite. +#
You should say somewhere here which of the half a dozen possible regular expression syntaxes is used.
tests/style.yml line 7
Quoted 1 line
tests/style.yml new file +1
-0+# Within each check, the following keys are valid
Missing trailing colon:
Quoted 5 lines
tests/style.yml new file +5
-0+# +# * files +# +# A regular expression matching filenames that +# are to be checked. Typically used to filter
tests/style.yml line 22
Quoted 10 lines
tests/style.yml new file +10
-0+# based on file extension. If omitted all files +# managed by git will be checked. +# +# * prohibit +# +# A regular expression matching content that is +# not allowed to be present in source files. Matches +# against single lines of text, unless 'multiline' +# option overrides. Either this option or 'require' +# must be present
Missing trailing '.' (here and in various others below)
tests/style.yml line 57
Quoted 7 lines
tests/style.yml new file +7
-0+# * enabled +# +# A boolean providing a way to temporarily disable +# a check. Defaults to 'true' if omitted. +# +# For all the keys above which accept a regular expression, +# one of three syntaxes are permitted
trailing colon
Quoted 21 lines
tests/style.yml new file +21
-0+# +# * string +# +# The full regular expression to match +# +# * list of strings +# +# Each element of the list will be combined with '|' +# to form the final regular expression. This is typically +# useful to keep line length short when specifying matches +# across many filenames +# +# * dict +# +# Contains the keys: +# +# * terms +# +# Either a string or list of strings interpreted as above +# +# * prefix
tests/style.yml line 88
Quoted 10 lines
tests/style.yml new file +10
-0+# +# A match added to the front of the regex. Useful when +# 'terms' is a list of strings and a common prefix is +# desired +# +# * suffix +# +# A match added to the front of the regex. Useful when +# 'terms' is a list of strings and a common prefix is +# desired
thanks
-- PMM
Re: [PATCH v3 1/9] tests: introduce tree-wide code style checking
Quoted 24 lines · Peter Maydell
Quoted 10 lines · Daniel P. Berrangé
The logic provide is inspired by the GNULIB '
top/maint.mk' file, but has been re-implemented in a simple Python script, using a YAML config file, in an attempt to make it easier to understand than the make rules.This commit does the bare minimum introducing the basic infra:
-
tests/style.py- the script for evaluating coding style rules
-tests/style.yml- the config defining the coding style rulesQuoted 8 lines
The concept behind the style checking is to perform simple regular expression matches across the source file content.
As such this style matching framework is not proposed as a solution for all possible coding style rules. It is general enough that it can accomplish many useful checks, and is intended to be complimentary to any style checkers with semantic knowledge of the code like libclang, or pylint/flake8.
So would the intention be that we try to obsolete checkpatch, or will we still have checkpatch because it can find some style issues that this framework cannot handle?
Quoted 6 lines
I think that on balance I'm in favour of this patchseries if it is part of a path where we say "we are going to drop checkpatch and replace it with X, Y and Z" (and we actually implement that path and don't just end up with another half-completed transition :-)). I'm much less in favour if it's just "we added yet another thing to the pile"...
I would certainly like to see us eventually remove checkpatch.pl because of the various downsides it has.
The caveat is that I've not actually looked in any detail at what things checkpatch.pl actually checks for. Without looking my guess-timate is that we could probably replace 90% of it without much trouble. Perhaps we'll just decide some of the checkjs in checkpatch aren't worth the burden of maintaining its usage.
Quoted 4 lines
Quoted 3 lines
If a file is known to intentionally violate a style check rule this can be recorded in the style.yml and will result in it being ignored. The '--ignored' flag can be used to see ignored failures.
Quoted 12 lines
Is it possible to have an individual "suppress this style check in this one place" mechanism? Dropping an entire file from the style check is certainly going to be useful for some situations, but very often I would expect there might be one place in a multi-thousand line C file where we want to violate a style rule and it would be nice not to lose the coverage on all the rest of the file as a result. Plus a whole-file suppression that lives somewhere other than the source file is going to tend to hang around for ages after we refactor/delete whatever bit of source code it was that meant we needed the suppression, whereas if the suppression is in the source file itself then you see it when you're working on that bit of code.
We could possibly come up with a way to put a magic comment on the end of a line (eg '// style:ignore' ), and have it applied automatically as an exclusion. A magic comment the line before is hard though, given that we're aiming to match things linewise for speed.
Quoted 7 lines
Quoted 5 lines
meson.build | 2 + tests/Makefile.include | 3 +- tests/meson.build | 17 ++++ tests/style.py | 218 +++++++++++++++++++++++++++++++++++++++++ tests/style.yml | 88 +++++++++++++++++I think this should live in
scripts/, same as checkpatch.
Sure, I don't mind.
Quoted 8 lines
Quoted 8 lines
meson.build +0
-0@@ -18,6 +18,8 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') enable_modules = 'CONFIG_MODULES' in config_host enable_static = 'CONFIG_STATIC' in config_host
Quoted 4 lines
meson.build config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') · line 21
Quoted 1 line
meson.build +1
-0+in_gitrepo = run_command('test', '-d', '.git', check: false).returncode() == 0Should we use Meson's
fs.is_dir()rather than running a shell?
(https://mesonbuild.com/Fs-module.html)
Will investigate
Quoted 7 lines
Quoted 7 lines
tests/style.yml new file +1
-0@@ -0,0 +1,88 @@ +# Source code style checking rules
Quoted 8 lines
tests/style.yml line 6
Quoted 5 lines
tests/style.yml new file +5
-0+# +# Each top level key defines a new check, that is +# exposed as a test case in the meson 'style' test +# suite. +#You should say somewhere here which of the half a dozen possible regular expression syntaxes is used.
ok
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v3 1/9] tests: introduce tree-wide code style checking
Quoted 8 lines · Daniel P. Berrangé
Quoted 8 lines
Quoted 8 lines
meson.build +0
-0@@ -18,6 +18,8 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') enable_modules = 'CONFIG_MODULES' in config_host enable_static = 'CONFIG_STATIC' in config_host
Quoted 6 lines
Quoted 4 lines
meson.build config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') · line 21
Quoted 1 line
meson.build +1
-0+in_gitrepo = run_command('test', '-d', '.git', check: false).returncode() == 0Should we use Meson's
fs.is_dir()rather than running a shell?
(https://mesonbuild.com/Fs-module.html)Will investigate
Probably not a good idea as-is; .git need not be a directory, but can also be a symlink. So 'test -e .git' is the better check (see scripts/qemu-version.sh); but if you can write an existence check in meson (instead of a directory check), then go for it.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH v3 1/9] tests: introduce tree-wide code style checking
Quoted 15 lines · Eric Blake
Quoted 13 lines · Daniel P. Berrangé
Quoted 12 lines
meson.build config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') · line 21
Quoted 9 lines
meson.build +1
-0@@ -18,6 +18,8 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak') enable_modules = 'CONFIG_MODULES' in config_host enable_static = 'CONFIG_STATIC' in config_host +in_gitrepo = run_command('test', '-d', '.git', check: false).returncode() == 0Should we use Meson's
fs.is_dir()rather than running a shell?
(https://mesonbuild.com/Fs-module.html)
Quoted 6 lines
Quoted 1 line
Will investigate
Probably not a good idea as-is; .git need not be a directory, but can also be a symlink. So 'test -e .git' is the better check (see
scripts/qemu-version.sh); but if you can write an existence check in meson (instead of a directory check), then go for it.
There is a fs.exists(), yes. I just suggested .is_dir() because the code as written here is doing a -d check, not a -e check.
-- PMM
Re: [PATCH v3 1/9] tests: introduce tree-wide code style checking
In reply to Daniel P. BerrangéQuoted 9 lines · Daniel P. Berrangé
I would certainly like to see us eventually remove checkpatch.pl because of the various downsides it has.
The caveat is that I've not actually looked in any detail at what things checkpatch.pl actually checks for. Without looking my guess-timate is that we could probably replace 90% of it without much trouble. Perhaps we'll just decide some of the checkjs in checkpatch aren't worth the burden of maintaining its usage.
I went through checkpatch, and here are the warnings I think are worth making sure we still have. I've included all the ones that look like we've added them specifically for QEMU on the basis that if we cared enough to edit checkpatch to add them then we ought to care enough to retain them.
* "Do not add expected files together with tests,
follow instructions in tests/qtest/bios-tables-test.c"
* "do not set execute permissions for source files"
* "please use python3 interpreter"
* "Author email address is mangled by the mailing list"
* syntax checks on Signed-off-by lines
* "does MAINTAINERS need updating?"
* "Invalid UTF-8"
* "trailing whitespace"
* "DOS line endings" (maybe)
* "Don't use '#' flag of printf format ('%#') in trace-events"
* "Hex numbers must be prefixed with '0x' [in trace-events]"
* line-length checks (though for a "whole codebase must pass" test we would want to set the length longer than the current "author should consider whether to wrap" value
* hard coded tabs
* the various dodgy-indentation checks
* the various space-required checks eg around operators
* misformatted block comments
* "do not use C99 // comments"
* "do not initialise globals/statics to 0 or NULL"
* "do not use assignment in if condition"
* "braces {} are necessary for all arms of this statement"
* "braces {} are necessary even for single statement blocks"
* "Use of volatile is usually wrong, please add a comment"
* "g_free(NULL) is safe this check is probably not required"
* "memory barrier without comment"
* "unnecessary cast may hide bugs, use g_new/g_renew instead"
* "consider using g_path_get_$1() in preference to g_strdup($1())"
* "use g_memdup2() instead of unsafe g_memdup()"
* "consider using qemu_$1 in preference to $1" (strto* etc)
* "use sigaction to establish signal handlers; signal is not portable"
* "please use block_init(), type_init() etc. instead of module_init()"
* "initializer for struct $1 should normally be const"
* "Error messages should not contain newlines"
* "use ctz32() instead of ffs()"
* ditto, ffsl, ffsll, bzero, getpagesize, _SC_PAGESIZE
* "Use g_assert or g_assert_not_reached" [instead of non-exiting glib asserts]
These seem to me to fall into three categories:
(1) many are easy enough to do with grep
(2) there are some checks we really do want to do on the patch, not on the codebase (most obviously things like Signed-off-by:
format checks)
(3) there are coding style checks that do need to have at least some idea of C syntax, to check brace placement, whitespace, etc
thanks
-- PMM
Re: [PATCH v3 1/9] tests: introduce tree-wide code style checking
In reply to Daniel P. BerrangéQuoted 5 lines · Daniel P. Berrangé
Historically QEMU has used the '
scripts/checkpatch.pl' script to validate various style rules but there are a number of issues:- Contributors / maintainers are reluctant to add new tests to it, nor fix existint rules, because the Perl
existing
Quoted 4 lines
The 'prohibit' rule is matched line-wise across every .c source file. If any violation is found, the contents of that line are printed, and 'message' is shown as a error message.
Can we add an exception regex as well: the prohibit rule is ignored on lines that also match the exception rule, allowing us to write a rule that would recognize magic comments on lines where we intentionally break the normal rule?
tests/style.py line 26
Quoted 13 lines
+++
b/tests/style.pytests/style.py new file +10
-0@@ -0,0 +1,218 @@ + +# Expand a regular expression from the config file which +# can be in several formats +# +# - a plain string - used as-is as a regular expression +# - a list of strings - each element is joined with '|' +# - a dict containing +# - 'terms' - interpreted as a string / list of strings +# - 'prefix' - added to the front of the regular +# - 'prefix' - added to the end of the regular
'suffix'
tests/style.py line 91
Quoted 5 lines
tests/style.py new file +5
-0+ +# Evalate the rule against the designated sources +# +# Returns: 1 if the rule failed against one or more sources, 0 otherwise +def evaluate(sources, name, rule, ignored=False):
Rather large, but looks like a nice translation of much of gnulib's maint.mk rule engine.
tests/style.py line 165
Quoted 9 lines
tests/style.py new file +9
-0+ + if len(proc.stdout) > 0: + print("\033[31;1mFAIL\033[0m ❌ (%0.2f secs)" % delta) + print(proc.stdout.strip()) + print("\033[31;1mERROR\033[0m: %s: %s ❌" % (name, rule["message"])) + return 1 + else: + print("\033[32;1mPASS\033[0m ✅ (%0.2f secs)" % delta) + return 0
Do we need to make the colorization dependent on whether output is a terminal or a specific flag is in use?
Quoted 35 lines
+++
b/tests/style.ymltests/style.yml new file +33
-0@@ -0,0 +1,88 @@ +# Source code style checking rules +# +# Each top level key defines a new check, that is +# exposed as a test case in the meson 'style' test +# suite. +# +# Within each check, the following keys are valid +# +# * files +# +# A regular expression matching filenames that +# are to be checked. Typically used to filter +# based on file extension. If omitted all files +# managed by git will be checked. +# +# * prohibit +# +# A regular expression matching content that is +# not allowed to be present in source files. Matches +# against single lines of text, unless 'multiline' +# option overrides. Either this option or 'require' +# must be present +# +# * require +# +# A regular expression matching content that must +# always be present in source files. Matches against +# single lines of text, unless 'multiline' option +# overrides. Either this option of 'prohibit' must +# be present +# +# * multiline +#
tests/style.yml line 43
Quoted 10 lines
tests/style.yml new file +10
-0+# A boolean controlling whether 'prohibit' and 'require' +# regular expressions match single lines or the entire +# file contents. Defaults to 'false', matching single +# lines at a time. +# +# * ignore +# +# A regular expression matching files to exclude from +# the check. This is typically used when certain files +# otherwise checked have known acceptable violations
s/have/that have/
Quoted 33 lines
tests/style.yml new file +33
-0+# of the test. +# +# * message +# +# A string providing a message to emit when the test +# condition fails. Must be present +# +# * enabled +# +# A boolean providing a way to temporarily disable +# a check. Defaults to 'true' if omitted. +# +# For all the keys above which accept a regular expression, +# one of three syntaxes are permitted +# +# * string +# +# The full regular expression to match +# +# * list of strings +# +# Each element of the list will be combined with '|' +# to form the final regular expression. This is typically +# useful to keep line length short when specifying matches +# across many filenames +# +# * dict +# +# Contains the keys: +# +# * terms +# +# Either a string or list of strings interpreted as above
tests/style.yml line 86
Quoted 10 lines
tests/style.yml new file +10
-0+# +# * prefix +# +# A match added to the front of the regex. Useful when +# 'terms' is a list of strings and a common prefix is +# desired +# +# * suffix +# +# A match added to the front of the regex. Useful when
s/front/end/
Review line 87
Quoted 1 line
(quoted diff) +1
-0+# 'terms' is a list of strings and a common prefix is
s/prefix/suffix/
Quoted 4 lines
(quoted diff) +1
-0+# desiredSignature · 1 line
2.36.1
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v3 2/9 misc: fix mixups of bool constants with int variables
In reply to Daniel P. Berrangé--- block/vhdx-log.c | 2 +- hw/xtensa/sim.c | 4 ++-- nbd/client.c | 8 +++++--- target/i386/cpu-dump.c | 3 ++- ui/spice-display.c | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-)
block/vhdx-log.c +1 -1
@@ -215,7 +215,7 @@ exit:static bool vhdx_log_hdr_is_valid (VHDXLogEntries *log,VHDXLogEntryHeader *hdr,BDRVVHDXState *s) { -int valid = false; +bool valid = false;if (hdr->signature !=VHDX_LOG_SIGNATURE ) { goto exit;
hw/xtensa/sim.c +2 -2
@@ -97,9 +97,9 @@ void xtensa_sim_load_kernel(XtensaCPU *cpu, MachineState *machine) {const char *kernel_filename = machine->kernel_filename;#if TARGET_BIG_ENDIAN -int big_endian = true; +int big_endian =1 ;#else -int big_endian = false; +int big_endian =0 ;#endif if (kernel_filename) {
nbd/client.c +5 -3
@@ -832,8 +832,8 @@ static int nbd_list_meta_contexts(QIOChannel *ioc, Error **errp) {int ret; -int seen_any = false; -int seen_qemu = false; +bool seen_any = false; +bool seen_qemu = false;if (nbd_send_meta_query (ioc,NBD_OPT_LIST_META_CONTEXT , info->name,NULL , errp) <0 ) {
@@ -863,7 +863,9 @@ static int nbd_list_meta_contexts(QIOChannel *ioc,return ret; } seen_any = true; - seen_qemu |=strstart (context,"qemu:" ,NULL ); +if (strstart (context,"qemu:" ,NULL )) { + seen_qemu = true; + } info->contexts = g_renew(char *, info->contexts, ++info->n_contexts); info->contexts[info->n_contexts -1 ] = context; }
target/i386/cpu-dump.c +2 -1
@@ -275,7 +275,8 @@ static void dump_apic_icr(APICCommonState *s, CPUX86State *env)static void dump_apic_interrupt (const char *name,uint32_t *ireg_tab,uint32_t *tmr_tab) { -int i, empty = true; +int i; +bool empty = true;qemu_printf ("%s\t " , name);for (i =0 ; i <256 ; i++) {
ui/spice-display.c +2 -2
@@ -541,14 +541,14 @@ static int interface_get_command(QXLInstance *sin, QXLCommandExt *ext) {SimpleSpiceDisplay *ssd =container_of (sin, SimpleSpiceDisplay, qxl);SimpleSpiceUpdate *update; -int ret = false; +int ret =0 ;qemu_mutex_lock (&ssd->lock); update =QTAILQ_FIRST (&ssd->updates);if (update !=NULL ) {QTAILQ_REMOVE (&ssd->updates, update, next); *ext = update->ext; - ret = true; + ret =1 ; }qemu_mutex_unlock (&ssd->lock);
Signature · 1 line
2.36.1
Re: [PATCH v3 2/9] misc: fix mixups of bool constants with int variables
Quoted 9 lines · Daniel P. Berrangé
Signed-off-by Daniel P. Berrangé <[email protected]>--- block/vhdx-log.c | 2 +- hw/xtensa/sim.c | 4 ++-- nbd/client.c | 8 +++++--- target/i386/cpu-dump.c | 3 ++- ui/spice-display.c | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-)
thanks
-- PMM
PATCH v3 3/9 tests/style: check for mixups of bool constants with int variables
In reply to Daniel P. BerrangéThe 'true' and 'false' constants should only ever be used with the 'bool' type, never 'int'.
--- tests/style.yml | 5 +++++ 1 file changed, 5 insertions(+)
tests/style.yml +5 -0
@@ -86,3 +86,8 @@ # A match added to the front of the regex. Useful when # 'terms' is a list of strings and a common prefix is # desired + +int_assign_bool: + files: \.c$ + prohibit: \<int\>.*= *(true|false)\b + message: use bool type for boolean values
Signature · 1 line
2.36.1
Re: [PATCH v3 3/9] tests/style: check for mixups of bool constants with int variables
Quoted 13 lines · Daniel P. Berrangé
The 'true' and 'false' constants should only ever be used with the 'bool' type, never 'int'.
Signed-off-by Daniel P. Berrangé <[email protected]>--- tests/style.yml | 5 +++++ 1 file changed, 5 insertions(+)tests/style.yml +0
-0
tests/style.yml line 91
Quoted 6 lines
tests/style.yml +3
-0@@ -86,3 +86,8 @@ # A match added to the front of the regex. Useful when # 'terms' is a list of strings and a common prefix is # desired + +int_assign_bool: + files: \.c$
Why not check .c.inc and .h (for static inlined func)?
Regardless:
Quoted 2 lines
tests/style.yml +2
-0+ prohibit: \<int\>.*= *(true|false)\b + message: use bool type for boolean values
Re: [PATCH v3 3/9] tests/style: check for mixups of bool constants with int variables
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Daniel P. Berrangé
The 'true' and 'false' constants should only ever be used with the 'bool' type, never 'int'.
Signed-off-by Daniel P. Berrangé <[email protected]>--- tests/style.yml | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 13 lines
tests/style.yml line 91
Quoted 11 lines
tests/style.yml +3
-0@@ -86,3 +86,8 @@ # A match added to the front of the regex. Useful when # 'terms' is a list of strings and a common prefix is # desired + +int_assign_bool: + files: \.c$Why not check .c.inc and .h (for static inlined func)?
Yes, we should.
Quoted 6 lines
Regardless:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 2 lines
tests/style.yml +2
-0+ prohibit: \<int\>.*= *(true|false)\b + message: use bool type for boolean values
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v3 4/9 misc: fix commonly doubled up words
In reply to Daniel P. Berrangé--- block/linux-aio.c | 2 +- block/qcow2-bitmap.c | 8 ++++---- contrib/plugins/cache.c | 2 +- disas/libvixl/vixl/invalset.h | 2 +- docs/devel/qom.rst | 4 ++-- docs/interop/live-block-operations.rst | 4 ++-- docs/system/arm/cpu-features.rst | 2 +- docs/system/devices/cxl.rst | 2 +- docs/system/s390x/bootdevices.rst | 2 +- docs/system/tls.rst | 2 +- docs/tools/qemu-pr-helper.rst | 4 ++-- hw/core/clock.c | 2 +- hw/intc/arm_gicv3_redist.c | 2 +- hw/misc/iotkit-secctl.c | 2 +- hw/misc/iotkit-sysctl.c | 4 ++-- hw/s390x/s390-ccw.c | 2 +- hw/usb/u2f.h | 2 +- include/hw/qdev-core.h | 2 +- include/user/safe-syscall.h | 2 +- linux-user/i386/cpu_loop.c | 2 +- pc-bios/s390-ccw/virtio-scsi.c | 2 +- python/Makefile | 2 +- python/qemu/utils/__init__.py | 2 +- target/arm/translate.c | 2 +- target/i386/cpu.c | 2 +- tcg/i386/tcg-target.c.inc | 2 +- tests/qtest/microbit-test.c | 6 +++--- tools/virtiofsd/fuse_virtio.c | 2 +- 28 files changed, 37 insertions(+), 37 deletions(-)
block/linux-aio.c +1 -1
@@ -461,7 +461,7 @@ LinuxAioState *laio_init(Error **errp) s =g_malloc0 (sizeof (*s)); rc =event_notifier_init (&s->e, false);if (rc <0 ) { -error_setg_errno (errp, -rc,"failed to to initialize event notifier" ); +error_setg_errno (errp, -rc,"failed to initialize event notifier" ); goto out_free_state; }
block/qcow2-bitmap.c +4 -4
@@ -787,10 +787,10 @@ static int bitmap_list_store(BlockDriverState *bs, Qcow2BitmapList *bm_list, } } -/* Actually, even in in-place case ignoring QCOW2_OL_BITMAP_DIRECTORY is not -* necessary, because we drop QCOW2_AUTOCLEAR_BITMAPS when updating bitmap -* directory in-place (actually, turn-off the extension), which is checked -* in qcow2_check_metadata_overlap() */ +/* Actually, even in the in-place case ignoring QCOW2_OL_BITMAP_DIRECTORY +* is not necessary, because we drop QCOW2_AUTOCLEAR_BITMAPS when updating +* bitmap directory in-place (actually, turn-off the extension), which is +* checked in qcow2_check_metadata_overlap() */ ret =qcow2_pre_write_overlap_check ( bs, in_place ?QCOW2_OL_BITMAP_DIRECTORY :0 , dir_offset, dir_size, false);
contrib/plugins/cache.c +1 -1
@@ -38,7 +38,7 @@ enum EvictionPolicy policy;* put in any of the blocks inside the set. The number of block per set is * called the associativity (assoc). * -* Each block contains the the stored tag and a valid bit. Since this is not +* Each block contains the stored tag and a valid bit. Since this is not * a functional simulator, the data itself is not stored. We only identify * whether a block is in the cache or not by searching for its tag. *
disas/libvixl/vixl/invalset.h +1 -1
@@ -102,7 +102,7 @@ template<TEMPLATE_INVALSET_P_DECL> class InvalSet { size_t size() const; // Returns true if no elements are stored in the set. - // Note that this does not mean the the backing storage is empty: it can still + // Note that this does not mean the backing storage is empty: it can still // contain invalid elements. bool empty() const;
docs/devel/qom.rst +2 -2
@@ -372,8 +372,8 @@ This accepts an array of interface type names. { TYPE_USER_CREATABLE }, { NULL }) -If the type is not intended to be instantiated, then then -the OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead: +If the type is not intended to be instantiated, then the +OBJECT_DEFINE_ABSTRACT_TYPE() macro can be used instead: .. code-block:: c :caption: Defining a simple abstract type
docs/interop/live-block-operations.rst +2 -2
@@ -53,7 +53,7 @@ files in a disk image backing chain: (1) Directional: 'base' and 'top'. Given the simple disk image chain above, image [A] can be referred to as 'base', and image [B] as - 'top'. (This terminology can be seen in in QAPI schema file, + 'top'. (This terminology can be seen in the QAPI schema file, block-core.json.) (2) Relational: 'backing file' and 'overlay'. Again, taking the same
@@ -825,7 +825,7 @@ entire disk image chain, to a target, using ``blockdev-mirror`` would be: job ready to be completed (5) Gracefully complete the 'mirror' block device job, and notice the - the event ``BLOCK_JOB_COMPLETED`` + event ``BLOCK_JOB_COMPLETED`` (6) Shutdown the guest by issuing the QMP ``quit`` command so that caches are flushed
docs/system/arm/cpu-features.rst +1 -1
@@ -284,7 +284,7 @@ SVE CPU Property Parsing Semantics CPU Property Dependencies and Constraints"). 4) If one or more vector lengths have been explicitly enabled and at - at least one of the dependency lengths of the maximum enabled length + least one of the dependency lengths of the maximum enabled length has been explicitly disabled, then an error is generated (see constraint (2) of "SVE CPU Property Dependencies and Constraints").
docs/system/devices/cxl.rst +1 -1
@@ -15,7 +15,7 @@ with CXL Host Bridges, which have CXL Root Ports which may be directly attached to CXL or PCI End Points. Alternatively there may be CXL Switches with CXL and PCI Endpoints attached below them. In many cases additional control and capabilities are exposed via PCI Express interfaces. -This sharing of interfaces and hence emulation code is is reflected +This sharing of interfaces and hence emulation code is reflected in how the devices are emulated in QEMU. In most cases the various CXL elements are built upon an equivalent PCIe devices.
docs/system/s390x/bootdevices.rst +1 -1
@@ -65,7 +65,7 @@ you can specify it via the ``-global s390-ipl.netboot_fw=filename`` command line option. The ``bootindex`` property is especially important for booting via the network. -If you don't specify the the ``bootindex`` property here, the network bootloader +If you don't specify the ``bootindex`` property here, the network bootloader firmware code won't get loaded into the guest memory so that the network boot will fail. For a successful network boot, try something like this::
docs/system/tls.rst +1 -1
@@ -182,7 +182,7 @@ certificates. --template client-hostNNN.info \ --outfile client-hostNNN-cert.pem -The subject alt name extension data is not required for clients, so the +The subject alt name extension data is not required for clients, so the ``dns_name`` and ``ip_address`` fields are not included. The ``tls_www_client`` keyword is the key purpose extension to indicate this certificate is intended for usage in a web client. Although QEMU network
docs/tools/qemu-pr-helper.rst +2 -2
@@ -21,8 +21,8 @@ programs because incorrect usage can disrupt regular operation of the storage fabric. QEMU's SCSI passthrough devices ``scsi-block`` and ``scsi-generic`` support passing guest persistent reservation requests to a privileged external helper program. :program:`qemu-pr-helper` -is that external helper; it creates a socket which QEMU can -connect to to communicate with it. +is that external helper; it creates a listener socket which will +accept incoming connections for communication with QEMU. If you want to run VMs in a setup like this, this helper should be started as a system service, and you should read the QEMU manual
hw/core/clock.c +1 -1
@@ -68,7 +68,7 @@ static uint64_t clock_get_child_period(Clock *clk) {/* * Return the period to be used for child clocks, which is the parent -* clock period adjusted for for multiplier and divider effects. +* clock period adjusted for multiplier and divider effects. */ return muldiv64 (clk->period, clk->multiplier, clk->divider); }
hw/intc/arm_gicv3_redist.c +1 -1
@@ -492,7 +492,7 @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset,return MEMTX_OK ;case GICR_WAKER :/* Only the ProcessorSleep bit is writable. When the guest sets -* it it requests that we transition the channel between the +* it, it requests that we transition the channel between the * redistributor and the cpu interface to quiescent, and that * we set the ChildrenAsleep bit once the inteface has reached the * quiescent state.
hw/misc/iotkit-secctl.c +1 -1
@@ -114,7 +114,7 @@ static const uint8_t iotkit_secctl_ns_sse300_idregs[] = {* AHB expansion, APB expansion) are all set up so that they are * in 16-aligned blocks so offsets 0xN0, 0xN4, 0xN8, 0xNC are PPCs * 0, 1, 2, 3 of that type, so we can convert a register address offset -* into an an index into a PPC array easily. +* into an index into a PPC array easily. */ static inline int offset_to_ppc_idx (uint32_t offset) {
hw/misc/iotkit-sysctl.c +2 -2
@@ -237,7 +237,7 @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset, r = s->ewctrl;break ;case ARMSSE_SSE300 : -/* In SSE300 this offset is is NMI_ENABLE */ +/* In SSE300 this offset is NMI_ENABLE */ r = s->nmi_enable;break ;default :
@@ -555,7 +555,7 @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset, s->ewctrl = value;break ;case ARMSSE_SSE300 : -/* In SSE300 this offset is is NMI_ENABLE */ +/* In SSE300 this offset is NMI_ENABLE */ qemu_log_mask (LOG_UNIMP ,"IoTKit SysCtl NMI_ENABLE unimplemented\n" ); s->nmi_enable = value;break ;
hw/s390x/s390-ccw.c +1 -1
@@ -57,7 +57,7 @@ IOInstEnding s390_ccw_store(SubchDev *sch)/* * This code is called for both virtual and passthrough devices, -* but only applies to to the latter. This ugly check makes that +* but only applies to the latter. This ugly check makes that * distinction for us. */ if (object_dynamic_cast (OBJECT (sch->driver_data),TYPE_S390_CCW )) {
hw/usb/u2f.h +1 -1
@@ -74,7 +74,7 @@ typedef struct U2FKeyState {/* * API to be used by the U2F key device variants (i.e. hw/u2f-*.c) -* to interact with the the U2F key base device (i.e. hw/u2f.c) +* to interact with the U2F key base device (i.e. hw/u2f.c) */ void u2f_send_to_guest (U2FKeyState *key,const uint8_t packet[U2FHID_PACKET_SIZE ]);
include/hw/qdev-core.h +1 -1
@@ -386,7 +386,7 @@ bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp);* * - unrealize any child buses by calling qbus_unrealize() * (this will recursively unrealize any devices on those buses) -* - call the the unrealize method of @dev +* - call the unrealize method of @dev * * The device can then be freed by causing its reference count to go * to zero.
include/user/safe-syscall.h +1 -1
@@ -70,7 +70,7 @@* If the host libc is used then the implementation will appear to work * most of the time, but there will be a race condition where a * signal could arrive just before we make the host syscall inside libc, -* and then then guest syscall will not correctly be interrupted. +* and then the guest syscall will not correctly be interrupted. * Instead the implementation of the guest syscall can use the safe_syscall * function but otherwise just return the result or errno in the usual * way; the main loop code will take care of restarting the syscall
linux-user/i386/cpu_loop.c +1 -1
@@ -137,7 +137,7 @@ static void emulate_vsyscall(CPUX86State *env) }/* -* Validate the the pointer arguments. +* Validate the pointer arguments. */ switch (syscall) {case TARGET_NR_gettimeofday:
pc-bios/s390-ccw/virtio-scsi.c +1 -1
@@ -195,7 +195,7 @@ static bool scsi_read_capacity(VDev *vdev,/* virtio-scsi routines */ /* -* Tries to locate a SCSI device and and adds the information for the found +* Tries to locate a SCSI device and adds the information for the found * device to the vdev->scsi_device structure. * Returns 0 if SCSI device could be located, or a error code < 0 otherwise */
python/Makefile +1 -1
@@ -29,7 +29,7 @@ help: @echo " Performs no environment setup of any kind." @echo "" @echo "make develop:" - @echo " Install deps needed for for 'make check'," + @echo " Install deps needed for 'make check'," @echo " and install the qemu package in editable mode." @echo " (Can be used in or outside of a venv.)" @echo ""
python/qemu/utils/__init__.py +1 -1
@@ -79,7 +79,7 @@ def add_visual_margin( :param content: The text to wrap and decorate. :param width: The number of columns to use, including for the decoration - itself. The default (None) uses the the available width of the + itself. The default (None) uses the available width of the current terminal, or a fallback of 72 lines. A negative number subtracts a fixed-width from the default size. The default obeys the COLUMNS environment variable, if set.
target/arm/translate.c +1 -1
@@ -8056,7 +8056,7 @@ static TCGv_i32 op_addr_block_pre(DisasContext *s, arg_ldst_block *a, int n)* If the writeback is incrementing SP rather than * decrementing it, and the initial SP is below the * stack limit but the final written-back SP would -* be above, then then we must not perform any memory +* be above, then we must not perform any memory * accesses, but it is IMPDEF whether we generate * an exception. We choose to do so in this case. * At this point 'addr' is the lowest address, so
target/i386/cpu.c +1 -1
@@ -3632,7 +3632,7 @@ static const X86CPUDefinition builtin_x86_defs[] = { CPUID_7_0_EDX_CORE_CAPABILITY, .features[FEAT_CORE_CAPABILITY ] = MSR_CORE_CAP_SPLIT_LOCK_DETECT, -/* XSAVES is is added in version 3 */ +/* XSAVES is added in version 3 */ .features[FEAT_XSAVE ] =CPUID_XSAVE_XSAVEOPT |CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1,
tcg/i386/tcg-target.c.inc +1 -1
@@ -1652,7 +1652,7 @@ static void tcg_out_branch(TCGContext *s, int call, const tcg_insn_unit *dest) } else { /* rip-relative addressing into the constant pool. This is 6 + 8 = 14 bytes, as compared to using an - an immediate load 10 + 6 = 16 bytes, plus we may + immediate load 10 + 6 = 16 bytes, plus we may be able to re-use the pool constant for more calls. */ tcg_out_opc(s, OPC_GRP5, 0, 0, 0); tcg_out8(s, (call ? EXT5_CALLN_Ev : EXT5_JMPN_Ev) << 3 | 5);
tests/qtest/microbit-test.c +3 -3
@@ -447,11 +447,11 @@ static void test_nrf51_timer(void)timer_set_bitmode (qts,NRF51_TIMER_WIDTH_16 );/* 16 MHz Timer */ timer_set_prescaler (qts,0 ); -/* Swept over in first step */ +/* Swept over, during the first step */ timer_set_cc (qts,0 ,2 ); -/* Barely miss on first step */ +/* Barely miss, after the second step */ timer_set_cc (qts,1 ,162 ); -/* Spot on on third step */ +/* Spot on, after the third step */ timer_set_cc (qts,2 ,480 );timer_assert_events (qts,0 ,0 ,0 ,0 );
tools/virtiofsd/fuse_virtio.c +1 -1
@@ -379,7 +379,7 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,copy_iov (iov, count, in_sg, in_num, iov_len);/* -* Build a copy of the the in_sg iov so we can skip bits in it, +* Build a copy of the in_sg iov so we can skip bits in it, * including changing the offsets */ in_sg_cpy = g_new(struct iovec, in_num);
Signature · 1 line
2.36.1
Re: [PATCH v3 4/9] misc: fix commonly doubled up words
Quoted 2 lines · Daniel P. Berrangé
Signed-off-by Daniel P. Berrangé <[email protected]>
thanks
-- PMM
PATCH v3 5/9 tests/style: check for commonly doubled up words
In reply to Daniel P. BerrangéThis style check looks for cases where the words
the then in an on if is it but for or at and do to
are repeated in a sentence. It uses a multi-line match to catch the especially common mistake in docs where the last word on a line is repeated as the first word of the next line.
There are inevitably be some false positives with this check, for example, some docs data tables have the same word in adjacent columns.
There are a few different ways to express this text as a regex which have wildly different execution time. This impl was carefully chosen to attempt to minimize matching time.
--- tests/style.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
tests/style.yml +30 -0
@@ -91,3 +91,33 @@ int_assign_bool: files: \.c$ prohibit: \<int\>.*= *(true|false)\b message: use bool type for boolean values + +double_words: + multiline: true + prohibit: + terms: + - the\s+the + - then\s+then + - in\s+in + - an\s+an + - on\s+on + - if\s+if + - is\s+is + - it\s+it + - but\s+but + - for\s+for + - or\s+or + - at\s+at + - and\s+and + - do\s+do + - to\s+to + - can\s+can + prefix: \b(?<!=|@|'|") + suffix: \b(?!=|@|'|") + message: doubled words + ignore: + - disas/sparc\.c + - pc-bios/ + - qemu-options\.hx + - scripts/checkpatch\.pl + - tests/qtest/arm-cpu-features\.c
Signature · 1 line
2.36.1
PATCH v3 6/9 misc: ensure qemu/osdep.h is included first in all .c files
In reply to Daniel P. BerrangéA few files relied on qemu/osdep.h being included via a common header. Others didn't need it because they were actually an included file, so ought to have been named '.c.inc'. Finally some didn't have it as the first header included.
---
backends/hostmem-epc.c | 4 +++-
block/export/vduse-blk.c | 3 ++-
bsd-user/arm/signal.c | 2 ++
bsd-user/arm/target_arch_cpu.c | 3 +++
bsd-user/{elfcore.c => elfcore.c.inc} | 0
bsd-user/elfload.c | 2 +-
bsd-user/freebsd/os-sys.c | 2 ++
bsd-user/i386/signal.c | 2 ++
bsd-user/i386/target_arch_cpu.c | 3 ++-
bsd-user/main.c | 3 ++-
bsd-user/qemu.h | 1 -
bsd-user/x86_64/signal.c | 2 ++
bsd-user/x86_64/target_arch_cpu.c | 3 ++-
crypto/rsakey.c | 1 +
hw/hyperv/syndbg.c | 2 +-
qga/cutils.c | 2 ++
...-enc-hextile-template.h => vnc-enc-hextile-template.c.inc} | 0
ui/vnc-enc-hextile.c | 4 ++--
ui/vnc-enc-zrle.c.inc | 2 +-
...nc-enc-zywrle-template.c => vnc-enc-zywrle-template.c.inc} | 0
util/mmap-alloc.c | 3 ++-
21 files changed, 32 insertions(+), 12 deletions(-)
rename bsd-user/{elfcore.c => elfcore.c.inc} (100%)
rename ui/{vnc-enc-hextile-template.h => vnc-enc-hextile-template.c.inc} (100%)
rename ui/{vnc-enc-zywrle-template.c => vnc-enc-zywrle-template.c.inc} (100%)backends/hostmem-epc.c +3 -1
@@ -9,9 +9,11 @@* This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ -#include <sys/ioctl.h> #include "qemu/osdep.h" + +#include <sys/ioctl.h> +#include "qom/object_interfaces.h" #include "qapi/error.h" #include "sysemu/hostmem.h"
block/export/vduse-blk.c +2 -1
@@ -10,9 +10,10 @@* later. See the COPYING file in the top-level directory. */ +#include "qemu/osdep.h" +#include <sys/eventfd.h> -#include "qemu/osdep.h" #include "qapi/error.h" #include "block/export.h" #include "qemu/error-report.h"
bsd-user/arm/signal.c +2 -0
@@ -17,6 +17,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include "qemu.h" /*
bsd-user/arm/target_arch_cpu.c +3 -0
@@ -16,6 +16,9 @@* You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +#include "qemu/osdep.h" +#include "target_arch.h" void target_cpu_set_tls (CPUARMState *env,target_ulong newtls)
bsd-user/elfcore.c.inc renamed from bsd-user/elfcore.c +0 -0
bsd-user/elfload.c +1 -1
@@ -121,7 +121,7 @@ static void bswap_note(struct elf_note *en) { }#endif /* ! BSWAP_NEEDED */ -#include "elfcore.c" +#include "elfcore.c.inc" /* * 'copy_elf_strings()' copies argument/envelope strings from user
bsd-user/freebsd/os-sys.c +2 -0
@@ -17,6 +17,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include "qemu.h" #include "target_arch_sysarch.h"
bsd-user/i386/signal.c +2 -0
@@ -17,6 +17,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include "qemu.h" /*
bsd-user/i386/target_arch_cpu.c +2 -1
@@ -17,9 +17,10 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include <sys/types.h> -#include "qemu/osdep.h" #include "cpu.h" #include "qemu.h" #include "qemu/timer.h"
bsd-user/main.c +2 -1
@@ -18,12 +18,13 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> #include <sys/sysctl.h> -#include "qemu/osdep.h" #include "qemu/help-texts.h" #include "qemu/units.h" #include "qemu/accel.h"
bsd-user/qemu.h +0 -1
@@ -17,7 +17,6 @@#ifndef QEMU_H #define QEMU_H -#include "qemu/osdep.h" #include "cpu.h" #include "qemu/units.h" #include "exec/cpu_ldst.h"
bsd-user/x86_64/signal.c +2 -0
@@ -16,6 +16,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include "qemu.h" /*
bsd-user/x86_64/target_arch_cpu.c +2 -1
@@ -17,9 +17,10 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" +#include <sys/types.h> -#include "qemu/osdep.h" #include "cpu.h" #include "qemu.h" #include "qemu/timer.h"
crypto/rsakey.c +1 -0
@@ -19,6 +19,7 @@* */ +#include "qemu/osdep.h" #include "rsakey.h" void qcrypto_akcipher_rsakey_free (QCryptoAkCipherRSAKey *rsa_key)
hw/hyperv/syndbg.c +1 -1
@@ -5,8 +5,8 @@* See the COPYING file in the top-level directory. */ -#include "qemu/ctype.h" #include "qemu/osdep.h" +#include "qemu/ctype.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h"
qga/cutils.c +2 -0
@@ -2,6 +2,8 @@* This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ + +#include "qemu/osdep.h" #include "cutils.h" #include "qapi/error.h"
ui/vnc-enc-hextile-template.c.inc renamed from ui/vnc-enc-hextile-template.h +0 -0
ui/vnc-enc-hextile.c +2 -2
@@ -34,12 +34,12 @@ static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h) }#define BPP 32 -#include "vnc-enc-hextile-template.h" +#include "vnc-enc-hextile-template.c.inc" #undef BPP#define GENERIC #define BPP 32 -#include "vnc-enc-hextile-template.h" +#include "vnc-enc-hextile-template.c.inc" #undef BPP#undef GENERIC
ui/vnc-enc-zrle.c.inc +1 -1
@@ -66,7 +66,7 @@ static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h, int zywrle_level); #if ZRLE_BPP != 8 -#include "vnc-enc-zywrle-template.c" +#include "vnc-enc-zywrle-template.c.inc" #endif
ui/vnc-enc-zywrle-template.c.inc renamed from ui/vnc-enc-zywrle-template.c +0 -0
util/mmap-alloc.c +2 -1
@@ -10,6 +10,8 @@* later. See the COPYING file in the top-level directory. */ +#include "qemu/osdep.h" +#ifdef CONFIG_LINUX #include <linux/mman.h> #else /* !CONFIG_LINUX */
@@ -17,7 +19,6 @@#define MAP_SHARED_VALIDATE 0x0#endif /* CONFIG_LINUX */ -#include "qemu/osdep.h" #include "qemu/mmap-alloc.h" #include "qemu/host-utils.h" #include "qemu/cutils.h"
Signature · 1 line
2.36.1
PATCH v3 7/9 tests/style: check qemu/osdep.h is included in all .c files
In reply to Daniel P. BerrangéThe qemu/osdep.h file must be included as the very first header in all C source files, to ensure its definitions take effect over all other header files, including system headers.
--- tests/style.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
tests/style.yml +23 -1
@@ -120,4 +120,26 @@ double_words: - pc-bios/ - qemu-options\.hx - scripts/checkpatch\.pl - - tests/qtest/arm-cpu-features\.c + - tests/qtest/arm-cpu-features\.c + +osdep_h_in_source: + multiline: true + files: \.c$ + require: ^((?!#include)[^\n]*\n)*#include "qemu/osdep.h" + message: all C source files must include qemu/osdep.h, as the first header + ignore: + - contrib/plugins/.* + - linux-user/(mips64|x86_64)/(signal|cpu_loop)\.c + - pc-bios/.* + - scripts/coverity-scan/model\.c + - scripts/xen-detect\.c + - subprojects/.* + - target/hexagon/(gen_semantics|gen_dectree_import)\.c + - target/s390x/gen-features\.c + - tests/migration/s390x/a-b-bios\.c + - tests/multiboot/.* + - tests/plugin/.* + - tests/tcg/.* + - tests/uefi-test-tools/.* + - tests/unit/test-rcu-(simpleq|slist|tailq)\.c + - tools/ebpf/rss.bpf.c
Signature · 1 line
2.36.1
Re: [PATCH v3 7/9] tests/style: check qemu/osdep.h is included in all .c files
Quoted 14 lines · Daniel P. Berrangé
The
qemu/osdep.hfile must be included as the very first header in all C source files, to ensure its definitions take effect over all other header files, including system headers.Signed-off-by Daniel P. Berrangé <[email protected]>--- tests/style.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)tests/style.yml +0
-0
tests/style.yml double_words: · line 123
Quoted 6 lines
tests/style.yml +1
-1@@ -120,4 +120,26 @@ double_words: - pc-bios/ - qemu-options\.hx - scripts/checkpatch\.pl - - tests/qtest/arm-cpu-features\.c + - tests/qtest/arm-cpu-features\.c
Unrelated to the patch at hand, but a good example of the issue...
Can we add a style checker to ensure that text files (including style.yml) end in a trailing newline?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v3 8/9 misc: remove qemu/osdep.h from headers / included source files
In reply to Daniel P. BerrangéSince qemu/osdep.h is guaranteed present in all C source files, there is hno reason for it to be present in header files. Some C source files are not directly directly, but rather included from other source files. These should also not have qemu/osdep.h present, as the primary source will have already included it.
--- crypto/akcipher-gcrypt.c.inc | 1 - crypto/akcipher-nettle.c.inc | 1 - crypto/cipher-gnutls.c.inc | 1 - crypto/rsakey-nettle.c.inc | 1 - crypto/rsakey.h | 1 - include/hw/cxl/cxl_host.h | 1 - include/hw/tricore/triboard.h | 1 - include/qemu/userfaultfd.h | 1 - net/vmnet_int.h | 1 - qga/cutils.h | 2 -- target/cris/translate_v10.c.inc | 1 - target/hexagon/hex_arch_types.h | 1 - target/hexagon/mmvec/macros.h | 1 - target/riscv/pmu.h | 1 - target/xtensa/core-dc232b/xtensa-modules.c.inc | 1 - target/xtensa/core-dc233c/xtensa-modules.c.inc | 1 - target/xtensa/core-de212/xtensa-modules.c.inc | 1 - target/xtensa/core-fsf/xtensa-modules.c.inc | 1 - target/xtensa/core-sample_controller/xtensa-modules.c.inc | 1 - ui/vnc-enc-zrle.c.inc | 3 --- ui/vnc-enc-zywrle-template.c.inc | 1 - 21 files changed, 24 deletions(-)
crypto/akcipher-gcrypt.c.inc +0 -1
@@ -21,7 +21,6 @@ #include <gcrypt.h> -#include "qemu/osdep.h" #include "qemu/host-utils.h" #include "crypto/akcipher.h" #include "crypto/random.h"
crypto/akcipher-nettle.c.inc +0 -1
@@ -21,7 +21,6 @@ #include <nettle/rsa.h> -#include "qemu/osdep.h" #include "qemu/host-utils.h" #include "crypto/akcipher.h" #include "crypto/random.h"
crypto/cipher-gnutls.c.inc +0 -1
@@ -18,7 +18,6 @@ * */ -#include "qemu/osdep.h" #include "cipherpriv.h" #include <gnutls/crypto.h>
crypto/rsakey-nettle.c.inc +0 -1
@@ -21,7 +21,6 @@ #include <nettle/asn1.h> -#include "qemu/osdep.h" #include "qapi/error.h" #include "rsakey.h"
crypto/rsakey.h +0 -1
@@ -22,7 +22,6 @@#ifndef QCRYPTO_RSAKEY_H #define QCRYPTO_RSAKEY_H -#include "qemu/osdep.h" #include "qemu/host-utils.h" #include "crypto/akcipher.h"
include/hw/cxl/cxl_host.h +0 -1
@@ -7,7 +7,6 @@* COPYING file in the top-level directory. */ -#include "qemu/osdep.h" #include "hw/cxl/cxl.h" #include "hw/boards.h"
include/hw/tricore/triboard.h +0 -1
@@ -18,7 +18,6 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/boards.h" #include "sysemu/sysemu.h"
include/qemu/userfaultfd.h +0 -1
@@ -13,7 +13,6 @@#ifndef USERFAULTFD_H #define USERFAULTFD_H -#include "qemu/osdep.h" #include "exec/hwaddr.h" #include <linux/userfaultfd.h>
net/vmnet_int.h +0 -1
@@ -10,7 +10,6 @@#ifndef VMNET_INT_H #define VMNET_INT_H -#include "qemu/osdep.h" #include "vmnet_int.h" #include "clients.h"
qga/cutils.h +0 -2
@@ -1,8 +1,6 @@#ifndef CUTILS_H_ #define CUTILS_H_ -#include "qemu/osdep.h" -int qga_open_cloexec (const char *name,int flags,mode_t mode);#endif /* CUTILS_H_ */
target/cris/translate_v10.c.inc +0 -1
@@ -18,7 +18,6 @@ * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" #include "crisv10-decode.h" static const char * const regnames_v10[] =
target/hexagon/hex_arch_types.h +0 -1
@@ -18,7 +18,6 @@#ifndef HEXAGON_HEX_ARCH_TYPES_H #define HEXAGON_HEX_ARCH_TYPES_H -#include "qemu/osdep.h" #include "mmvec/mmvec.h" #include "qemu/int128.h"
target/hexagon/mmvec/macros.h +0 -1
@@ -18,7 +18,6 @@#ifndef HEXAGON_MMVEC_MACROS_H #define HEXAGON_MMVEC_MACROS_H -#include "qemu/osdep.h" #include "qemu/host-utils.h" #include "arch.h" #include "mmvec/system_ext_mmvec.h"
target/riscv/pmu.h +0 -1
@@ -16,7 +16,6 @@* this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" #include "qemu/main-loop.h"
target/xtensa/core-dc232b/xtensa-modules.c.inc +0 -1
@@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "qemu/osdep.h" #include "xtensa-isa.h" #include "xtensa-isa-internal.h"
target/xtensa/core-dc233c/xtensa-modules.c.inc +0 -1
@@ -21,7 +21,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "qemu/osdep.h" #include "xtensa-isa.h" #include "xtensa-isa-internal.h"
target/xtensa/core-de212/xtensa-modules.c.inc +0 -1
@@ -21,7 +21,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "qemu/osdep.h" #include "xtensa-isa.h" #include "xtensa-isa-internal.h"
target/xtensa/core-fsf/xtensa-modules.c.inc +0 -1
@@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "qemu/osdep.h" #include "xtensa-isa.h" #include "xtensa-isa-internal.h"
target/xtensa/core-sample_controller/xtensa-modules.c.inc +0 -1
@@ -21,7 +21,6 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "qemu/osdep.h" #include "xtensa-isa.h" #include "xtensa-isa-internal.h"
ui/vnc-enc-zrle.c.inc +0 -3
@@ -21,9 +21,6 @@ * algorithm writes to the position one past the end of the pixel data. */ - -#include "qemu/osdep.h" - #undef ZRLE_ENDIAN_SUFFIX #if ZYWRLE_ENDIAN == ENDIAN_LITTLE
ui/vnc-enc-zywrle-template.c.inc +0 -1
@@ -100,7 +100,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #define ZYWRLE_QUANTIZE -#include "qemu/osdep.h" #include "vnc-enc-zywrle.h" #ifndef ZRLE_COMPACT_PIXEL
Signature · 1 line
2.36.1
Re: [PATCH v3 8/9] misc: remove qemu/osdep.h from headers / included source files
Quoted 20 lines · Daniel P. Berrangé
Since
qemu/osdep.his guaranteed present in all C source files, there is hno reason for it to be present in header files. Some C source files are not directly directly, but rather included from other source files. These should also not haveqemu/osdep.hpresent, as the primary source will have already included it.--- crypto/akcipher-gcrypt.c.inc | 1 - crypto/akcipher-nettle.c.inc | 1 - crypto/cipher-gnutls.c.inc | 1 - crypto/rsakey-nettle.c.inc | 1 - crypto/rsakey.h | 1 - include/hw/cxl/cxl_host.h | 1 - include/hw/tricore/triboard.h | 1 - include/qemu/userfaultfd.h | 1 - net/vmnet_int.h | 1 - qga/cutils.h | 2 -- target/cris/translate_v10.c.inc | 1 - target/hexagon/hex_arch_types.h | 1 - target/hexagon/mmvec/macros.h | 1 - target/riscv/pmu.h | 1 -
Quoted 8 lines
target/xtensa/core-dc232b/xtensa-modules.c.inc | 1 - target/xtensa/core-dc233c/xtensa-modules.c.inc | 1 - target/xtensa/core-de212/xtensa-modules.c.inc | 1 - target/xtensa/core-fsf/xtensa-modules.c.inc | 1 - target/xtensa/core-sample_controller/xtensa-modules.c.inc | 1 - ui/vnc-enc-zrle.c.inc | 3 --- ui/vnc-enc-zywrle-template.c.inc | 1 - 21 files changed, 24 deletions(-)
Re: [PATCH v3 8/9] misc: remove qemu/osdep.h from headers / included source files
In reply to Daniel P. BerrangéQuoted 2 lines · Daniel P. Berrangé
Since
qemu/osdep.his guaranteed present in all C source files, there is hno reason for it to be present in header files. Some
s/hno/no/
Quoted 4 lines
C source files are not directly directly, but rather included from other source files. These should also not have
qemu/osdep.hpresent, as the primary source will have already included it.
---
Missing S-o-b
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v3 9/9 tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
In reply to Daniel P. BerrangéSince the qemu/osdep.h file must be included as the very first header in all C source files, there is no reason to include it in .h or .c.in files.
--- tests/style.yml | 5 +++++ 1 file changed, 5 insertions(+)
tests/style.yml +5 -0
@@ -143,3 +143,8 @@ osdep_h_in_source: - tests/uefi-test-tools/.* - tests/unit/test-rcu-(simpleq|slist|tailq)\.c - tools/ebpf/rss.bpf.c + +osdep_h_in_header: + files: \.(h|c\.inc)$ + prohibit: '#include "qemu/osdep\.h"' + message: only C source files may include qemu/osdep.h
Signature · 1 line
2.36.1
Re: [PATCH v3 9/9] tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
Quoted 8 lines · Daniel P. Berrangé
Since the
qemu/osdep.hfile must be included as the very first header in all C source files, there is no reason to include it in .h or .c.in files.Signed-off-by Daniel P. Berrangé <[email protected]>--- tests/style.yml | 5 +++++ 1 file changed, 5 insertions(+)
Re: [PATCH v3 9/9] tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
In reply to Daniel P. BerrangéQuoted 2 lines · Daniel P. Berrangé
Since the
qemu/osdep.hfile must be included as the very first header in all C source files, there is no reason to include it in .h or .c.in
.c.inc
Quoted 12 lines
files.
Signed-off-by Daniel P. Berrangé <[email protected]>--- tests/style.yml | 5 +++++ 1 file changed, 5 insertions(+)tests/style.yml +0
-0
tests/style.yml osdep_h_in_source: · line 150
Quoted 8 lines
tests/style.yml +5
-0@@ -143,3 +143,8 @@ osdep_h_in_source: - tests/uefi-test-tools/.* - tests/unit/test-rcu-(simpleq|slist|tailq)\.c - tools/ebpf/rss.bpf.c + +osdep_h_in_header: + files: \.(h|c\.inc)$ + prohibit: '#include "qemu/osdep\.h"' + message: only C source files may include qemu/osdep.h
Should we also have a rule that rejects <qemu/osdep.h> in all files (our only spelling should be with "", not <>)?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org