From patchwork Sat Nov 17 19:51:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radoslaw Biernacki X-Patchwork-Id: 151423 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp904399ljp; Sat, 17 Nov 2018 13:09:35 -0800 (PST) X-Google-Smtp-Source: AJdET5dgTWKI7NNUk+G5kItileQjc+4rS6CX5Ufw9S0Sf8I/rN1AMoicDJYN2eOfrrrttLvXam0j X-Received: by 2002:aed:3084:: with SMTP id 4mr11232453qtf.30.1542488975165; Sat, 17 Nov 2018 13:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542488975; cv=none; d=google.com; s=arc-20160816; b=kS7uLUzO6JqINCgP36Ln1wEkf9Xe4Bs2Yz1N5fLh94gr8kYsriAFNwltElIvzZdYw+ disl3b2PPu2HDXNImr4mwUCT0n1Bi3u4FKFQUJh2hpbQyhPwDjCVACU5r/Vhy4vW2Rlf hwr11q/h0fyBQGkhyjj0qVsjRQRihoU65wQLlOcfD884re7aGf255GOFP1miJyWMDOqQ +X6wLypu3AKcbc7lLnsiL5+q/mO+ZZcTmYeFeIWSrcFgGJ2F3kXrHuSHsFQYrDTu5Xdc TMsqMgYd8pmvHAEZDHzdtBJiEYivEDQkehL+pwJXpOSDlO6X9U2M0Tej4M7NCJRtp6cE igrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=a/7eaEHU6p0zu+7zqf0GKi/4Pbp4jKqcRK7cNQp7JXM=; b=C/KS5EP1EHaKv32Z6voTQhHhFIQdqZPzBGSdDTzoDnoVU7b+0xCBN353DrFk4UMDFt cWiyh8dotLmM1deUYgfr0mUGq/6XGWvobK5oIqXVXAOCCzv0A8plFzQ0A68NiUTcvCMs qzxHXBFSrFABO3wW9Iwo0BhsSOEp7kRrO68cmH1h7Kj28vr7EhwsvdUXAgfzxSLAAzSZ +KGbN1I6wVaxf+1G6vRHNvJ/bxsl94G3aCFWyhu1/vwRGURVgPoDU6Be6znOWyhkM9iQ EPMdXYl1jSdyapIYz7dA4CXmv8lfjdhi9KGECMQiL1IOmnF8+oRYY8W3pvaYfHc2uBMD IQvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QX11F3GT; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i13si1714346qvj.139.2018.11.17.13.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 13:09:35 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QX11F3GT; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 826263083392; Sat, 17 Nov 2018 21:09:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51B2217249; Sat, 17 Nov 2018 21:09:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0810C18005B1; Sat, 17 Nov 2018 21:09:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAHJpOou029178 for ; Sat, 17 Nov 2018 14:51:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7022C60BF1; Sat, 17 Nov 2018 19:51:24 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6497065F4C for ; Sat, 17 Nov 2018 19:51:23 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA2EC3DDB6 for ; Sat, 17 Nov 2018 19:51:21 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f4so9586466edq.10 for ; Sat, 17 Nov 2018 11:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kVZfDwJ2r7m+ojDZr9hYdZNb8P6V0m1xH6zGF0YyfXc=; b=QX11F3GTiuYnJpAl9JFbH+hlx/qZt0IJaKsoLRggYesMAhRtnA87op/Vq+f9/Rasvj bCPUU2lTwy20xLbqXThOrBEFwQEvDN7XRJTHw7fEoE5kesPVGAml8DwEfr1o0NVOP6xd M1cdQZUv84JmjEJdbOvpyVbrntB7wiA8O8Do4= 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=kVZfDwJ2r7m+ojDZr9hYdZNb8P6V0m1xH6zGF0YyfXc=; b=g5F2ndszmk85Bak2/IFU33fqdd0SXszlF1Toh/1gEeuYqffaUEGvgtuilS8OjxDbYm 8mxcgJ+DlRXLFN8szSmP5QVPGCYFw9aYwmLGpCABNR773cK6rgfzWxj+HF9pzZpCgpXU sLmedy77G6p9yJJw2r9eT7adF/zmzt6ubEmGVu8P+ng/3zierpc61o5Ybwl4EWJn4WLV Jm+BSq4gGbOFYt+ioi+OXA1h4l9V6uBqz8sDTZb987/mZdPeb0PcwolC/QhHgim1ONnR YZimJw34MTHazMmlj0B6yawiRe9fZCOuU8AqmnrnkmQiCinCtXgwF97xu/90/Fwlc22x DbZA== X-Gm-Message-State: AA+aEWaq0IOzC3WxyFCInF7m5KDpwz08RUMA7s3TP6IpOV9bxqZOP9WC H/ZNn/L0tf/L/XdkoAr5r6/ku1SSEoM= X-Received: by 2002:a50:b902:: with SMTP id m2mr4646682ede.108.1542484280308; Sat, 17 Nov 2018 11:51:20 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s12sm7887633edb.43.2018.11.17.11.51.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 11:51:19 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com, mprivozn@redhat.com Date: Sat, 17 Nov 2018 20:51:11 +0100 Message-Id: <20181117195113.12544-3-radoslaw.biernacki@linaro.org> In-Reply-To: <20181117195113.12544-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> <20181117195113.12544-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Nov 2018 19:51:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Nov 2018 19:51:22 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'radoslaw.biernacki@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.112 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v2 2/4] util: Code simplification X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sat, 17 Nov 2018 21:09:34 +0000 (UTC) Removing redundant sections of the code Signed-off-by: Radoslaw Biernacki Reviewed-by: Michal Privoznik --- src/util/virnetdev.c | 40 +++----------------- 1 file changed, 5 insertions(+), 35 deletions(-) -- 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index f1c2ba8c17..9318de406c 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1441,34 +1441,16 @@ int virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname, int *vf) { - char *pf_sysfs_path = NULL, *vf_sysfs_path = NULL; - int ret = -1; - *pfname = NULL; if (virNetDevGetPhysicalFunction(vfname, pfname) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot get PF netdev name for VF %s"), vfname); - return ret; + return -1; } - if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0) - goto cleanup; - - if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0) - goto cleanup; - - ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf); - - cleanup: - if (ret < 0) - VIR_FREE(*pfname); - - VIR_FREE(vf_sysfs_path); - VIR_FREE(pf_sysfs_path); - - return ret; + return virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf); } #else /* !__linux__ */ @@ -1863,13 +1845,9 @@ virNetDevSaveNetConfig(const char *linkdev, int vf, * it to PF + VFname */ - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf)) goto cleanup; - pfDevName = pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } if (pfDevName) { @@ -2021,13 +1999,9 @@ virNetDevReadNetConfig(const char *linkdev, int vf, * it to PF + VFname */ - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf)) goto cleanup; - pfDevName = pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; } /* if there is a PF, it's now in pfDevName, and linkdev is either @@ -2226,13 +2200,9 @@ virNetDevSetNetConfig(const char *linkdev, int vf, * it to PF + VFname */ - if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) + if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf)) goto cleanup; - pfDevName = pfDevOrig; - - if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0) - goto cleanup; }