From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v2 7/7] tests/style: check qemu/osdep.h is included in all .c files
Date: Mon, 4 Jul 2022 17:15:09 +0100 [thread overview]
Message-ID: <YsMSDVDoe/7/zIDT@redhat.com> (raw)
In-Reply-To: <CAFEAcA-fK4qqJ7zyNYf5hyGDeWF9YDX0oG_gEWvXMZg4+bmnSw@mail.gmail.com>
On Mon, Jul 04, 2022 at 04:55:45PM +0100, Peter Maydell wrote:
> On Mon, 4 Jul 2022 at 16:50, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Mon, Jul 04, 2022 at 04:47:16PM +0100, Peter Maydell wrote:
> > > On Mon, 4 Jul 2022 at 16:23, Daniel P. Berrangé <berrange@redhat.com> wrote:
> > > >
> > > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > >
> > > > +
> > > > +sc_c_file_osdep_h:
> > > > + @require='#include "qemu/osdep.h"' \
> > > > + in_vc_files='\.c$$' \
> > > > + halt='all C files must include qemu/osdep.h' \
> > > > + $(_sc_search_regexp)
> > >
> > > The rule is not just "included in all C files", but "included
> > > as the *first* include in all C files".
> >
> > Oh right, so we can copy a rule from libvirt to validate that.
> >
> > It would look like this, but s,config.h,qemu/osdep.h,
> >
> >
> > # Print each file name for which the first #include does not match
> > # $(config_h_header). Like grep -m 1, this only looks at the first match.
> > perl_config_h_first_ = \
> > -e 'BEGIN {$$ret = 0}' \
> > -e 'if (/^\# *include\b/) {' \
> > -e ' if (not m{^\# *include $(config_h_header)}) {' \
> > -e ' print "$$ARGV\n";' \
> > -e ' $$ret = 1;' \
> > -e ' }' \
> > -e ' \# Move on to next file after first include' \
> > -e ' close ARGV;' \
> > -e '}' \
> > -e 'END {exit $$ret}'
> >
> > # You must include <config.h> before including any other header file.
> > # This can possibly be via a package-specific header, if given by syntax-check.mk.
> > sc_require_config_h_first:
> > @if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \
> > files=$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \
> > perl -n $(perl_config_h_first_) $$files || \
> > { echo 'the above files include some other header' \
> > 'before <config.h>' 1>&2; exit 1; } || :; \
> > else :; \
> > fi
>
> As an example syntax checking rule I think this makes a pretty
> convincing case for the argument "make is the wrong language/framework
> for this job"...
Matching contextually across multiple lines of text is admittedly hard.
IME most of the usage of this syntax checking facility we had in libvirt
can be handled using single line matches, which are trivial to provide.
With regards,
Daniel
--
|: 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 :|
prev parent reply other threads:[~2022-07-04 16:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 15:22 [PATCH v2 0/7] tests: introduce a tree-wide code style checking facility Daniel P. Berrangé
2022-07-04 15:22 ` [PATCH v2 1/7] tests: introduce tree-wide code style checking Daniel P. Berrangé
2022-07-04 15:46 ` Peter Maydell
2022-07-04 16:12 ` Daniel P. Berrangé
2022-07-07 16:43 ` Daniel P. Berrangé
2022-07-04 15:22 ` [PATCH v2 2/7] misc: fix mixups of bool constants with int variables Daniel P. Berrangé
2022-07-04 15:38 ` Peter Maydell
2022-07-04 15:22 ` [PATCH v2 3/7] tests/style: check for " Daniel P. Berrangé
2022-07-04 15:23 ` [PATCH v2 4/7] misc: fix commonly doubled up words Daniel P. Berrangé
2022-07-04 15:52 ` Peter Maydell
2022-07-07 12:30 ` Daniel P. Berrangé
2022-07-07 12:35 ` Peter Maydell
2022-07-04 15:23 ` [PATCH v2 5/7] tests/style: check for " Daniel P. Berrangé
2022-07-04 15:23 ` [PATCH v2 6/7] misc: ensure qemu/osdep.h is included in all .c files Daniel P. Berrangé
2022-07-04 15:38 ` Warner Losh
2022-07-04 15:46 ` Daniel P. Berrangé
2022-07-04 16:08 ` Warner Losh
2022-07-04 15:23 ` [PATCH v2 7/7] tests/style: check " Daniel P. Berrangé
2022-07-04 15:47 ` Peter Maydell
2022-07-04 15:50 ` Daniel P. Berrangé
2022-07-04 15:55 ` Peter Maydell
2022-07-04 16:15 ` Daniel P. Berrangé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YsMSDVDoe/7/zIDT@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=f4bug@amsat.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).