]> xenbits.xensource.com Git - libvirt.git/commitdiff
maint: enforce private symbol section sorting
authorEric Blake <eblake@redhat.com>
Wed, 20 Feb 2013 00:59:20 +0000 (17:59 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 20 Feb 2013 15:27:03 +0000 (08:27 -0700)
Automating a sorting check is the only way to ensure we don't
regress.  Suggested by Dan Berrange.

* src/check-symsorting.pl (check_sorting): Add a parameter,
validate that groups are in order, and that files exist.
* src/Makefile.am (check-symsorting): Adjust caller.
* src/libvirt_private.syms: Fix typo.
* src/libvirt_linux.syms: Fix file name.
* src/libvirt_vmx.syms: Likewise.
* src/libvirt_xenxs.syms: Likewise.
* src/libvirt_sasl.syms: Likewise.
* src/libvirt_libssh2.syms: Likewise.
* src/libvirt_esx.syms: Mention file name.
* src/libvirt_openvz.syms: Likewise.

src/Makefile.am
src/check-symsorting.pl
src/libvirt_esx.syms
src/libvirt_libssh2.syms
src/libvirt_linux.syms
src/libvirt_openvz.syms
src/libvirt_private.syms
src/libvirt_sasl.syms
src/libvirt_vmx.syms
src/libvirt_xenxs.syms

index 780cd5236d2801363f4728d09deeeba9604ce41b..3ef9a9c90baeac9d4ee0dddc6b1b2dbd5de8a4e3 100644 (file)
@@ -388,7 +388,8 @@ else
 check-symfile:
 endif
 check-symsorting:
-       $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl $(USED_SYM_FILES)
+       $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl \
+               $(srcdir) $(USED_SYM_FILES)
 EXTRA_DIST += check-symfile.pl check-symsorting.pl
 
 PROTOCOL_STRUCTS = \
index 9c622466738b9b7778958ddf987dcec78c538e8e..c523c34b21a58583b6c0b81f41b4a450ed7c3a72 100755 (executable)
@@ -3,22 +3,28 @@
 use strict;
 use warnings;
 
-die "syntax: $0 SYMFILE..." unless int(@ARGV) >= 1;
+die "syntax: $0 SRCDIR SYMFILE..." unless int(@ARGV) >= 2;
 
 my $ret = 0;
+my $srcdir = shift;
+my $lastgroup = undef;
 foreach my $symfile (@ARGV) {
     open SYMFILE, $symfile or die "cannot read $symfile: $!";
 
     my $line;
+    my $groupfile = "";
     my @group;
 
     while (<SYMFILE>) {
         chomp;
-        next if /^#/;
 
-        if (/^\s*$/) {
+        if (/^#\s*((\w+\/)*(\w+\.h))\s*$/) {
+            $groupfile = $1;
+        } elsif (/^#/) {
+            # Ignore comments
+        } elsif (/^\s*$/) {
             if (@group) {
-                &check_sorting(\@group, $symfile, $line);
+                &check_sorting(\@group, $symfile, $line, $groupfile);
             }
             @group = ();
             $line = $.;
@@ -30,20 +36,38 @@ foreach my $symfile (@ARGV) {
 
     close SYMFILE;
     if (@group) {
-        &check_sorting(\@group, $symfile, $line);
+        &check_sorting(\@group, $symfile, $line, $groupfile);
     }
+    $lastgroup = undef;
 }
 
 sub check_sorting {
     my $group = shift;
     my $symfile = shift;
     my $line = shift;
+    my $groupfile = shift;
 
     my @group = @{$group};
     my @sorted = sort { lc $a cmp lc $b } @group;
     my $sorted = 1;
     my $first;
     my $last;
+
+    # Check that groups are in order and groupfile exists
+    if (defined $lastgroup && lc $lastgroup ge lc $groupfile) {
+        print "Symbol block at $symfile:$line: block not sorted\n";
+        print "Move $groupfile block before $lastgroup block\n";
+        print "\n";
+        $ret = 1;
+    }
+    if (! -e "$srcdir/$groupfile") {
+        print "Symbol block at $symfile:$line: $groupfile not found\n";
+        print "\n";
+        $ret = 1;
+    }
+    $lastgroup = $groupfile;
+
+    # Check that symbols within a group are in order
     for (my $i = 0 ; $i <= $#sorted ; $i++) {
         if ($sorted[$i] ne $group[$i]) {
             $first = $i unless defined $first;
@@ -54,7 +78,7 @@ sub check_sorting {
     if (!$sorted) {
         @group = splice @group, $first, ($last-$first+1);
         @sorted = splice @sorted, $first, ($last-$first+1);
-        print "Symbol block at $symfile:$line symbols not sorted\n";
+        print "Symbol block at $symfile:$line: symbols not sorted\n";
         print map { "  " . $_ . "\n" } @group;
         print "Correct ordering\n";
         print map { "  " . $_ . "\n" } @sorted;
index ad3d60aa0389ad07e2adeeee72882e0b7eaba6c9..3c14b94aeb4c24c6923db642258933f9da9cf55c 100644 (file)
@@ -2,6 +2,7 @@
 # These symbols are dependent upon --with-esx via WITH_ESX
 #
 
+# esx/esx_util.h
 esxUtil_EscapeDatastoreItem;
 esxUtil_ParseDatastorePath;
 esxVI_DateTime_ConvertToCalendarTime;
index 815195b20eecdca21ae8607092802d07c1ccc683..55022b5ad3d8033ee5c730d9fef4d889970e68d8 100644 (file)
@@ -2,8 +2,7 @@
 # ssh session - specific symbols
 #
 
-# virnetsshsession.h
-#
+# rpc/virnetsshsession.h
 virNetSSHChannelRead;
 virNetSSHChannelWrite;
 virNetSSHSessionAuthAddAgentAuth;
index b5f7ee2ad7135e2d23dbf35aa6322bd32e2ac243..3500898cb773dd125e10dfa801f57498e8ff93af 100644 (file)
@@ -5,7 +5,7 @@
 # nodeinfo.h
 linuxNodeInfoCPUPopulate;
 
-# stats_linux.h
+# util/virstatslinux.h
 linuxDomainInterfaceStats;
 
 # Let emacs know we want case-insensitive sorting
index 58b93aecde981dd820c65b93cf5830e0b339cb46..ac0ed0d23ea48f42e7cf8de23ff1c1a2b73c2f40 100644 (file)
@@ -1,6 +1,8 @@
 #
 # These symbols are dependent upon --with-openvz via WITH_OPENVZ
 #
+
+# openvz/openvz_conf.h
 openvzLocateConfFile;
 openvzReadConfigParam;
 openvzReadNetworkConf;
index 1686bb8110740931db60bf64193ddcf6779dfb0a..3c44cc31cd39084779e83903bd061a918a7b2fa1 100644 (file)
@@ -420,7 +420,7 @@ virNetDevVlanFormat;
 virNetDevVlanParse;
 
 
-# conf/netdev_vportprofile_conf.h
+# conf/netdev_vport_profile_conf.h
 virNetDevVPortProfileFormat;
 virNetDevVPortProfileParse;
 virNetDevVPortTypeFromString;
index 099f48a5835ac59c296bf86c21bb6d7fae93e9ac..beb8825a588c8b311a97ff0035f83802f4440b97 100644 (file)
@@ -2,10 +2,10 @@
 # SASL-specific symbols
 #
 
-# virnetclient.h
+# rpc/virnetclient.h
 virNetClientSetSASLSession;
 
-# virnetsaslcontext.h
+# rpc/virnetsaslcontext.h
 virNetSASLContextCheckIdentity;
 virNetSASLContextNewClient;
 virNetSASLContextNewServer;
@@ -25,11 +25,11 @@ virNetSASLSessionServerStart;
 virNetSASLSessionServerStep;
 
 
-# virnetserverclient.h
+# rpc/virnetserverclient.h
 virNetServerClientSetSASLSession;
 
 
-# virnetsocket.h
+# rpc/virnetsocket.h
 virNetSocketSetSASLSession;
 
 # Let emacs know we want case-insensitive sorting
index 99fe5905175fadf1afb2bd7937a4a6b326bf755c..0b15f49c225341e525dd7ed9e6beae72f6f15bce 100644 (file)
@@ -2,7 +2,7 @@
 # These symbols are dependent upon --with-esx via WITH_ESX or --with-vmware via WITH_VMWARE.
 #
 
-# vmx.h
+# vmx/vmx.h
 virVMXConvertToUTF8;
 virVMXEscapeHex;
 virVMXFormatCDROM;
index 75d5322b86bff465502acbefe3e3de9dba2359b6..04b35c4befd81e34c456c96eff2bdbc2762e8b34 100644 (file)
@@ -2,7 +2,7 @@
 # These symbols are dependent upon --with-xen via WITH_XEN or --with-libxl via WITH_LIBXL.
 #
 
-# xen_sxpr.h
+# xenxs/xen_sxpr.h
 xenFormatSxpr;
 xenFormatSxprChr;
 xenFormatSxprDisk;
@@ -16,7 +16,7 @@ xenParseSxprChar;
 xenParseSxprSound;
 xenParseSxprString;
 
-# xen_xm.h
+# xenxs/xen_xm.h
 xenFormatXM;
 xenParseXM;