From patchwork Fri Oct 13 23:35:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10006115 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 5EC1760230 for ; Fri, 13 Oct 2017 23:36:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EBC629009 for ; Fri, 13 Oct 2017 23:36:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 431D729190; Fri, 13 Oct 2017 23:36:06 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A502729009 for ; Fri, 13 Oct 2017 23:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879AbdJMXf7 (ORCPT ); Fri, 13 Oct 2017 19:35:59 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:52321 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751391AbdJMXf6 (ORCPT ); Fri, 13 Oct 2017 19:35:58 -0400 Received: by mail-pg0-f66.google.com with SMTP id a192so914678pge.9 for ; Fri, 13 Oct 2017 16:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+jW+AgaYx0uEMW0UPbw8P+aRXZWsT0ef/IKeqEoDEwc=; b=mHT4lVIimGQqd2cKl1TlcP+J1uxitR0zbzbO2VjNwmxbA8jkAEE3WRdJTsSBSv6ik1 8VR1Il0Cs6FHRl/nZ5AkcFEzkr9bexfm3h4MQpfejrKpzocIbRzrFepUCiDY1DIYq+XW Mt/jVQZy7XUMECzUfx7uvRUnnEyEkDvDzNkeMQz1pwI1QfCvMM2ryPvE0pKESK29aOgr xqi+OakIc+tYMc4Oesg5lpdwyG0ZvEiriy9nm8fUNA441lo+NGYuRfFMWsC3rVTtThag 0RiurLuYVe5vO0izPUE2EcDRYHBbAZZXz7YyoffVK/5LIBMqxF6vokXLM0SURYUXbk+8 hF3A== 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=+jW+AgaYx0uEMW0UPbw8P+aRXZWsT0ef/IKeqEoDEwc=; b=YpLzMEXmC5mHSeh5X4V+JwgCWrhKjaZYxuStlz2fB8ucB4RK/y7rjmHeBpUs1zV70j SVjlUXyHZZXEAk9AxaDNVlq+8Uz9qGXkqeCfFpCjMqA+kvJy7Y2k/zQxv4e6oRY/rVxx b+tKqhwzZiXYQxYK+Z8nlApHRMktYIlG/33E7rKDcZf4yid3oX/9AIvwq0skiRp47Gya Kl9ViKo4vCGaSnHbsAsPfxjueHe3B6mACRca12Ki2K1UYIR32bPpg4M9eXLDzIL7Wf/k AEFi5bequ+v2R08biy1r3nQVaKyUN5P0p3J8u1SU+m7Moi3PqZqzXkBfTazfEhtgPVDv 0jjw== X-Gm-Message-State: AMCzsaXvzVbyComXf54Zr8ct+jf46A07YbcHEW5HPRoTGXaG1lGHcOpZ effLO8ahHlVFqv/dfpq2LSIP5Q== X-Google-Smtp-Source: AOwi7QCC7nm3He7lqNmur6NxqsedHgIqw7ICL+1bkUlFZduO1FYJog+0L/V/yXj7prmLl6RhT3WA4Q== X-Received: by 10.159.245.129 with SMTP id a1mr2688085pls.394.1507937757914; Fri, 13 Oct 2017 16:35:57 -0700 (PDT) Received: from localhost.localdomain (68-189-67-104.dhcp.prtv.ca.charter.com. [68.189.67.104]) by smtp.gmail.com with ESMTPSA id 74sm4950718pft.184.2017.10.13.16.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 16:35:57 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Peter Foley Subject: [PATCH 01/15] bcache: Avoid nested function definition Date: Fri, 13 Oct 2017 16:35:28 -0700 Message-Id: <20171013233542.20938-2-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013233542.20938-1-mlyle@lyle.org> References: <20171013233542.20938-1-mlyle@lyle.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Foley Fixes below error with clang: ../drivers/md/bcache/sysfs.c:759:3: error: function definition is not allowed here { return *((uint16_t *) r) - *((uint16_t *) l); } ^ ../drivers/md/bcache/sysfs.c:789:32: error: use of undeclared identifier 'cmp' sort(p, n, sizeof(uint16_t), cmp, NULL); ^ 2 errors generated. v2: rename function to __bch_cache_cmp Signed-off-by: Peter Foley Reviewed-by: Coly Li Reviewed-by: Michael Lyle --- drivers/md/bcache/sysfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 104c57cd666c..69f355b9650c 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -745,6 +745,11 @@ static struct attribute *bch_cache_set_internal_files[] = { }; KTYPE(bch_cache_set_internal); +static int __bch_cache_cmp(const void *l, const void *r) +{ + return *((uint16_t *)r) - *((uint16_t *)l); +} + SHOW(__bch_cache) { struct cache *ca = container_of(kobj, struct cache, kobj); @@ -769,9 +774,6 @@ SHOW(__bch_cache) CACHE_REPLACEMENT(&ca->sb)); if (attr == &sysfs_priority_stats) { - int cmp(const void *l, const void *r) - { return *((uint16_t *) r) - *((uint16_t *) l); } - struct bucket *b; size_t n = ca->sb.nbuckets, i; size_t unused = 0, available = 0, dirty = 0, meta = 0; @@ -800,7 +802,7 @@ SHOW(__bch_cache) p[i] = ca->buckets[i].prio; mutex_unlock(&ca->set->bucket_lock); - sort(p, n, sizeof(uint16_t), cmp, NULL); + sort(p, n, sizeof(uint16_t), __bch_cache_cmp, NULL); while (n && !cached[n - 1])