Skip to content

Commit

Permalink
qga/commands-posix: Make ga_wait_child() return boolean
Browse files Browse the repository at this point in the history
Make ga_wait_child() return boolean and check the returned boolean
in ga_run_command() instead of dereferencing @errp.

Cc: Michael Roth <[email protected]>
Cc: Konstantin Kostiuk <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Reviewed-by: Konstantin Kostiuk <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Konstantin Kostiuk <[email protected]>
  • Loading branch information
trueptolemy authored and kostyanf14 committed Jul 19, 2024
1 parent 2e3b166 commit 1d52386
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qga/commands-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#endif
#endif

static void ga_wait_child(pid_t pid, int *status, Error **errp)
static bool ga_wait_child(pid_t pid, int *status, Error **errp)
{
pid_t rpid;

Expand All @@ -59,10 +59,11 @@ static void ga_wait_child(pid_t pid, int *status, Error **errp)
if (rpid == -1) {
error_setg_errno(errp, errno, "failed to wait for child (pid: %d)",
pid);
return;
return false;
}

g_assert(rpid == pid);
return true;
}

static ssize_t ga_pipe_read_str(int fd[2], char **str)
Expand Down Expand Up @@ -167,8 +168,7 @@ static int ga_run_command(const char *argv[], const char *in_str,
goto out;
}

ga_wait_child(pid, &status, errp);
if (*errp) {
if (!ga_wait_child(pid, &status, errp)) {
goto out;
}

Expand Down

0 comments on commit 1d52386

Please sign in to comment.