[libvirt PATCH 2/5] src: QemuMonitorCommandWithFiles: report error when fd passing is unsupported

Martin Kletzander mkletzan at redhat.com
Thu May 19 13:01:24 UTC 2022


On Wed, May 18, 2022 at 04:00:57PM +0200, Ján Tomko wrote:
>The result of the <= 0 comparison was assigned to 'rc', rendering the
>if (rc == 0) condition dead code.
>
>Signed-off-by: Ján Tomko <jtomko at redhat.com>
>---
> src/libvirt-qemu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
>index 5020b5dc1b..ace91e8ada 100644
>--- a/src/libvirt-qemu.c
>+++ b/src/libvirt-qemu.c
>@@ -161,7 +161,7 @@ virDomainQemuMonitorCommandWithFiles(virDomainPtr domain,
>     if (ninfiles > 0 || outfiles) {
>         int rc;
>         if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn,
>-                                           VIR_DRV_FEATURE_FD_PASSING) <= 0)) {
>+                                           VIR_DRV_FEATURE_FD_PASSING)) <= 0) {
>             if (rc == 0)
>                 virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
>                                _("fd passing is not supported by this connection"));
>-- 
>2.34.1
>

Or even (way) better:

diff --git i/src/libvirt-qemu.c w/src/libvirt-qemu.c
index 3cd8c8f7453d..93107d1bfcbb 100644
--- i/src/libvirt-qemu.c
+++ w/src/libvirt-qemu.c
@@ -159,9 +159,9 @@ virDomainQemuMonitorCommandWithFiles(virDomainPtr domain,
      virCheckNonNullArgGoto(cmd, error);

      if (ninfiles > 0 || outfiles) {
-        int rc;
-        if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn,
-                                           VIR_DRV_FEATURE_FD_PASSING) <= 0)) {
+        int rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn,
+                                          VIR_DRV_FEATURE_FD_PASSING);
+        if (rc <= 0) {
              if (rc == 0)
                  virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                                 _("fd passing is not supported by this connection"));
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220519/d6151611/attachment.sig>


More information about the libvir-list mailing list