[libvirt] [PATCH] Fix sorting of libvirt_private.syms and add syntax check rule

Daniel P. Berrange berrange at redhat.com
Wed Dec 12 10:44:18 UTC 2012


On Tue, Dec 11, 2012 at 03:47:09PM -0700, Eric Blake wrote:
> On 12/11/2012 03:27 PM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange at redhat.com>
> > 
> > Add check-symsorting.pl to perform case-insensitive alphabetical
> > sorting of groups of symbols. Fix all violations it reports
> > 
> > Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> > ---
> >  src/Makefile.am          |   4 +-
> >  src/check-symsorting.pl  |  66 +++++++++++++++++++
> >  src/libvirt_esx.syms     |   2 +-
> >  src/libvirt_openvz.syms  |   2 +-
> >  src/libvirt_private.syms | 161 ++++++++++++++++++++++++-----------------------
> >  5 files changed, 152 insertions(+), 83 deletions(-)
> >  create mode 100644 src/check-symsorting.pl
> > 
> 
> > diff --git a/src/check-symsorting.pl b/src/check-symsorting.pl
> > new file mode 100644
> 
> chmod +x
> 
> > index 0000000..9c62246
> > --- /dev/null
> > +++ b/src/check-symsorting.pl
> > @@ -0,0 +1,66 @@
> > +#!/usr/bin/perl
> > +
> > +use strict;
> > +use warnings;
> > +
> > +die "syntax: $0 SYMFILE..." unless int(@ARGV) >= 1;
> > +
> > +my $ret = 0;
> > +foreach my $symfile (@ARGV) {
> > +    open SYMFILE, $symfile or die "cannot read $symfile: $!";
> > +
> > +    my $line;
> > +    my @group;
> > +
> > +    while (<SYMFILE>) {
> > +        chomp;
> > +        next if /^#/;
> > +
> > +        if (/^\s*$/) {
> > +            if (@group) {
> > +                &check_sorting(\@group, $symfile, $line);
> 
> So perl lets you call a function...

Yes, the key here is the '&' symbol, since we've not predeclared
the function

[perlsub(1)]
       A subroutine may be called using an explicit "&" prefix.  The "&" is
       optional in modern Perl, as are parentheses if the subroutine has
       been predeclared.  The "&" is not optional when just naming the
       subroutine, such as when it's used as an argument to defined() or
       undef().  Nor is it optional when you want to do an indirect
       subroutine call with a subroutine name or reference using the
       "&$subref()" or "&{$subref}()" constructs, although the
       "$subref->()" notation solves that problem.  See perlref for more
       about all that.
[/perlsub]


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