mirror of https://gitee.com/openkylin/linux.git
bcache: Avoid nested function definition
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 <pefoley2@pefoley.com> Reviewed-by: Coly Li <colyli@suse.de> Reviewed-by: Michael Lyle <mlyle@lyle.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
515c24c13c
commit
58f913dce2
|
@ -745,6 +745,11 @@ static struct attribute *bch_cache_set_internal_files[] = {
|
||||||
};
|
};
|
||||||
KTYPE(bch_cache_set_internal);
|
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)
|
SHOW(__bch_cache)
|
||||||
{
|
{
|
||||||
struct cache *ca = container_of(kobj, struct cache, kobj);
|
struct cache *ca = container_of(kobj, struct cache, kobj);
|
||||||
|
@ -769,9 +774,6 @@ SHOW(__bch_cache)
|
||||||
CACHE_REPLACEMENT(&ca->sb));
|
CACHE_REPLACEMENT(&ca->sb));
|
||||||
|
|
||||||
if (attr == &sysfs_priority_stats) {
|
if (attr == &sysfs_priority_stats) {
|
||||||
int cmp(const void *l, const void *r)
|
|
||||||
{ return *((uint16_t *) r) - *((uint16_t *) l); }
|
|
||||||
|
|
||||||
struct bucket *b;
|
struct bucket *b;
|
||||||
size_t n = ca->sb.nbuckets, i;
|
size_t n = ca->sb.nbuckets, i;
|
||||||
size_t unused = 0, available = 0, dirty = 0, meta = 0;
|
size_t unused = 0, available = 0, dirty = 0, meta = 0;
|
||||||
|
@ -800,7 +802,7 @@ SHOW(__bch_cache)
|
||||||
p[i] = ca->buckets[i].prio;
|
p[i] = ca->buckets[i].prio;
|
||||||
mutex_unlock(&ca->set->bucket_lock);
|
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 &&
|
while (n &&
|
||||||
!cached[n - 1])
|
!cached[n - 1])
|
||||||
|
|
Loading…
Reference in New Issue