From: Matthias Kaehlcke <mka@chromium.org>
To: Kent Overstreet <kent.overstreet@gmail.com>,
Shaohua Li <shli@kernel.org>, Coly Li <colyli@suse.de>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org,
linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
q^Center Roeck <groeck@chromium.org>,
Behan Webster <behanw@converseincode.com>,
Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH] bcache: Remove nested function from sysfs
Date: Fri, 6 Oct 2017 14:35:00 -0700 [thread overview]
Message-ID: <20171006213500.88230-1-mka@chromium.org> (raw)
From: Behan Webster <behanw@converseincode.com>
Replace the use of nested functions where a normal function will
suffice.
Nested functions are not liked by upstream kernel developers in
general. Their use breaks the use of clang as a compiler, and
doesn't make the code any better.
This code now works for both gcc and clang.
From: Behan Webster <behanw@converseincode.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
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..440c3906f852 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])
--
2.14.2.920.gcf0c67979c-goog
next reply other threads:[~2017-10-06 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 21:35 Matthias Kaehlcke [this message]
2017-10-07 2:33 ` [PATCH] bcache: Remove nested function from sysfs Coly Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171006213500.88230-1-mka@chromium.org \
--to=mka@chromium.org \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=behanw@converseincode.com \
--cc=colyli@suse.de \
--cc=groeck@chromium.org \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=shli@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox