Skip to content

Commit 83ff931

Browse files
Coly Liaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 9951379 commit 83ff931

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/bcache/stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void bch_cache_accounting_clear(struct cache_accounting *acc)
111111
{
112112
memset(&acc->total.cache_hits,
113113
0,
114-
sizeof(unsigned long) * 7);
114+
sizeof(struct cache_stats));
115115
}
116116

117117
void bch_cache_accounting_destroy(struct cache_accounting *acc)

0 commit comments

Comments
 (0)