The idea of virCommand* APIs is that a possible error that
occurred while constructing cmd line is kept in virCommand
struct. If that's the case all subsequent calls to virCommand*()
are NO-OPs or they return an error. Well,
virCommandPassFDGetFDIndex() is not honoring that.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
{
size_t i = 0;
+ if (!cmd || cmd->has_error)
+ return -1;
+
while (i < cmd->npassfd) {
if (cmd->passfd[i].fd == fd)
return i;