From: Coly Li <i@coly.li>
To: Peter Foley <pefoley2@pefoley.com>,
shli@kernel.org, linux-bcache@vger.kernel.org,
linux-raid@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kent.overstreet@gmail.com
Subject: Re: [PATCH] Avoid nested function definition
Date: Sun, 27 Nov 2016 12:06:04 +0800 [thread overview]
Message-ID: <9a8a84ed-ecf7-b1dd-59e8-1a36dbcef088@coly.li> (raw)
In-Reply-To: <20161126222415.13404-1-pefoley2@pefoley.com>
On 2016/11/27 上午6:24, Peter Foley wrote:
> 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.
>
> Signed-off-by: Peter Foley <pefoley2@pefoley.com>
> ---
> drivers/md/bcache/sysfs.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index b3ff57d61dde..22ac9e6676a0 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -731,6 +731,11 @@ static struct attribute *bch_cache_set_internal_files[] = {
> };
> KTYPE(bch_cache_set_internal);
>
> +static int 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);
> @@ -755,9 +760,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;
>
I agree with this fix. Anyway, Can we use a more unique name like
__bch_cache_cmp() ?
Thanks.
--
Coly Li
next prev parent reply other threads:[~2016-11-27 5:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-26 22:24 Peter Foley
2016-11-27 4:06 ` Coly Li [this message]
2016-11-28 2:50 ` [PATCH v2] " Peter Foley
2016-11-28 3:06 ` 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=9a8a84ed-ecf7-b1dd-59e8-1a36dbcef088@coly.li \
--to=i@coly.li \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=pefoley2@pefoley.com \
--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
all inboxes | Powered by JetHome®