From patchwork Thu Apr 7 09:40:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Liu X-Patchwork-Id: 8770171 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5C7679FC82 for ; Thu, 7 Apr 2016 09:43:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 887CD2011E for ; Thu, 7 Apr 2016 09:43:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD828200E8 for ; Thu, 7 Apr 2016 09:43:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ao6R4-0005bH-CX; Thu, 07 Apr 2016 09:41:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ao6R2-0005aA-Gl for xen-devel@lists.xen.org; Thu, 07 Apr 2016 09:41:08 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 87/FC-03786-33B26075; Thu, 07 Apr 2016 09:41:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRWlGSWpSXmKPExsXS6fhLStdYmy3 c4NdJEYslHxezODB6HN39mymAMYo1My8pvyKBNWPNz1tsBae4K+b9amNpYHzP0cXIySEksJZR 4sQ/YRCbTUBJ4u2v1ewgtoiAtMS1z5cZuxi5OJgFZjBKfHm9gQkkISxgK/HlzBFmEJtFQFVi/ fSbbCA2r4CdxOU3/WBxCQE5ifPHf4LZnAL2EutnPmGBWGYn0dAwnXECI9cCRoZVjBrFqUVlqU W6hmZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiBfmQAgh2M5097HmKU5GBSEuU 9K8UWLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCV1MLKCdYlJqeWpGWmQMMKJi0BAePkgjvSpA0 b3FBYm5xZjpE6hSjopQ4rxxIQgAkkVGaB9cGC+JLjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUE uZ1AZnCk5lXAjf9FdBiJqDFF/jBFpckIqSkGhg9/J6rPpxQbHl8G/dfnslTfTe0ck5qXDwjPH fnsrWJucF+HMuPG28UbGs2rLOPVvTgY/36bEnoY+FtxQbaFxVDlK4tPMqxpM35zs4EhZC27Lc P9/99msIYP/fyqs6o0H2r6uNSo7hC5k/Y2199o3hjc7XH6cD+LUYR20Wvt2mV3CjoXCCxVEiJ pTgj0VCLuag4EQAbc4aFXQIAAA== X-Env-Sender: cyliu@suse.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1460022065!33148200!1 X-Originating-IP: [137.65.250.26] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61282 invoked from network); 7 Apr 2016 09:41:07 -0000 Received: from prv3-mh.provo.novell.com (HELO prv3-mh.provo.novell.com) (137.65.250.26) by server-6.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Apr 2016 09:41:07 -0000 Received: from linux-3hvf.site (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Thu, 07 Apr 2016 03:40:53 -0600 From: Chunyan Liu To: xen-devel@lists.xen.org Date: Thu, 7 Apr 2016 17:40:27 +0800 Message-Id: <1460022028-25174-4-git-send-email-cyliu@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460022028-25174-1-git-send-email-cyliu@suse.com> References: <1460022028-25174-1-git-send-email-cyliu@suse.com> Cc: Simon Cao , Ian Jackson , Chunyan Liu , George Dunlap Subject: [Xen-devel] [PATCH 3/4] cleanup redundant lstat in libxl_pvusb.c X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CID: 1358112 Signed-off-by: Chunyan Liu CC: Simon Cao CC: George Dunlap CC: Ian Jackson Acked-by: Ian Jackson --- tools/libxl/libxl_pvusb.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_pvusb.c b/tools/libxl/libxl_pvusb.c index 45117cf..02d3e55 100644 --- a/tools/libxl/libxl_pvusb.c +++ b/tools/libxl/libxl_pvusb.c @@ -983,25 +983,14 @@ static char *usbdev_busid_from_ctrlport(libxl__gc *gc, uint32_t domid, static int usbintf_get_drvpath(libxl__gc *gc, const char *intf, char **drvpath) { char *spath, *dp = NULL; - struct stat st; - int r; spath = GCSPRINTF(SYSFS_USB_DEV "/%s/driver", intf); - r = lstat(spath, &st); - if (r == 0) { - /* Find the canonical path to the driver. */ - dp = libxl__zalloc(gc, PATH_MAX); - dp = realpath(spath, dp); - if (!dp) { - LOGE(ERROR, "get realpath failed: '%s'", spath); - return ERROR_FAIL; - } - } else if (errno == ENOENT) { - /* driver path doesn't exist */ - dp = NULL; - } else { - LOGE(ERROR, "lstat failed: '%s'", spath); + /* Find the canonical path to the driver. */ + dp = libxl__zalloc(gc, PATH_MAX); + dp = realpath(spath, dp); + if (!dp && errno != ENOENT) { + LOGE(ERROR, "get realpath failed: '%s'", spath); return ERROR_FAIL; }