From patchwork Wed Apr 20 08:03:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulina Szubarczyk X-Patchwork-Id: 8886741 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 DF91A9F39A for ; Wed, 20 Apr 2016 08:07:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F09982025A for ; Wed, 20 Apr 2016 08:07:28 +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 14FB22024D for ; Wed, 20 Apr 2016 08:07:28 +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 1asn8T-0006Ei-RV; Wed, 20 Apr 2016 08:05:21 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asn8S-0006EV-Fu for xen-devel@lists.xenproject.org; Wed, 20 Apr 2016 08:05:20 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 3E/46-14148-F3837175; Wed, 20 Apr 2016 08:05:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsVyMfTmGl17C/F wgyVT+C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oz9rXNYC54LVvR13WNsYJzC28XIxSEkMJ1R 4uHz4ywgDovASxaJ33/nMoE4EgL9rBK/NzwAynACOTESTzqvs0PYlRJ75i5gBbGFBLQkLq1cw QIxaiqTROv/6WBFbAJmEjMn/wRrFhEIl3jbv4MZpIhZYA6jxP53V9lAEsICwRJXfk5lBrFZBF Qldr29AzaVV8Bb4uehHUwQ2+QkTh6bDBTn4OAU8JHovh8MYgoBlVzekTuBUWABI8MqRo3i1KK y1CJdQwu9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYzA0GIAgh2MTds9DzFKcjAp ifKqCoiHC/El5adUZiQWZ8QXleakFh9ilOHgUJLg5TcHygkWpaanVqRl5gCDHCYtwcGjJMLLC 5LmLS5IzC3OTIdInWI05tjy+9paJo5tU++tZRJiycvPS5US531mBlQqAFKaUZoHNwgWfZcYZa WEeRmBThPiKUgtys0sQZV/xSjOwagkzPsEZApPZl4J3L5XQKcwAZ3Cf1cU5JSSRISUVAOjhB6 35JnUVwcOtcZwbma8ukNR02tLg+LUirPPDs+5G5/pWuVicW1v1DzuBb5xy8Jq3KtPX9ji/yF0 zS/OdVbeq73EbudHX7xyqlHziuqPBTdqRCxd2lOD43XkL3578eURv9SRZ+qbv3+++Pmf9hfbS c9X+oQ6tbduP/I4w/BIddLaPwe9vUVYlFiKMxINtZiLihMB81c6rrkCAAA= X-Env-Sender: paulinaszubarczyk@gmail.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1461139518!35499473!1 X-Originating-IP: [209.85.217.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52697 invoked from network); 20 Apr 2016 08:05:19 -0000 Received: from mail-lb0-f172.google.com (HELO mail-lb0-f172.google.com) (209.85.217.172) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 Apr 2016 08:05:19 -0000 Received: by mail-lb0-f172.google.com with SMTP id u8so4885407lbk.0 for ; Wed, 20 Apr 2016 01:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YLrIKP1BRDGZ9/tWd47mxFFr8HVnyxOyjrL/MaXrsDg=; b=pdm8nr8FSbOFwmmAbFsxCEJnyqsAC6zA+EMC6SFkWV27KDGz1OAk4ryfuhdXakYe+D YQFQYYYCjwEr6twxDaXuqpe2yDg/u4qdB3sOGGenQSe9673sAqcs4gW48GLuAHETd0y3 sJn0tTMxhfK/eG/bmHKEldjFqRgLG/ty5pS4icsQ/cyWIqgx2g1TtFusihgsEpOckGkY xySplP+JiBtxakct/iGP/ElXFUtjdNaP+OL/iiSQ8k9I3hA9uQEzg0ELEXj9jL+Gm7bP uHv1eMZ9FnBk+1pPyX+ybPzMi8ZkbNYWjxD/mMubIHWOt+aJDJbHwrssYQHwrNZEbd1M oFmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YLrIKP1BRDGZ9/tWd47mxFFr8HVnyxOyjrL/MaXrsDg=; b=bA6vrY8BTodIVS0Qv9QKdO60iC59eU8M8XMfpJR7WjedqDhoOgH270Was9nKMywwmk DgHB3+fVeN0VpIqMUGbVPGmWVhWgstsennwoQUAWSEsB/PV8HvSGDt/Zb3eGpf6ST2kO 7jCfNbsQHQ8Fdj1FxcQl3AQosxH5Xj4bIfBBL2MZL7A2qSTgZ7sbuat0Bhj/on5eqQ5q Lij2YZ+ZnNUwVxny41A9tY/3UrXgw8g+MpSOEkJRe93ntRisf6LeuhNRwvkLh4oBC+xy Ozyn6VkoQYjuW/ZDYUL3yOPnMWZfjrBNt4Z1+AqIRbgEux2dfO1Hm/OUgaS7DfX+se6K awGA== X-Gm-Message-State: AOPr4FU/eQlJx8D/75Z0+DkZdAk5FpSKu9ho6nu3eHbLWGCQj5o83zXi95MdMZ14h565jw== X-Received: by 10.112.227.71 with SMTP id ry7mr2998503lbc.78.1461139518683; Wed, 20 Apr 2016 01:05:18 -0700 (PDT) Received: from localhost.localdomain (84-10-74-207.static.chello.pl. [84.10.74.207]) by smtp.gmail.com with ESMTPSA id o10sm820613lbp.47.2016.04.20.01.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Apr 2016 01:05:17 -0700 (PDT) From: Paulina Szubarczyk To: xen-devel@lists.xenproject.org, roger.pau@citrix.com, George.Dunlap@eu.citrix.com Date: Wed, 20 Apr 2016 10:03:59 +0200 Message-Id: <1461139444-12342-3-git-send-email-paulinaszubarczyk@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461139444-12342-1-git-send-email-paulinaszubarczyk@gmail.com> References: <1461139444-12342-1-git-send-email-paulinaszubarczyk@gmail.com> Cc: ian.jackson@eu.citrix.com, dario.faggioli@citrix.com, wei.liu2@citrix.com, ian.campbell@citrix.com, Paulina Szubarczyk Subject: [Xen-devel] [PATCH v3 2/7] libxl: style cleanups in libxl_device_pci_assignable_list() 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 Various coding style compliance cleanups, such as, arranging for using only one path out of the function, whitespaces in loops ad if-s and r instead of rc for storing non-libxl error codes. Signed-off-by: Paulina Szubarczyk --- Changes since v2: - changed the changelog --- tools/libxl/libxl_pci.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index b4be967..6ac0a92 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -398,34 +398,34 @@ libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *num) libxl_device_pci *pcidevs = NULL, *new, *assigned; struct dirent *de; DIR *dir; - int rc, num_assigned; + int r, num_assigned; *num = 0; - rc = get_all_assigned_devices(gc, &assigned, &num_assigned); - if ( rc ) - goto out; + r = get_all_assigned_devices(gc, &assigned, &num_assigned); + if (r) goto out; dir = opendir(SYSFS_PCIBACK_DRIVER); - if ( NULL == dir ) { - if ( errno == ENOENT ) { + if (NULL == dir) { + if (errno == ENOENT) { LOG(ERROR, "Looks like pciback driver not loaded"); - }else{ + } else { LOGE(ERROR, "Couldn't open %s", SYSFS_PCIBACK_DRIVER); } - goto out_closedir; + closedir(dir); + goto out; } - while( (de = readdir(dir)) ) { + while((de = readdir(dir))) { unsigned dom, bus, dev, func; - if ( sscanf(de->d_name, PCI_BDF, &dom, &bus, &dev, &func) != 4 ) + if (sscanf(de->d_name, PCI_BDF, &dom, &bus, &dev, &func) != 4) continue; - if ( is_pcidev_in_array(assigned, num_assigned, dom, bus, dev, func) ) + if (is_pcidev_in_array(assigned, num_assigned, dom, bus, dev, func)) continue; new = realloc(pcidevs, ((*num) + 1) * sizeof(*new)); - if ( NULL == new ) + if (NULL == new) continue; pcidevs = new; @@ -436,8 +436,6 @@ libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *num) (*num)++; } -out_closedir: - closedir(dir); out: GC_FREE; return pcidevs;