Message ID | 1487248176-29602-6-git-send-email-dmitry@daynix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 02/16/2017 09:29 AM, Dmitry Fleytman wrote: > This is a refactoring commit that does not change behavior. > > Signed-off-by: Dmitry Fleytman <dmitry@daynix.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > hw/net/net_rx_pkt.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c > index c7ae33d..3899211 100644 > --- a/hw/net/net_rx_pkt.c > +++ b/hw/net/net_rx_pkt.c > @@ -88,20 +88,21 @@ net_rx_pkt_pull_data(struct NetRxPkt *pkt, > const struct iovec *iov, int iovcnt, > size_t ploff) > { > + uint32_t pllen = iov_size(iov, iovcnt) - ploff; > + > if (pkt->ehdr_buf_len) { > net_rx_pkt_iovec_realloc(pkt, iovcnt + 1); > > pkt->vec[0].iov_base = pkt->ehdr_buf; > pkt->vec[0].iov_len = pkt->ehdr_buf_len; > > - pkt->tot_len = iov_size(iov, iovcnt) - ploff + pkt->ehdr_buf_len; > + pkt->tot_len = pllen + pkt->ehdr_buf_len; > pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1, > - iov, iovcnt, ploff, > - pkt->tot_len - pkt->ehdr_buf_len) + 1; > + iov, iovcnt, ploff, pllen) + 1; > } else { > net_rx_pkt_iovec_realloc(pkt, iovcnt); > > - pkt->tot_len = iov_size(iov, iovcnt) - ploff; > + pkt->tot_len = pllen; > pkt->vec_len = iov_copy(pkt->vec, pkt->vec_len_total, > iov, iovcnt, ploff, pkt->tot_len); > } >
diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index c7ae33d..3899211 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -88,20 +88,21 @@ net_rx_pkt_pull_data(struct NetRxPkt *pkt, const struct iovec *iov, int iovcnt, size_t ploff) { + uint32_t pllen = iov_size(iov, iovcnt) - ploff; + if (pkt->ehdr_buf_len) { net_rx_pkt_iovec_realloc(pkt, iovcnt + 1); pkt->vec[0].iov_base = pkt->ehdr_buf; pkt->vec[0].iov_len = pkt->ehdr_buf_len; - pkt->tot_len = iov_size(iov, iovcnt) - ploff + pkt->ehdr_buf_len; + pkt->tot_len = pllen + pkt->ehdr_buf_len; pkt->vec_len = iov_copy(pkt->vec + 1, pkt->vec_len_total - 1, - iov, iovcnt, ploff, - pkt->tot_len - pkt->ehdr_buf_len) + 1; + iov, iovcnt, ploff, pllen) + 1; } else { net_rx_pkt_iovec_realloc(pkt, iovcnt); - pkt->tot_len = iov_size(iov, iovcnt) - ploff; + pkt->tot_len = pllen; pkt->vec_len = iov_copy(pkt->vec, pkt->vec_len_total, iov, iovcnt, ploff, pkt->tot_len); }
This is a refactoring commit that does not change behavior. Signed-off-by: Dmitry Fleytman <dmitry@daynix.com> --- hw/net/net_rx_pkt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)