Patchwork [02/10] slirp: check system() success

login
register
mail settings
Submitter Juan Quintela
Date March 4, 2010, 9 a.m.
Message ID <93c1dcb48b0cfa33775fc45a1ffb9c0edb44d833.1267692963.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/46891/
State New
Headers show

Comments

Juan Quintela - March 4, 2010, 9 a.m.
we shouldn't call W*() macros until we check that fork worked.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 net/slirp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Michael S. Tsirkin - March 4, 2010, 9:20 a.m.
On Thu, Mar 04, 2010 at 10:00:31AM +0100, Juan Quintela wrote:
> we shouldn't call W*() macros until we check that fork worked.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  net/slirp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/net/slirp.c b/net/slirp.c
> index 317cca7..7f846ec 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -472,7 +472,7 @@ static void slirp_smb_cleanup(SlirpState *s)
>      if (s->smb_dir[0] != '\0') {
>          snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
>          ret = system(cmd);
> -        if (!WIFEXITED(ret)) {
> +        if (ret == -1 || !WIFEXITED(ret)) {
>              qemu_error("'%s' failed.\n", cmd);
>          } else if (WEXITSTATUS(ret)) {
>              qemu_error("'%s' failed. Error code: %d\n",
> -- 
> 1.6.6.1
> 
>

Patch

diff --git a/net/slirp.c b/net/slirp.c
index 317cca7..7f846ec 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -472,7 +472,7 @@  static void slirp_smb_cleanup(SlirpState *s)
     if (s->smb_dir[0] != '\0') {
         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
         ret = system(cmd);
-        if (!WIFEXITED(ret)) {
+        if (ret == -1 || !WIFEXITED(ret)) {
             qemu_error("'%s' failed.\n", cmd);
         } else if (WEXITSTATUS(ret)) {
             qemu_error("'%s' failed. Error code: %d\n",