diff mbox

[10/18] net/slirp.c: fix warning with _FORTIFY_SOURCE

Message ID 1261273167-3240-10-git-send-email-kirill@shutemov.name
State New
Headers show

Commit Message

Kirill A . Shutemov Dec. 20, 2009, 1:39 a.m. UTC
CC    net/slirp.o
cc1: warnings being treated as errors
net/slirp.c: In function 'slirp_smb_cleanup':
net/slirp.c:470: error: ignoring return value of 'system', declared with attribute warn_unused_result
make: *** [net/slirp.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 net/slirp.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Comments

Blue Swirl Dec. 22, 2009, 6:50 p.m. UTC | #1
On Sun, Dec 20, 2009 at 1:39 AM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
>  CC    net/slirp.o
> cc1: warnings being treated as errors
> net/slirp.c: In function 'slirp_smb_cleanup':
> net/slirp.c:470: error: ignoring return value of 'system', declared with attribute warn_unused_result
> make: *** [net/slirp.o] Error 1
>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  net/slirp.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/net/slirp.c b/net/slirp.c
> index 3f91c4b..1f16814 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -464,10 +464,15 @@ int net_slirp_redir(const char *redir_str)
>  static void slirp_smb_cleanup(SlirpState *s)
>  {
>     char cmd[128];
> +    int ret;
>
>     if (s->smb_dir[0] != '\0') {
>         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
> -        system(cmd);
> +        ret = system(cmd);
> +        if (ret) {
> +            qemu_error("'%s' failed. Error code: %d\n", cmd, ret);
> +            /* abort() ? */

This is not correct.

- system() returns -1 on error and the command exit status otherwise,
which may also be nonzero.
- the exit status should be retrieved with WEXITSTATUS() macro, or in
case of error via errno.
- in no case abort() is warranted for smb cleanup.
diff mbox

Patch

diff --git a/net/slirp.c b/net/slirp.c
index 3f91c4b..1f16814 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -464,10 +464,15 @@  int net_slirp_redir(const char *redir_str)
 static void slirp_smb_cleanup(SlirpState *s)
 {
     char cmd[128];
+    int ret;
 
     if (s->smb_dir[0] != '\0') {
         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
-        system(cmd);
+        ret = system(cmd);
+        if (ret) {
+            qemu_error("'%s' failed. Error code: %d\n", cmd, ret);
+            /* abort() ? */
+        }
         s->smb_dir[0] = '\0';
     }
 }