[libvirt] [PATCH] virCommand: Cleanup unnecessarily variables

Daniel P. Berrange berrange at redhat.com
Mon May 23 11:47:09 UTC 2011


On Sun, May 22, 2011 at 04:42:09PM +0200, Michal Privoznik wrote:
> ---
> Building with ENABLE_DEBUG=0 showed more errors,
> because VIR_DEBUG() get replaced with dummy 'do {} while(0)' statement,
> and compiler complains about unused parameters. So if anybody knows
> how to get rid of this ... Note that I am speaking about '...' part in
> VIR_DEBUG_INT() definition.
> 
>  src/util/command.c |    9 +++------
>  1 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/src/util/command.c b/src/util/command.c
> index ebb90cb..4b8a940 100644
> --- a/src/util/command.c
> +++ b/src/util/command.c
> @@ -962,9 +962,8 @@ virCommandProcessIO(virCommandPtr cmd)
>                  } else {
>                      inoff += done;
>                      if (inoff == inlen) {
> -                        int tmpfd = infd;
>                          if (VIR_CLOSE(infd) < 0)
> -                            VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
> +                            VIR_DEBUG("ignoring failed close on fd %d", infd);
>                      }
>                  }
>              }
> @@ -1145,17 +1144,15 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
>              VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
>      }
>      if (cmd->outbuf == &outbuf) {
> -        int tmpfd = cmd->outfd;
>          if (VIR_CLOSE(cmd->outfd) < 0)
> -            VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
> +            VIR_DEBUG("ignoring failed close on fd %d", cmd->outfd);
>          cmd->outfdptr = NULL;
>          cmd->outbuf = NULL;
>          VIR_FREE(outbuf);
>      }
>      if (cmd->errbuf == &errbuf) {
> -        int tmpfd = cmd->errfd;
>          if (VIR_CLOSE(cmd->errfd) < 0)
> -            VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
> +            VIR_DEBUG("ignoring failed close on fd %d", cmd->errfd);
>          cmd->errfdptr = NULL;
>          cmd->errbuf = NULL;
>          VIR_FREE(errbuf);

Anything which wants to ignore the return status of VIR_CLOSE and not
report an error, should be using  VIR_FORCE_CLOSE instead.

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