From: Michal Privoznik Date: Sat, 19 Oct 2019 11:19:32 +0000 (+0200) Subject: qemu_command: Change logic in qemuVirCommandGet{FDSet,GetDevSet} X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=307a04671b53cc3987ca867cd0b4ee0c5bfd1aa7;p=libvirt.git qemu_command: Change logic in qemuVirCommandGet{FDSet,GetDevSet} 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 Reviewed-by: Ján Tomko --- 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; }