On 07/08/2011 01:26 PM, Eric Blake wrote:
Enforce the recent flags cleanups - we want to use 'unsigned int
flags'
in any of our APIs (except where backwards compatibility is important,
in the public migration APIs), and that all flags are checked for
validity (except when there are stub functions that completely
ignore the flags argument).
There are a few minor tweaks done here to avoid false positives:
signed arguments passed to open() are renamed oflags, and flags
arguments that are legitimately ignored are renamed flags_unused.
* cfg.mk (sc_flags_usage): New rule.
(exclude_file_name_regexp--sc_flags_usage): And a few exemptions.
+sc_flags_usage:
+ @test "$$(grep -c 'long flags' \
+ $(srcdir)/include/libvirt/libvirt.h.in)" != 4 && \
+ { echo '$(ME): new API should use "unsigned int flags"'
1>&2; \
+ exit 1; } || :
As mentioned in 4/27, this doesn't cover all public APIs. I'm thinking
of squashing this in (I'll post a full v2 once I actually rebase it on
top of all ACK'd posts, but will start the review now):
diff --git i/cfg.mk w/cfg.mk
index 4ab5752..2e177ff 100644
--- i/cfg.mk
+++ w/cfg.mk
@@ -280,14 +280,17 @@ sc_flags_debug:
# Prefer 'unsigned int flags', along with checks for unknown flags.
# For historical reasons, we are stuck with 'unsigned long flags' in
-# migration and in a few other places.
-# Three tests in this check: a fixed number of non-int flags in public
-# API, no flags marked unused, and 'unsigned' should appear before any
-# declaration of a flags variable (hence the prohibit line of [^d]).
-# The existence of long long makes the third test slightly harder.
+# migration, so check for those known 4 instances and no more in public
+# API. Also check that no flags are marked unused, and 'unsigned' should
+# appear before any declaration of a flags variable (acheived by
+# prohibiting the word prior to the type from ending in anything other
+# than d). The existence of long long, and of documentation about
+# flags, makes the regex in the third test slightly harder.
sc_flags_usage:
- @test "$$(grep -c 'long flags' \
- $(srcdir)/include/libvirt/libvirt.h.in)" != 4 && \
+ @test "$$(cat $(srcdir)/include/libvirt/libvirt.h.in \
+ $(srcdir)/include/libvirt/virterror.h \
+ $(srcdir)/include/libvirt/libvirt-qemu.h \
+ | grep -c '\(long\|unsigned\) flags')" != 4 && \
{ echo '$(ME): new API should use "unsigned int flags"'
1>&2; \
exit 1; } || :
@prohibit=' flags ''ATTRIBUTE_UNUSED' \
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org