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
---
v2:
- remove the special handling of the 'close' procedure
daemon/Makefile.am | 2 +-
src/Makefile.am | 2 +-
src/rpc/gendispatch.pl | 32 +++++++++++++++++---------------
3 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 8ed29b8..63c731e 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -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 \
diff --git a/src/Makefile.am b/src/Makefile.am
index fadde28..00e78ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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)
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index e068b53..6e26e2d 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -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(a)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}"
--
1.7.4.1