1 ext4: use BUG() instead of BUG_ON(1)
3 From: Arnd Bergmann <arnd@arndb.de>
5 BUG_ON(1) leads to bogus warnings from clang when
6 CONFIG_PROFILE_ANNOTATED_BRANCHES is set:
8 fs/ext4/inode.c:544:4: error: variable 'retval' is used uninitialized whenever 'if' condition is false
9 [-Werror,-Wsometimes-uninitialized]
12 include/asm-generic/bug.h:61:36: note: expanded from macro 'BUG_ON'
14 include/linux/compiler.h:48:23: note: expanded from macro 'unlikely'
15 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 fs/ext4/inode.c:591:6: note: uninitialized use occurs here
17 if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
19 fs/ext4/inode.c:544:4: note: remove the 'if' if its condition is always true
22 include/asm-generic/bug.h:61:32: note: expanded from macro 'BUG_ON'
24 fs/ext4/inode.c:502:12: note: initialize the variable 'retval' to silence this warning
26 Change it to BUG() so clang can see that this code path can never
29 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
30 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
31 Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
32 Reviewed-by: Jan Kara <jack@suse.cz>
34 fs/ext4/extents_status.c | 4 ++--
35 fs/ext4/inode.c | 4 ++--
36 2 files changed, 4 insertions(+), 4 deletions(-)
38 diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
39 index 2b439afafe13..023a3eb3afa3 100644
40 --- a/fs/ext4/extents_status.c
41 +++ b/fs/ext4/extents_status.c
42 @@ -711,7 +711,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
43 * We don't need to check unwritten extent because
44 * indirect-based file doesn't have it.
49 } else if (retval == 0) {
50 if (ext4_es_is_written(es)) {
51 @@ -780,7 +780,7 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
60 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
61 index b32a57bc5d5d..190f0478582a 100644
64 @@ -541,7 +541,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
71 #ifdef ES_AGGRESSIVE_TEST
72 ext4_map_blocks_es_recheck(handle, inode, map,
73 @@ -1876,7 +1876,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
74 else if (ext4_es_is_unwritten(&es))
75 map->m_flags |= EXT4_MAP_UNWRITTEN;
80 #ifdef ES_AGGRESSIVE_TEST
81 ext4_map_blocks_es_recheck(NULL, inode, map, &orig_map, 0);