diff options
author | Colin Ian King <colin.king@canonical.com> | 2016-09-19 15:34:08 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-09-19 16:19:40 +0200 |
commit | 60658e0dc1df058607990278fdf9d831e0c2c71a (patch) | |
tree | 8518edd7779ec1bec41d674f77956672edf37989 /lib/sbitmap.c | |
parent | sbitmap: don't update the allocation hint on clear after resize (diff) | |
download | linux-60658e0dc1df058607990278fdf9d831e0c2c71a.tar.xz linux-60658e0dc1df058607990278fdf9d831e0c2c71a.zip |
sbitmap: initialize weight to zero
Variable weight is not being initialized to zero before it is
used to compute the weight sum. Ensure it is initialized to zero.
Found with static analysis with cppcheck:
[lib/sbitmap.c:177]: (error) Uninitialized variable: weight
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'lib/sbitmap.c')
-rw-r--r-- | lib/sbitmap.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sbitmap.c b/lib/sbitmap.c index e40808921544..2cecf05c82fd 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -169,7 +169,7 @@ EXPORT_SYMBOL_GPL(sbitmap_any_bit_clear); unsigned int sbitmap_weight(const struct sbitmap *sb) { - unsigned int i, weight; + unsigned int i, weight = 0; for (i = 0; i < sb->map_nr; i++) { const struct sbitmap_word *word = &sb->map[i]; |