[libvirt] [PATCH v3 1/4] iptablesFormatNetwork(): constify target of "netaddr" parameter

Eric Blake eblake at redhat.com
Tue Sep 24 16:25:36 UTC 2013


On 09/24/2013 07:33 AM, Laszlo Ersek wrote:
>>
>> I suspect that forbidding const.*Ptr in "make syntax-check" wouldn't be
>> a bad idea.
> 
> The pattern should probably require some whitespace in the middle as
> well, if constWhateverPtr typedefs are to be accepted as valid.

Here's the proposed syntax check:

diff --git i/cfg.mk w/cfg.mk
index dad8a90..6a17d43 100644
--- i/cfg.mk
+++ w/cfg.mk
@@ -468,6 +468,14 @@ sc_correct_id_types:
 	halt="use pid_t for pid, uid_t for uid, gid_t for gid"		\
 	  $(_sc_search_regexp)

+# 'const fooPtr a' is the same as 'foo * const a', even though it is
+# usually desired to have 'foo const *a'.  It's easier to just prevent
+# the confusing mix of typedef vs. const placement.
+sc_forbid_const_pointer_typedef:
+	@prohibit='const [a-zA-Z_0-9]*Ptr'				\
+	halt="'const fooPtr var' does not declare what you meant"	\
+	  $(_sc_search_regexp)
+
 # Forbid sizeof foo or sizeof (foo), require sizeof(foo)
 sc_size_of_brackets:
 	@prohibit='sizeof\s'						\


and here's the damage we'd have to clean up:

$ make sc_forbid_const_pointer_typedef | wc
maint.mk: 'const fooPtr var' does not declare what you meant
make: *** [sc_forbid_const_pointer_typedef] Error 1
    403    1766   37136

spread among 75 files.

There's probably some fallout, too - once you have a const-correct
pointer type, it might show us places where we have been assigning
through what we thought was const.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130924/61b17b2e/attachment-0001.sig>


More information about the libvir-list mailing list