From patchwork Thu Feb 16 12:29:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Fleytman X-Patchwork-Id: 9577025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1775260244 for ; Thu, 16 Feb 2017 12:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE787285BA for ; Thu, 16 Feb 2017 12:40:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE1E0285BD; Thu, 16 Feb 2017 12:40:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4DA7E285BA for ; Thu, 16 Feb 2017 12:40:02 +0000 (UTC) Received: from localhost ([::1]:46163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceLLt-000429-3d for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Feb 2017 07:40:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceLD1-0003hu-EE for qemu-devel@nongnu.org; Thu, 16 Feb 2017 07:30:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceLD0-00088X-Hk for qemu-devel@nongnu.org; Thu, 16 Feb 2017 07:30:51 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceLD0-00088F-B2 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 07:30:50 -0500 Received: by mail-wr0-x241.google.com with SMTP id c4so1878589wrd.1 for ; Thu, 16 Feb 2017 04:30:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xCR8+AVqlW+fXaY/4OUYVvWyf9jLhpZuxpcZcqtYiIA=; b=RRd/vrs2Kc7R00mMNLE1aeRR7/aa3ffAkZ+vJOEsvViNJFrmNCT+7wkA2f1j/RweSg NZ1WtwcxWjJVJwa5jEK/2JXG66g0fZzFwSdqb8XyT3OIEpG7kTgAmeEX6lP5HyIciWdw tgUFKqzzqksNguJhDTXwFXHrDlQf0BAulYqJm/Ta8oPycDgrbjlI1d4Y/QG4KYg3Rg5m N5rnjtIH4vfSYGNxmyKTyBfaXPb1ovDctXA5k0to7HHvb91m40OnBl4dPKEd1DIC1q0a TolQLPxKxzujWx0iuknaAQevzoGKjVEHXgOGepbriaOpji1tiTo9KYAstNuqXg2aBCfb eAUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xCR8+AVqlW+fXaY/4OUYVvWyf9jLhpZuxpcZcqtYiIA=; b=Xvru2zdatIcYIFfx2JPM1qbn/MCgmFc0GHsvk7r/0QxODdGIWpFl1SErEog3EwrT3Y BtENnMimBfFEQWOlkfC7LEqsuqc1cGbEnEtKnLKve1P1uvXSq0HFYsK9pP0euZHgY6Pu wCEk3h75s3/jPBufV6oaToEAv+3Svmm6lTmUfamNsNirjcyS6dxFTCOfTqMgg966Kz2l GUQ+rkip+n8N//5RJckGBEEfVm99K+IloDMdfCBqXX9pD8d5GnlW0DRyA3mXLfemsErT NwUlwanXIBxh+glXGIPIxzSWaUb4nwcl/1KNn+rn9mdtlUYVCTdPyTuFGnoLzYyd86Gs svoQ== X-Gm-Message-State: AMke39nW2pobDlksdFnUnX2hBxiqU0ZiyaztnSaKvSqdjI6ZIRwWtdq+pvaW+lQI4AUiwA== X-Received: by 10.223.163.136 with SMTP id l8mr2281983wrb.42.1487248249352; Thu, 16 Feb 2017 04:30:49 -0800 (PST) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id b51sm8827365wrd.39.2017.02.16.04.30.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 04:30:48 -0800 (PST) From: Dmitry Fleytman To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 14:29:36 +0200 Message-Id: <1487248176-29602-6-git-send-email-dmitry@daynix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487248176-29602-1-git-send-email-dmitry@daynix.com> References: <1487248176-29602-1-git-send-email-dmitry@daynix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH 5/5] NetRxPkt: Remove code duplication in net_rx_pkt_pull_data() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Dmitry Fleytman , Jason Wang , P J P Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is a refactoring commit that does not change behavior. Signed-off-by: Dmitry Fleytman Reviewed-by: Philippe Mathieu-Daudé --- 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); }