slirp: misc cleanups
cover slirp: misc cleanups
This is on top of my previous field renaming patch
Michael S. Tsirkin (2):
slirp: remove unused type name
slirp: M_dat -> m_dat
slirp/ip_input.c | 6 +++--- slirp/mbuf.c | 28 ++++++++++++++-------------- slirp/mbuf.h | 12 ++++++------ slirp/socket.c | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-)
Signature · 1 line
1.7.9.111.gf3fb0
PATCH 1/2 slirp: remove unused type name
M_dat union has an ugly name. We never use it
so just make it unnamed.
Signed-off-by Michael S. Tsirkin <[email protected]>
--- slirp/mbuf.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
slirp/mbuf.h +1 -1
@@ -85,7 +85,7 @@ struct mbuf {bool arp_requested;uint64_t expiration_date;/* start of dynamic buffer area, must be last element */ -union M_dat { +union {char m_dat_[1 ];/* ANSI don't like 0 sized arrays */ char *m_ext_; } M_dat;
Signature · 1 line
1.7.9.111.gf3fb0
PATCH 2/2 slirp: M_dat -> m_dat
In reply to Michael S. TsirkinDrop upper case from field name.
Generated by:
s#\bM_dat\b#m_dat#g;
Signed-off-by Michael S. Tsirkin <[email protected]>
--- slirp/ip_input.c | 6 +++--- slirp/mbuf.c | 28 ++++++++++++++-------------- slirp/mbuf.h | 10 +++++----- slirp/socket.c | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-)
slirp/ip_input.c +3 -3
@@ -342,13 +342,13 @@ insert:/* * If the fragments concatenated to an mbuf that's * bigger than the total size of the fragment, then and -* M_dat.m_ext_ buffer was alloced. But fp->ipq_next points to +* m_dat.m_ext_ buffer was alloced. But fp->ipq_next points to * the old buffer (in the mbuf), so we must point ip * into the new buffer. */ if (m->m_hdr.mh_flags &M_EXT ) { -int delta = (char *)q - m->M_dat.m_dat_; - q = (struct ipasfrag *)(m->M_dat.m_ext_ + delta); +int delta = (char *)q - m->m_dat.m_dat_; + q = (struct ipasfrag *)(m->m_dat.m_ext_ + delta); } ip =fragtoip (q);
slirp/mbuf.c +14 -14
@@ -11,7 +11,7 @@* so that one whole packet can fit. Mbuf's cannot be * chained together. If there's more data than the mbuf * could hold, an external malloced buffer is pointed to -* by M_dat.m_ext_ (and the data pointers) and M_EXT is set in +* by m_dat.m_ext_ (and the data pointers) and M_EXT is set in * the flags */
@@ -23,7 +23,7 @@* Find a nice value for msize * XXX if_maxlinkhdr already in mtu */ -#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + offsetof(struct mbuf, M_dat.m_dat_) + 6) +#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + offsetof(struct mbuf, m_dat.m_dat_) + 6)void m_init (Slirp *slirp)
@@ -65,8 +65,8 @@ m_get(Slirp *slirp) m->m_hdr.mh_flags = (flags |M_USEDLIST );/* Initialise it */ - m->m_hdr.mh_size = SLIRP_MSIZE - offsetof(struct mbuf, M_dat.m_dat_); - m->m_hdr.mh_data = m->M_dat.m_dat_; + m->m_hdr.mh_size = SLIRP_MSIZE - offsetof(struct mbuf, m_dat.m_dat_); + m->m_hdr.mh_data = m->m_dat.m_dat_; m->m_hdr.mh_len =0 ; m->m_hdr.mh_nextpkt =NULL ; m->m_hdr.mh_prevpkt =NULL ;
@@ -91,7 +91,7 @@ m_free(struct mbuf *m)/* If it's M_EXT, free() it */ if (m->m_hdr.mh_flags &M_EXT ) -free (m->M_dat.m_ext_); +free (m->m_dat.m_ext_);/* * Either free() it or put it on the free list
@@ -137,17 +137,17 @@ m_inc(struct mbuf *m, int size)if (m->m_hdr.mh_size>size)return ;if (m->m_hdr.mh_flags &M_EXT ) { - datasize = m->m_hdr.mh_data - m->M_dat.m_ext_; - m->M_dat.m_ext_ = (char *)realloc (m->M_dat.m_ext_,size); - m->m_hdr.mh_data = m->M_dat.m_ext_ + datasize; + datasize = m->m_hdr.mh_data - m->m_dat.m_ext_; + m->m_dat.m_ext_ = (char *)realloc (m->m_dat.m_ext_,size); + m->m_hdr.mh_data = m->m_dat.m_ext_ + datasize; }else {char *dat; - datasize = m->m_hdr.mh_data - m->M_dat.m_dat_; + datasize = m->m_hdr.mh_data - m->m_dat.m_dat_; dat = (char *)malloc (size); -memcpy (dat, m->M_dat.m_dat_, m->m_hdr.mh_size); +memcpy (dat, m->m_dat.m_dat_, m->m_hdr.mh_size); - m->M_dat.m_ext_ = dat; - m->m_hdr.mh_data = m->M_dat.m_ext_ + datasize; + m->m_dat.m_ext_ = dat; + m->m_hdr.mh_data = m->m_dat.m_ext_ + datasize; m->m_hdr.mh_flags |=M_EXT ; }
@@ -206,10 +206,10 @@ dtom(Slirp *slirp, void *dat)for (m = slirp->m_usedlist.m_hdr.mh_next; m != &slirp->m_usedlist; m = m->m_hdr.mh_next) {if (m->m_hdr.mh_flags &M_EXT ) { -if ( (char *)dat>=m->M_dat.m_ext_ && (char *)dat<(m->M_dat.m_ext_ + m->m_hdr.mh_size) ) +if ( (char *)dat>=m->m_dat.m_ext_ && (char *)dat<(m->m_dat.m_ext_ + m->m_hdr.mh_size) )return m; }else { -if ( (char *)dat >= m->M_dat.m_dat_ && (char *)dat<(m->M_dat.m_dat_ + m->m_hdr.mh_size) ) +if ( (char *)dat >= m->m_dat.m_dat_ && (char *)dat<(m->m_dat.m_dat_ + m->m_hdr.mh_size) )return m; } }
slirp/mbuf.h +5 -5
@@ -46,7 +46,7 @@* m_hdr.mh_nextpkt points to the next packet, if fragmented. * If the data is too large, the M_EXT is used, and a larger block * is alloced. Therefore, m_free[m] must check for M_EXT and if set -* free the M_dat.m_ext_. This is inefficient memory-wise, but who cares. +* free the m_dat.m_ext_. This is inefficient memory-wise, but who cares. */ /* XXX should union some of these! */
@@ -69,9 +69,9 @@ struct m_hdr {* How much room is in the mbuf, from m_hdr.mh_data to the end of the mbuf */ #define M_ROOM (m) ((m->m_hdr.mh_flags & M_EXT)? \ - (((m)->M_dat.m_ext_ + (m)->m_hdr.mh_size) - (m)->m_hdr.mh_data) \ + (((m)->m_dat.m_ext_ + (m)->m_hdr.mh_size) - (m)->m_hdr.mh_data) \ : \ - (((m)->M_dat.m_dat_ + (m)->m_hdr.mh_size) - (m)->m_hdr.mh_data)) + (((m)->m_dat.m_dat_ + (m)->m_hdr.mh_size) - (m)->m_hdr.mh_data))/* * How much free room there is
@@ -88,10 +88,10 @@ struct mbuf {union {char m_dat_[1 ];/* ANSI don't like 0 sized arrays */ char *m_ext_; - } M_dat; + } m_dat; }; -#define M_EXT 0x01/* M_dat.m_ext_ points to more (malloced) data */ +#define M_EXT 0x01/* m_dat.m_ext_ points to more (malloced) data */ #define M_FREELIST 0x02/* mbuf is on free list */ #define M_USEDLIST 0x04/* XXX mbuf is on used list (for dtom()) */ #define M_DOFREE 0x08/* when m_free is called on the mbuf, free()
slirp/socket.c +1 -1
@@ -489,7 +489,7 @@ sorecvfrom(struct socket *so)ioctlsocket (so->s,FIONREAD , &n);if (n > len) { - n = (m->m_hdr.mh_data - m->M_dat.m_dat_) + m->m_hdr.mh_len + n +1 ; + n = (m->m_hdr.mh_data - m->m_dat.m_dat_) + m->m_hdr.mh_len + n +1 ;m_inc (m, n); len =M_FREEROOM (m); }
Signature · 1 line
1.7.9.111.gf3fb0