Re: [PATCH 32/32] Prevent use of 'int' data type & 'ii', 'jj', 'kk' var names for loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 10, 2013 at 10:38:27AM +0200, Ján Tomko wrote:
> On 07/08/2013 04:21 PM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> > 
> > Add two syntax-check rules
> > 
> >  - sc_prohibit_int_ijk - block use of 'int' as a data type
> >    for any variables named 'i', 'j', 'k'
> >  - sc_prohibit_int_iijjkk - block use of 'ii', 'jj', 'kk'
> >    for any variable names
> > ---
> >  cfg.mk | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> > 
> > diff --git a/cfg.mk b/cfg.mk
> > index bbe84b3..2285f08 100644
> > --- a/cfg.mk
> > +++ b/cfg.mk
> > @@ -545,6 +545,17 @@ sc_avoid_attribute_unused_in_header:
> >  	halt='use ATTRIBUTE_UNUSED in .c rather than .h files'		\
> >  	  $(_sc_search_regexp)
> >  
> > +sc_prohibit_int_ijk:
> > +	@prohibit='\<int ([^=\(]+ )*(i|j|k)(\s|,|;)'			\
> > +	halt='use size_t, not int/unsigned int for loop vars i, j, k'	\
> > +	  $(_sc_search_regexp)
> > +
> 
> This misses some variables after the '=' sign:
> int n = 0, i;

Yep, I notice that now. Seems I was slightly too clever. The following
simpler rule catches them

  @prohibit='\<int [^(]* (i|j|k)(\s|,|;)'

The following were missed:

examples/hellolibvirt/hellolibvirt.c:57:    int ret = 0, i, numNames, numInactiveDomains, numActiveDomains;
examples/openauth/openauth.c:93:    int ret = 0, i, numNames, numInactiveDomains, numActiveDomains;
python/libvirt-override.c:2103:    int ret = -1, i;
src/conf/node_device_conf.c:742:    int ret = -1, n = 0, i;
src/lxc/lxc_container.c:254:            int tmpfd = i;
src/network/bridge_driver.c:2843:    int nactive = 0, i;
src/network/bridge_driver.c:2865:    int got = 0, i;
src/network/bridge_driver.c:2896:    int ninactive = 0, i;
src/network/bridge_driver.c:2918:    int got = 0, i;
src/network/bridge_driver.c:3765:    int ret = -1, i = 0;
src/node_device/node_device_udev.c:320:    int ret = 0, i = 0;
src/nwfilter/nwfilter_dhcpsnoop.c:1348:    int tmp = -1, i, rv, n, pollTo;
src/nwfilter/nwfilter_driver.c:468:    int got = 0, i;
src/nwfilter/nwfilter_ebiptables_driver.c:3673:    int rc = 0, i;
src/parallels/parallels_network.c:366:    int nactive = 0, i;
src/parallels/parallels_network.c:386:    int got = 0, i;
src/parallels/parallels_network.c:413:    int ninactive = 0, i;
src/parallels/parallels_network.c:433:    int got = 0, i;
src/qemu/qemu_command.c:7590:            int vlan = i;
src/qemu/qemu_driver.c:9011:    int ret = -1, i;
src/qemu/qemu_driver.c:12235:            int idx = i;
src/security/security_stack.c:518:    int len = 0, i = 0;
src/storage/storage_backend.c:1541:    int maxReg = 0, i, j;
src/storage/storage_driver.c:369:    int got = 0, i;
src/storage/storage_driver.c:427:    int got = 0, i;
src/storage/storage_driver.c:1165:    int ret = -1, i;
src/test/test_driver.c:2791:    int ret = -1, i;
src/test/test_driver.c:3009:    int numActive = 0, i;
src/test/test_driver.c:3025:    int n = 0, i;
src/test/test_driver.c:3051:    int numInactive = 0, i;
src/test/test_driver.c:3067:    int n = 0, i;
src/test/test_driver.c:3495:    int n = 0, i;
src/test/test_driver.c:3541:    int n = 0, i;
src/test/test_driver.c:3967:    int numActive = 0, i;
src/test/test_driver.c:3983:    int n = 0, i;
src/test/test_driver.c:4010:    int numInactive = 0, i;
src/test/test_driver.c:4029:    int n = 0, i;
src/util/vircommand.c:395:    int null = -1, i, openmax;
src/util/virnetdev.c:1098:    int ret = -1, i;
src/util/virpci.c:2521:    int ret = -1, i;
src/util/virsocketaddr.c:590:    int ret = 0, i;
src/xen/xen_driver.c:2462:    int ret = -1, i;
src/xen/xen_hypervisor.c:2601:    int maxids = 100, nids, i, id;
src/xenapi/xenapi_driver.c:1227:    int nvcpus = 0, i;
src/xenapi/xenapi_driver.c:1608:    int DomNum = 0, i;
src/xenxs/xen_sxpr.c:2207:    int hvm = 0, i, vmlocaltime = -1;
src/xenxs/xen_xm.c:1512:    int hvm = 0, i, vmlocaltime = 0;
tests/testutils.c:287:            int tmpfd = i;


I won't re-post the entire series since it is horrible to review. I'll
send some incremental patches for review which I'll squash in.

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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]