qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alon Levy <alevy@redhat.com>
To: qemu-trivial@nongnu.org
Subject: [Qemu-trivial] [PATCH] slirp: workaround gcc __warn_memset_zero_len warnings
Date: Thu, 23 Feb 2012 22:29:42 +0200	[thread overview]
Message-ID: <1330028982-13973-1-git-send-email-alevy@redhat.com> (raw)

Fixes __warn_memset_zero_len warnings with gcc --version
gcc (GCC) 4.7.0 20120208 (Red Hat 4.7.0-0.12)

Caused by an overly protective memset check to avoid transposition of
the fill value and length parameters.

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 slirp/misc.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index 3432fbf..17c21e2 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -358,7 +358,9 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
             dst_port = so->so_fport;
         }
         n = snprintf(buf, sizeof(buf), "  TCP[%s]", state);
-        memset(&buf[n], ' ', 19 - n);
+        if (n < 19) {
+            memset(&buf[n], ' ', 19 - n);
+        }
         buf[19] = 0;
         monitor_printf(mon, "%s %3d %15s %5d ", buf, so->s,
                        src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*",
@@ -383,7 +385,9 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
             dst_addr = so->so_faddr;
             dst_port = so->so_fport;
         }
-        memset(&buf[n], ' ', 19 - n);
+        if (n < 19) {
+            memset(&buf[n], ' ', 19 - n);
+        }
         buf[19] = 0;
         monitor_printf(mon, "%s %3d %15s %5d ", buf, so->s,
                        src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*",
-- 
1.7.9.1



             reply	other threads:[~2012-02-23 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23 20:29 Alon Levy [this message]
2012-02-24  8:29 ` [Qemu-trivial] [PATCH] slirp: workaround gcc __warn_memset_zero_len warnings Stefan Hajnoczi
2012-02-24 10:18   ` Alon Levy
2012-02-24 11:33   ` [Qemu-trivial] [PATCH] slirp/misc: fix " Alon Levy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330028982-13973-1-git-send-email-alevy@redhat.com \
    --to=alevy@redhat.com \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).