aboutsummaryrefslogtreecommitdiff
path: root/slirp/mbuf.c
diff options
context:
space:
mode:
authorPrasad J Pandit <pjp@fedoraproject.org>2018-06-05 23:38:35 +0530
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-06-08 09:08:30 +0300
commitc22098c74a09164797fae6511c5eaf68f32c4dd8 (patch)
treed60f152b430a9c18c799de6a236b5f7a08270ee2 /slirp/mbuf.c
parent864036e251f54c99d31df124aad7f34f01f5344c (diff)
slirp: reformat m_inc routine
Coding style changes to the m_inc routine and minor refactoring. Reported-by: ZDI Disclosures <zdi-disclosures@trendmicro.com> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp/mbuf.c')
-rw-r--r--slirp/mbuf.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/slirp/mbuf.c b/slirp/mbuf.c
index 18cbf759a7..0c189e1a7b 100644
--- a/slirp/mbuf.c
+++ b/slirp/mbuf.c
@@ -151,27 +151,25 @@ 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 compilers 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;
- }
+ 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_size = size + datasize;
+ m->m_data = m->m_ext + datasize;
+ m->m_size = size + datasize;
}