On 12/20/2011 01:35 AM, Hu Tao wrote:
the removal of unused variable i also removes codes like
this:
if (!xdr_int (xdrs, &objp->remote_typed_param_value_u.i))
which should not be removed.
Sorry I'm not familiar with perl and can't find a perfect way
to deal with this.
---
src/rpc/genprotocol.pl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl
index 7af1b3b..cec93d8 100755
--- a/src/rpc/genprotocol.pl
+++ b/src/rpc/genprotocol.pl
@@ -72,7 +72,7 @@ while (<RPCGEN>) {
# Remove decl of i, if i isn't used in the function.
@uses = grep /\bi\b/, @function;
- @function = grep !/\bi\b/, @function if @uses == 1;
+ #@function = grep !/\bi\b/, @function if @uses == 1;
Oh my. That certainly explains things.
But removing this line re-introduces a compiler warning about an unused
variable 'i', so a better fix would be restricting matches to non-member
uses of 'buf' and 'i':
diff --git i/src/rpc/genprotocol.pl w/src/rpc/genprotocol.pl
index 7af1b3b..4838325 100755
--- i/src/rpc/genprotocol.pl
+++ w/src/rpc/genprotocol.pl
@@ -67,12 +67,12 @@ while (<RPCGEN>) {
# Note: The body of the function is in @function.
# Remove decl of buf, if buf isn't used in the function.
- my @uses = grep /\bbuf\b/, @function;
- @function = grep !/\bbuf\b/, @function if @uses == 1;
+ my @uses = grep /[^.>]\bbuf\b/, @function;
+ @function = grep !/[^.>]\bbuf\b/, @function if @uses == 1;
# Remove decl of i, if i isn't used in the function.
- @uses = grep /\bi\b/, @function;
- @function = grep !/\bi\b/, @function if @uses == 1;
+ @uses = grep /[^.>]\bi\b/, @function;
+ @function = grep !/[^.>]\bi\b/, @function if @uses == 1;
# (char **)&objp->... gives:
# warning: dereferencing type-punned pointer will break
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org