[libvirt] [PATCH] Remove unused variables.

Martin Kletzander mkletzan at redhat.com
Fri Sep 25 21:20:31 UTC 2015


On Fri, Sep 25, 2015 at 02:21:52PM -0600, Eric Blake wrote:
>On 09/24/2015 01:35 AM, Martin Kletzander wrote:
>> I was playing with coccinelle tool the other day and just for the fun of
>> it, I tried removing some useless things from our code.  And look what
>> came up.  No functional change, and we're down in the number of lines by
>> about a hundred.
>
>It would be worth including your spatch rule in the commit message, for
>a couple of reasons:
>
>If someone tries to backport the patch, having the spatch rule to feed
>coccinelle will make it easier to replay the rule from scratch instead
>of having to manually resolve any backport conflicts.
>
>Having the ruleset listed lets it be inspected, in case anyone familiar
>with coccinelle sees a bug in it, or as a teaching moment for those
>trying to learn coccinelle.
>

Oh, if you want, I can certainly add it, but since there are many
occurrences inside macros that were not made to be handled properly,
etc., I figured it's not worth it.  Anyway, here it is, I'll add it in
the commit message if we decide to put it in.  Anyway, some work on
the macro recognitions would be nice.  I can work on that if you want
to postpone the clean-ups until just applying simple spatch works and
doesn't need further cleaning.

The following spatch is just what we had tested on KVM Forum.

@@
expression ret;
@@
- if (ret) return ret;
- return 0;
+ return ret;

@@
local idexpression ret;
expression e;
@@
- ret = e;
- return ret;
+ return e;

@@
type T;
identifier i;
expression E;
@@
- T i = E;
  ... when != i

@@
type T;
identifier i;
@@
- T i;
  ... when != i
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150925/1be8c8f5/attachment-0001.sig>


More information about the libvir-list mailing list