From patchwork Sat Nov 10 12:56:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radoslaw Biernacki X-Patchwork-Id: 150736 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1035014ljp; Sat, 10 Nov 2018 05:13:01 -0800 (PST) X-Google-Smtp-Source: AJdET5de945MwzJwkld7FH1Ik29n3erhaTrijdjdk7Ep1BWTWIMoHGBz5LN6FP9l8m/T5/VEsrH/ X-Received: by 2002:aed:2539:: with SMTP id v54mr12158115qtc.211.1541855581883; Sat, 10 Nov 2018 05:13:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541855581; cv=none; d=google.com; s=arc-20160816; b=pPPpFQYAqzlJsebXKPDL87pvC921M7ZYKzTeqF2V2o5ND3hD6pTP7eOHsDNod/+c6S KOGf0oxlG5DooyMnBm2jFyFNtyFiX+3JDxNpcJO8jIjkO6Qg7la8k1D10iiuJzGYBYht 7fOk8XoyWuNCOE5t78O2UuH5gRXlY694uqQW0Rc003ABLh+2x2D92j8MaVQyiYwq6Vk3 u4H5J0m1AeRO9keKmYacqfP9nQod4qv/yrvWcWoYgpZvoEErc6jhE0AfxnQrMna1MNrz 9fnniJq39GdPJPBEE0P5u35UgpZA487f5ruT4oB+4W25dhAxn2INnwWvlrCO3RjTryDe 5YDw== 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=jlsp0xJgxWF5fDgHZTa02X8K7OzLvYnSCnrnLNM2pQo=; b=gqxztsQDBYvWJSUpoNXvJJGjA7YuX3PFz15LIo7D+NmzCHwW++chHJX2rycbBB5QgI 29C7sMUezQNCZRv4aBALnCSMbVHf9UgygSQbe08nVUb5ddtM/uV6xb8DsJkLyXq/N75x G6xLLga5ZoKajomJn/4ZIa0xtU6fufEkosGFI8y2zcGCun0zeI/F7c4YAyyECxBcw0kQ idlXraIejugwAZGp1jWFy73B+93GuD0qRDD829X5AgRgHI8kyrJGh1EluX0k3SFQRq9D 2lH7WmVWywD8FcGzkPCwFroi/Aapmr4eqUB3vM1NE/YX+CiiVH8EsJLBv8i6qD4Qvqi3 IFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b7AMEUHh; 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 d4si2990801qvn.7.2018.11.10.05.13.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Nov 2018 05:13:01 -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=b7AMEUHh; 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-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 214112D2BF9; Sat, 10 Nov 2018 13:13:00 +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 CB86160C66; Sat, 10 Nov 2018 13:12:59 +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 80965180053A; Sat, 10 Nov 2018 13:12:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAACugN0022806 for ; Sat, 10 Nov 2018 07:56:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7F196101963A; Sat, 10 Nov 2018 12:56:42 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 750261019626 for ; Sat, 10 Nov 2018 12:56:39 +0000 (UTC) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (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 1BA50308AA13 for ; Sat, 10 Nov 2018 12:56:38 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id z13so3195554lfe.11 for ; Sat, 10 Nov 2018 04:56:38 -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=IWjsVxPvjkCLCTPAbNy2vh23hN/jENwJWtqYH5GeQn4=; b=b7AMEUHhYJPvSKqRFJ6fHGII23+IE7rVJ25K4q/E/Of6c3MuZHjFejM7qZXFgb9z7u GWrhk13nYBubUvAYxgGs8s+leRONFRrLRclSkvdQnB4vry5fA/8LVfRlYkI2NKnNdUFp sSwY7lkCYReNrQYTkSU+QuRcaAqt3cSd6xQG8= 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=IWjsVxPvjkCLCTPAbNy2vh23hN/jENwJWtqYH5GeQn4=; b=Lzszj5KINxNuKiJ0DuTZ2bnfLg+u5hGs13NCNJsNXjdaP2DP5WNawT3boLwtoiy5Fm VxscqoKLzTEnE8atSNtZTTMNrx140GLGkwypHZLYHMBA4+HxcoPY/dWOJ998LVwpiFBB mQvs0CRByk2iroB6Ygpa4u6YvnIdSRGj39QWyM7EvXXwq4ucwWYwN+zfQwdVHazvYMDv /m0XtpFCuWE4Dfexejhl/soC6gQvPl0jBDMSZUvk9A6tDbQvd8d5XgiK2soHvdfVafj1 MGItqzD6GNYQOFISz9jQMfADUMGNZZivtpi8X8mJpkpPGIkTAhN3TMEUB54DmtdluNZ7 AN6g== X-Gm-Message-State: AGRZ1gIxa8D/g+k7/V9bp8FMj+YcltREP5ktEk6TDCk8F2vbxruYIFIs Y33NJstj5dVVavamn1qD9TJgZVEnZgU= X-Received: by 2002:a19:f89:: with SMTP id 9mr7201633lfp.10.1541854596096; Sat, 10 Nov 2018 04:56:36 -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 h16-v6sm2145024lfc.0.2018.11.10.04.56.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Nov 2018 04:56:35 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com Date: Sat, 10 Nov 2018 13:56:22 +0100 Message-Id: <20181110125624.1168-3-radoslaw.biernacki@linaro.org> In-Reply-To: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sat, 10 Nov 2018 12:56:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sat, 10 Nov 2018 12:56:38 +0000 (UTC) for IP:'209.85.167.68' DOMAIN:'mail-lf1-f68.google.com' HELO:'mail-lf1-f68.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.167.68 mail-lf1-f68.google.com 209.85.167.68 mail-lf1-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sat, 10 Nov 2018 13:13:00 +0000 (UTC) Removing redundant sections of the code Signed-off-by: Radoslaw Biernacki --- 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 e55c538a29..117ec41869 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1445,30 +1445,12 @@ 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) - return ret; - - 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 -1; - 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; }