qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Alon Levy <alevy@redhat.com>,
	qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 3/3] slirp/misc: fix gcc __warn_memset_zero_len warnings
Date: Fri, 24 Feb 2012 14:00:41 +0000	[thread overview]
Message-ID: <1330092041-13801-4-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1330092041-13801-1-git-send-email-stefanha@linux.vnet.ibm.com>

From: Alon Levy <alevy@redhat.com>

By removing memset altogether (Patch from Stefan Hajnoczi, tested
compile only by me).

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 slirp/misc.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index 3432fbf..0308a62 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -333,7 +333,6 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
     struct socket *so;
     const char *state;
     char buf[20];
-    int n;
 
     monitor_printf(mon, "  Protocol[State]    FD  Source Address  Port   "
                         "Dest. Address  Port RecvQ SendQ\n");
@@ -357,10 +356,8 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
             dst_addr = so->so_faddr;
             dst_port = so->so_fport;
         }
-        n = snprintf(buf, sizeof(buf), "  TCP[%s]", state);
-        memset(&buf[n], ' ', 19 - n);
-        buf[19] = 0;
-        monitor_printf(mon, "%s %3d %15s %5d ", buf, so->s,
+        snprintf(buf, sizeof(buf), "  TCP[%s]", state);
+        monitor_printf(mon, "%-19s %3d %15s %5d ", buf, so->s,
                        src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*",
                        ntohs(src.sin_port));
         monitor_printf(mon, "%15s %5d %5d %5d\n",
@@ -370,22 +367,20 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
 
     for (so = slirp->udb.so_next; so != &slirp->udb; so = so->so_next) {
         if (so->so_state & SS_HOSTFWD) {
-            n = snprintf(buf, sizeof(buf), "  UDP[HOST_FORWARD]");
+            snprintf(buf, sizeof(buf), "  UDP[HOST_FORWARD]");
             src_len = sizeof(src);
             getsockname(so->s, (struct sockaddr *)&src, &src_len);
             dst_addr = so->so_laddr;
             dst_port = so->so_lport;
         } else {
-            n = snprintf(buf, sizeof(buf), "  UDP[%d sec]",
+            snprintf(buf, sizeof(buf), "  UDP[%d sec]",
                          (so->so_expire - curtime) / 1000);
             src.sin_addr = so->so_laddr;
             src.sin_port = so->so_lport;
             dst_addr = so->so_faddr;
             dst_port = so->so_fport;
         }
-        memset(&buf[n], ' ', 19 - n);
-        buf[19] = 0;
-        monitor_printf(mon, "%s %3d %15s %5d ", buf, so->s,
+        monitor_printf(mon, "%-19s %3d %15s %5d ", buf, so->s,
                        src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*",
                        ntohs(src.sin_port));
         monitor_printf(mon, "%15s %5d %5d %5d\n",
@@ -394,13 +389,11 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
     }
 
     for (so = slirp->icmp.so_next; so != &slirp->icmp; so = so->so_next) {
-        n = snprintf(buf, sizeof(buf), "  ICMP[%d sec]",
+        snprintf(buf, sizeof(buf), "  ICMP[%d sec]",
                      (so->so_expire - curtime) / 1000);
         src.sin_addr = so->so_laddr;
         dst_addr = so->so_faddr;
-        memset(&buf[n], ' ', 19 - n);
-        buf[19] = 0;
-        monitor_printf(mon, "%s %3d %15s  -    ", buf, so->s,
+        monitor_printf(mon, "%-19s %3d %15s  -    ", buf, so->s,
                        src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*");
         monitor_printf(mon, "%15s  -    %5d %5d\n", inet_ntoa(dst_addr),
                        so->so_rcv.sb_cc, so->so_snd.sb_cc);
-- 
1.7.9

  parent reply	other threads:[~2012-02-24 14:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24 14:00 [Qemu-devel] [PULL 0/3] Trivial patches for 11 to 24 February 2012 Stefan Hajnoczi
2012-02-24 14:00 ` [Qemu-devel] [PATCH 1/3] tcg: Remove unneeded include statements Stefan Hajnoczi
2012-02-24 14:00 ` [Qemu-devel] [PATCH 2/3] vl.c: Increase width of machine name column in "-M ?" output Stefan Hajnoczi
2012-02-24 14:00 ` Stefan Hajnoczi [this message]
2012-02-24 16:35 ` [Qemu-devel] [PULL 0/3] Trivial patches for 11 to 24 February 2012 Anthony Liguori

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=1330092041-13801-4-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=alevy@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@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).