mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
build: syntax check to avoid 'const fooPtr'
'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. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
33aec50684
commit
e79810162a
8
cfg.mk
8
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' \
|
||||
|
Loading…
x
Reference in New Issue
Block a user