diff options
author | Coly Li <colyli@suse.de> | 2019-02-09 05:52:54 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-02-09 15:18:31 +0100 |
commit | 83ff9318c44babe32da0947d81443bad82da2d44 (patch) | |
tree | cfef8628087b108de2e1c8bbf82fabfaa92b3cc9 /drivers/md | |
parent | bcache: never writeback a discard operation (diff) | |
download | linux-83ff9318c44babe32da0947d81443bad82da2d44.tar.xz linux-83ff9318c44babe32da0947d81443bad82da2d44.zip |
bcache: not use hard coded memset size in bch_cache_accounting_clear()
In stats.c:bch_cache_accounting_clear(), a hard coded number '7' is
used in memset(). It is because in struct cache_stats, there are 7
atomic_t type members. This is not good when new members added into
struct stats, the hard coded number will only clear part of memory.
This patch replaces 'sizeof(unsigned long) * 7' by more generic
'sizeof(struct cache_stats))', to avoid potential error if new
member added into struct cache_stats.
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/stats.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index 894410f3f829..ba1c93791d8d 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c @@ -111,7 +111,7 @@ void bch_cache_accounting_clear(struct cache_accounting *acc) { memset(&acc->total.cache_hits, 0, - sizeof(unsigned long) * 7); + sizeof(struct cache_stats)); } void bch_cache_accounting_destroy(struct cache_accounting *acc) |