Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1530787
| From | Peter Foley <pefoley2@pefoley.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] Avoid nested function definition |
| Date | 2016-11-26 23:30 +0100 |
| Message-ID | <sHTDQ-47v-15@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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;
--
2.11.0.rc2
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] Avoid nested function definition Peter Foley <pefoley2@pefoley.com> - 2016-11-26 23:30 +0100
Re: [PATCH] Avoid nested function definition Coly Li <i@coly.li> - 2016-11-27 06:10 +0100
[PATCH v2] Avoid nested function definition Peter Foley <pefoley2@pefoley.com> - 2016-11-28 04:00 +0100
Re: [PATCH v2] Avoid nested function definition Coly Li <i@coly.li> - 2016-11-28 04:10 +0100
csiph-web