[Libvir] 0/8 add syntax checks

Jim Meyering jim at meyering.net
Fri Jan 25 22:16:15 UTC 2008

A few days ago I wrote a patch eliminating all of the useless
if tests of the form "if (foo) free (foo);".

In general, when making such a global change, I prefer to
add a check so that it is easy to ensure mechanically that the
new violations don't sneak back in.  So I wrote a script
to detect the above, then another to perform the "remove-if-cond"
part as a double check against my detect-and-manually-remove work.

Once you can mechanically detect the offending pattern,
it's good to make it as easy as possible to check for
recurrence.  In other projects, I've used "make syntax-check",
because most such tests are syntax-related and detectable
using tools like grep.

The first patch simply removes the useless if tests.
Following it, I introduce a "make syntax-check" framework
similar to what I use in coreutils.  In it, most tests
are disabled, except the new one that tests for the unnecessary

In the following 6 patches, I enable new tests one by one, and
correct the violations each one exposes.

I deliberately keep these tests in a separate Makefile.maint
file, and pull them in via GNUmakefile so that they are not
subject to the burdensome portability constraints associated
with regular Makefile.am contents.  I.e., if you run "make
syntax-check", you are expected to have GNU make as well
as a reasonable set of working tools.  Thus, we don't have to
worry about whether egrep works or whether e.g., perl is present.


More information about the libvir-list mailing list