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>
This commit is contained in:
Prasad J Pandit 2018-06-05 23:38:35 +05:30 committed by Samuel Thibault
parent 864036e251
commit c22098c74a
1 changed files with 16 additions and 18 deletions

View File

@ -151,27 +151,25 @@ m_cat(struct mbuf *m, struct mbuf *n)
void void
m_inc(struct mbuf *m, int size) m_inc(struct mbuf *m, int size)
{ {
int datasize; int datasize;
/* some compiles throw up on gotos. This one we can fake. */ /* some compilers throw up on gotos. This one we can fake. */
if(m->m_size>size) return; if (m->m_size > size) {
return;
}
if (m->m_flags & M_EXT) { if (m->m_flags & M_EXT) {
datasize = m->m_data - m->m_ext; datasize = m->m_data - m->m_ext;
m->m_ext = g_realloc(m->m_ext, size + datasize); m->m_ext = g_realloc(m->m_ext, size + datasize);
m->m_data = m->m_ext + datasize; } else {
} else { datasize = m->m_data - m->m_dat;
char *dat; m->m_ext = g_malloc(size + datasize);
datasize = m->m_data - m->m_dat; memcpy(m->m_ext, m->m_dat, m->m_size);
dat = g_malloc(size + datasize); m->m_flags |= M_EXT;
memcpy(dat, m->m_dat, m->m_size); }
m->m_ext = dat; m->m_data = m->m_ext + datasize;
m->m_data = m->m_ext + datasize; m->m_size = size + datasize;
m->m_flags |= M_EXT;
}
m->m_size = size + datasize;
} }