]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
rpc: Make the dispatch generator handle 'void name(void)' style procedures
authorMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 19 Jul 2011 12:16:47 +0000 (14:16 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 21 Jul 2011 15:00:59 +0000 (17:00 +0200)
The only 'void name(void)' style procedure in the protocol is 'close' that
is handled special, but also programming errors like a missing _args or
_ret suffix on the structs in the .x files can create such a situation by
accident. Making the generator aware of this avoids bogus errors from the
generator such as:

  Use of uninitialized value in exists at ./rpc/gendispatch.pl line 967.

Also this allows to get rid of the -c option and the special case code for
the 'close' procedure, as the generator handles it now correctly.

Reported by Michal Privoznik

daemon/Makefile.am
src/Makefile.am
src/rpc/gendispatch.pl

index 8ed29b89e2bd2cc67f6444de7e53167145f0d152..63c731efb5d7583e4c04d71bec693f110aaa8341 100644 (file)
@@ -44,7 +44,7 @@ QEMU_PROTOCOL = $(top_srcdir)/src/remote/qemu_protocol.x
 
 $(srcdir)/remote_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \
                $(REMOTE_PROTOCOL)
-       $(AM_V_GEN)perl -w $(srcdir)/../src/rpc/gendispatch.pl -c -b remote \
+       $(AM_V_GEN)perl -w $(srcdir)/../src/rpc/gendispatch.pl -b remote \
          $(REMOTE_PROTOCOL) > $@
 
 $(srcdir)/qemu_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \
index fadde28a6c2f19746142565055a974a76e1db4e6..00e78ac7e0fcc6dcee666486ab342c7df4ed7d4c 100644 (file)
@@ -188,7 +188,7 @@ REMOTE_DRIVER_PROTOCOL = $(REMOTE_PROTOCOL) $(QEMU_PROTOCOL)
 $(srcdir)/remote/remote_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \
                $(REMOTE_PROTOCOL)
        $(AM_V_GEN)perl -w $(srcdir)/rpc/gendispatch.pl \
-         -c -k remote $(REMOTE_PROTOCOL) > $@
+         -k remote $(REMOTE_PROTOCOL) > $@
 
 $(srcdir)/remote/qemu_client_bodies.h: $(srcdir)/rpc/gendispatch.pl \
                $(QEMU_PROTOCOL)
index e068b538062c118d5033d89cbb8a47cc24f001a0..6e26e2d6795345729ae5f0572ec3a0fba039da84 100755 (executable)
@@ -9,7 +9,7 @@
 # for both remote_protocol.x and qemu_protocol.x, you would run the
 # following:
 #
-# gendispatch.pl -c -t remote ../src/remote/remote_protocol.x
+# gendispatch.pl -t remote ../src/remote/remote_protocol.x
 # gendispatch.pl -t qemu ../src/remote/qemu_protocol.x
 #
 # By Richard Jones <rjones@redhat.com>
@@ -20,8 +20,8 @@ use strict;
 use Getopt::Std;
 
 # Command line options.
-our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d, $opt_c, $opt_b, $opt_k);
-getopts ('ptardcbk');
+our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d, $opt_b, $opt_k);
+getopts ('ptardbk');
 
 my $structprefix = shift or die "missing prefix argument";
 my $protocol = shift or die "missing protocol argument";
@@ -45,18 +45,6 @@ sub name_to_ProcName {
 # opinion about the name, args and return type of each RPC.
 my ($name, $ProcName, $id, $flags, %calls, @calls);
 
-# only generate a close method if -c was passed
-if ($opt_c) {
-    # REMOTE_PROC_CLOSE has no args or ret.
-    $calls{close} = {
-        name => "close",
-        ProcName => "Close",
-        UC_NAME => "CLOSE",
-        args => "void",
-        ret => "void",
-    };
-}
-
 my $collect_args_members = 0;
 my $collect_ret_members = 0;
 my $last_name;
@@ -143,6 +131,20 @@ while (<PROTOCOL>) {
         $flags = $3;
         $ProcName = name_to_ProcName ($name);
 
+        if (!exists $calls{$name}) {
+            # that the argument and return value cases have not yet added
+            # this procedure to the calls hash means that it has no arguments
+            # and no return value. add it to the calls hash now because all
+            # procedures have to be listed in the calls hash
+            $calls{$name} = {
+                name => $name,
+                ProcName => $ProcName,
+                UC_NAME => uc $name,
+                args => "void",
+                ret => "void"
+            }
+        }
+
         if ($opt_b or $opt_k) {
             if (!($flags =~ m/^\s*\/\*\s*(\S+)\s+(\S+)\s*(.*)\*\/\s*$/)) {
                 die "invalid generator flags for ${procprefix}_PROC_${name}"