qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: Qemu Developers <qemu-devel@nongnu.org>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Prasad J Pandit <pjp@fedoraproject.org>
Subject: [Qemu-devel] [PATCH 2/2] slirp: reformat m_cat routine
Date: Tue,  5 Jun 2018 23:38:36 +0530	[thread overview]
Message-ID: <20180605180836.21485-3-ppandit@redhat.com> (raw)
In-Reply-To: <20180605180836.21485-1-ppandit@redhat.com>

From: Prasad J Pandit <pjp@fedoraproject.org>

Coding style changes to the m_cat routine and minor refactoring.

Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 slirp/mbuf.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/slirp/mbuf.c b/slirp/mbuf.c
index 0f45abd917..30e3b2719d 100644
--- a/slirp/mbuf.c
+++ b/slirp/mbuf.c
@@ -151,32 +151,28 @@ m_cat(struct mbuf *m, struct mbuf *n)
 void
 m_inc(struct mbuf *m, int size)
 {
-	int datasize;
+    int datasize;
 
-	/* some compiles throw up on gotos.  This one we can fake. */
-        if(m->m_size>size) return;
+    /* some compiles throw up on gotos. This one we can fake. */
+    if (m->m_size > size) {
+        return;
+    }
 
-        if (m->m_flags & M_EXT) {
-	  datasize = m->m_data - m->m_ext;
-          m->m_ext = g_realloc(m->m_ext, size + datasize);
-	  m->m_data = m->m_ext + datasize;
-        } else {
-	  char *dat;
-	  datasize = m->m_data - m->m_dat;
-      dat = g_malloc(size + datasize);
-	  memcpy(dat, m->m_dat, m->m_size);
-
-	  m->m_ext = dat;
-	  m->m_data = m->m_ext + datasize;
-	  m->m_flags |= M_EXT;
-        }
-
-        m->m_size = size + datasize;
+    if (m->m_flags & M_EXT) {
+        datasize = m->m_data - m->m_ext;
+        m->m_ext = g_realloc(m->m_ext, size + datasize);
+    } else {
+        datasize = m->m_data - m->m_dat;
+        m->m_ext = g_malloc(size + datasize);
+        memcpy(m->m_ext, m->m_dat, m->m_size);
+        m->m_flags |= M_EXT;
+    }
 
+    m->m_data = m->m_ext + datasize;
+    m->m_size = size + datasize;
 }
 
 
-
 void
 m_adj(struct mbuf *m, int len)
 {
-- 
2.17.1

  parent reply	other threads:[~2018-06-05 18:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 18:08 [Qemu-devel] [PATCH 0/2] correct size computation in m_cat P J P
2018-06-05 18:08 ` [Qemu-devel] [PATCH 1/2] slirp: correct size computation while concatenating mbuf P J P
2018-06-06  9:09   ` Samuel Thibault
2018-06-06 18:42     ` P J P
2018-06-05 18:08 ` P J P [this message]
2018-06-06  9:18   ` [Qemu-devel] [PATCH 2/2] slirp: reformat m_cat routine Samuel Thibault
2018-06-06  8:58 ` [Qemu-devel] [PATCH 0/2] correct size computation in m_cat no-reply
2018-06-06 10:19 ` no-reply

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=20180605180836.21485-3-ppandit@redhat.com \
    --to=ppandit@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.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).