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 <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9e9d78057d
commit
307a04671b
@ -256,13 +256,13 @@ qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
|
|||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
int idx = virCommandPassFDGetFDIndex(cmd, fd);
|
int idx = virCommandPassFDGetFDIndex(cmd, fd);
|
||||||
|
|
||||||
if (idx >= 0) {
|
if (idx < 0) {
|
||||||
ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd));
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("file descriptor %d has not been transferred"), fd);
|
_("file descriptor %d has not been transferred"), fd);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,12 +283,13 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
|
|||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
int idx = virCommandPassFDGetFDIndex(cmd, fd);
|
int idx = virCommandPassFDGetFDIndex(cmd, fd);
|
||||||
|
|
||||||
if (idx >= 0) {
|
if (idx < 0) {
|
||||||
ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx));
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("file descriptor %d has not been transferred"), fd);
|
_("file descriptor %d has not been transferred"), fd);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user