These two functions have pattern that's preventing us from simpler virAsprintf() -> g_strdup_printf() transition. Modify their logic a bit. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_command.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f24013f9eb..0160507737 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -256,13 +256,13 @@ qemuVirCommandGetFDSet(virCommandPtr cmd, int fd) char *result = NULL; int idx = virCommandPassFDGetFDIndex(cmd, fd); - if (idx >= 0) { - ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd)); - } else { + if (idx < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("file descriptor %d has not been transferred"), fd); + return NULL; } + ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd)); return result; } @@ -283,12 +283,13 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd) char *result = NULL; int idx = virCommandPassFDGetFDIndex(cmd, fd); - if (idx >= 0) { - ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx)); - } else { + if (idx < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("file descriptor %d has not been transferred"), fd); + return NULL; } + + ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx)); return result; } -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list