[PATCH v3 9/9] tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files

Daniel P. Berrangé posted 9 patches 3 years, 7 months ago
[PATCH v3 9/9] tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
Posted by Daniel P. Berrangé 3 years, 7 months ago
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.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/style.yml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/style.yml b/tests/style.yml
index 6d91ac6115..d2a0299a33 100644
--- a/tests/style.yml
+++ b/tests/style.yml
@@ -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
-- 
2.36.1


Re: [PATCH v3 9/9] tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
Posted by Eric Blake 3 years, 6 months ago
On Thu, Jul 07, 2022 at 05:37:20PM +0100, Daniel P. Berrangé wrote:
> 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

.c.inc

> files.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  tests/style.yml | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/style.yml b/tests/style.yml
> index 6d91ac6115..d2a0299a33 100644
> --- a/tests/style.yml
> +++ b/tests/style.yml
> @@ -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 <>)?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


Re: [PATCH v3 9/9] tests/style: check qemu/osdep.h is NOT included in all .h/.c.inc files
Posted by Philippe Mathieu-Daudé via 3 years, 7 months ago
On 7/7/22 18:37, Daniel P. Berrangé wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/style.yml | 5 +++++
>   1 file changed, 5 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>