On Mon, Mar 18, 2019 at 01:21:01PM +0000, Peter Maydell wrote: > On Mon, 18 Mar 2019 at 13:17, Daniel P. Berrangé <berra...@redhat.com> wrote: > > On Mon, Mar 18, 2019 at 01:53:38PM +0100, Markus Armbruster wrote: > > > In case teaching it to checkpatch turns out to be too onerous: perhaps > > > certain things would be easier to check in a program that looks at > > > sources rather than patches. Other projects have that as "make > > > syntax-check". > > > > FWIW, I think most of what qemu's checkpatch does would be better > > as checks against the source tree. The big pain with checkpatch > > is that it never enforces that we clean up existing code. So any > > time we introduce a new rule, it usually means that we end up having > > 2 different styles in the code forever. > > The other big problem with checkpatch is that it's a huge perl > script that is doing fairly ad-hoc operations on textual source, > and certainly I find it almost impossible to understand to be > able to add any kind of new check to it. > > If there was a good framework for writing project-specific static > syntax-and-style-checks that would be great; I don't know of one, > though.
Libvirt just uses gnulib's Makefile based framework which largely relies on regex for grep. Unfortunately that is insufficient for more complex checks, so we resort to creating separate perl/python scripts for checks that can't be expressed by a regex. The other downside is that every check reads the source files again, so it isn't that scalable. eg 50 checks means every source file is read 50 times. A long while ago I started prototyping a framework for doing this as python code, so that we could run many checks over the file at once. Never got around to finishing this, but its the kind of thing that could be useful for both qemu & libvirt ultimately. 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 :|