linux/drivers/md/bcache
Arnd Bergmann 78d4eb8ad9 bcache: avoid clang -Wunintialized warning
clang has identified a code path in which it thinks a
variable may be unused:

drivers/md/bcache/alloc.c:333:4: error: variable 'bucket' is used uninitialized whenever 'if' condition is false
      [-Werror,-Wsometimes-uninitialized]
                        fifo_pop(&ca->free_inc, bucket);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/md/bcache/util.h:219:27: note: expanded from macro 'fifo_pop'
 #define fifo_pop(fifo, i)       fifo_pop_front(fifo, (i))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/md/bcache/util.h:189:6: note: expanded from macro 'fifo_pop_front'
        if (_r) {                                                       \
            ^~
drivers/md/bcache/alloc.c:343:46: note: uninitialized use occurs here
                        allocator_wait(ca, bch_allocator_push(ca, bucket));
                                                                  ^~~~~~
drivers/md/bcache/alloc.c:287:7: note: expanded from macro 'allocator_wait'
                if (cond)                                               \
                    ^~~~
drivers/md/bcache/alloc.c:333:4: note: remove the 'if' if its condition is always true
                        fifo_pop(&ca->free_inc, bucket);
                        ^
drivers/md/bcache/util.h:219:27: note: expanded from macro 'fifo_pop'
 #define fifo_pop(fifo, i)       fifo_pop_front(fifo, (i))
                                ^
drivers/md/bcache/util.h:189:2: note: expanded from macro 'fifo_pop_front'
        if (_r) {                                                       \
        ^
drivers/md/bcache/alloc.c:331:15: note: initialize the variable 'bucket' to silence this warning
                        long bucket;
                                   ^

This cannot happen in practice because we only enter the loop
if there is at least one element in the list.

Slightly rearranging the code makes this clearer to both the
reader and the compiler, which avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-24 10:56:27 -06:00
..
alloc.c bcache: avoid clang -Wunintialized warning 2019-04-24 10:56:27 -06:00
bcache.h bcache: option to automatically run gc thread after writeback 2018-12-13 08:15:54 -07:00
bset.c bcache: fix code comments style 2018-08-11 15:46:42 -06:00
bset.h bcache: style fixes for lines over 80 characters 2018-08-11 15:46:41 -06:00
btree.c block: allow bio_for_each_segment_all() to iterate over multi-page bvec 2019-02-15 08:40:11 -07:00
btree.h bcache: introduce force_wake_up_gc() 2018-12-13 08:15:54 -07:00
closure.c bcache: add missing SPDX header 2018-08-11 15:46:42 -06:00
closure.h bcache: fix typo in code comments of closure_return_with_destructor() 2018-10-08 08:19:43 -06:00
debug.c bcache: do not check if debug dentry is ERR or NULL explicitly on remove 2018-12-13 08:15:54 -07:00
debug.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
extents.c bcache: treat stale && dirty keys as bad keys 2019-02-09 07:18:31 -07:00
extents.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
io.c bcache: fix typo 'succesfully' to 'successfully' 2018-08-11 15:46:42 -06:00
journal.c bcache: print number of keys in trace_bcache_journal_write 2018-12-13 08:15:54 -07:00
journal.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
Kconfig for-4.19/post-20180822 2018-08-22 13:38:05 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
movinggc.c bcache: style fix to add a blank line after declarations 2018-08-11 15:46:41 -06:00
request.c bcache: fix crashes stopping bcache device before read miss done 2019-04-24 10:56:27 -06:00
request.h bcache: remove unused bch_passthrough_cache 2018-10-08 08:19:52 -06:00
stats.c bcache: not use hard coded memset size in bch_cache_accounting_clear() 2019-02-09 07:18:31 -07:00
stats.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
super.c bcache: fix indentation issue, remove tabs on a hunk of code 2019-02-09 07:18:31 -07:00
sysfs.c bcache: fix inaccurate result of unused buckets 2019-04-24 10:56:27 -06:00
sysfs.h bcache: add sysfs_strtoul_bool() for setting bit-field variables 2019-02-09 07:18:32 -07:00
trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
util.c bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() 2019-02-15 08:40:11 -07:00
util.h for-4.19/post-20180822 2018-08-22 13:38:05 -07:00
writeback.c bcache: option to automatically run gc thread after writeback 2018-12-13 08:15:54 -07:00
writeback.h bcache: never writeback a discard operation 2019-02-09 07:18:31 -07:00