'const fooPtr' is the same as 'foo * const' (the pointer won't change, but it's contents can). But in general, if an interface is trying to be const-correct, it should be using 'const foo *' (the pointer is to data that can't be changed). Now that the code base has been cleaned, enforce it with a syntax checker. * cfg.mk (sc_forbid_const_pointer_typedef): New rule. --- cfg.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cfg.mk b/cfg.mk index dad8a90..82ecc95 100644 --- a/cfg.mk +++ b/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 \w*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' \ -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list