[libvirt] [PATCH] Consistent style for usage of sizeof operator
Daniel P. Berrange
berrange at redhat.com
Thu Mar 29 16:07:06 UTC 2012
On Thu, Mar 29, 2012 at 10:02:00AM -0600, Eric Blake wrote:
> On 03/29/2012 09:51 AM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange at redhat.com>
> >
> > The code is splattered with a mix of
> >
> > sizeof foo
> > sizeof (foo)
> > sizeof(foo)
> >
> > Standardize on sizeof(foo) and add a syntax check rule to
> > enforce it
>
> We might also want to document our policy on 'return 0' and 'sizeof(v)'
> in HACKING.
>
> > ---
> > cfg.mk | 4 +
>
> > +++ b/cfg.mk
> > @@ -813,3 +813,7 @@ exclude_file_name_regexp--sc_trailing_blank = \.(fig|gif|ico|png)$$
> >
> > exclude_file_name_regexp--sc_unmarked_diagnostics = \
> > ^(docs/apibuild.py|tests/virt-aa-helper-test)$$
> > +
> > +exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
> > +
> > +exclude_file_name_regexp--sc_const_long_option = tools/virt-host-validate.c
> > diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
>
> Where's the new rule that actually adds the syntax check?
In my source tree but not committed ! Opps.
The change was:
diff --git a/cfg.mk b/cfg.mk
index c3de533..ade8690 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -422,6 +422,12 @@ sc_correct_id_types:
halt="use pid_t for pid, uid_t for uid, gid_t for gid" \
$(_sc_search_regexp)
+# Forbid sizeof foo or sizeof (foo), require sizeof(foo)
+sc_size_of_brackets:
+ @prohibit='sizeof\s' \
+ halt='use sizeof(foo), not sizeof (foo) or sizeof foo' \
+ $(_sc_search_regexp)
+
# Ensure that no C source file, docs, or rng schema uses TABs for
# indentation. Also match *.h.in files, to get libvirt.h.in. Exclude
# files in gnulib, since they're imported.
@@ -807,3 +813,5 @@ exclude_file_name_regexp--sc_trailing_blank = \.(fig|gif|ico|png)$$
exclude_file_name_regexp--sc_unmarked_diagnostics = \
^(docs/apibuild.py|tests/virt-aa-helper-test)$$
+
+exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list