Commit 1e83bc81 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Theodore Ts'o

ext4: use BUG() instead of BUG_ON(1)

BUG_ON(1) leads to bogus warnings from clang when
CONFIG_PROFILE_ANNOTATED_BRANCHES is set:

 fs/ext4/inode.c:544:4: error: variable 'retval' is used uninitialized whenever 'if' condition is false
      [-Werror,-Wsometimes-uninitialized]
                        BUG_ON(1);
                        ^~~~~~~~~
 include/asm-generic/bug.h:61:36: note: expanded from macro 'BUG_ON'
                                   ^~~~~~~~~~~~~~~~~~~
 include/linux/compiler.h:48:23: note: expanded from macro 'unlikely'
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 fs/ext4/inode.c:591:6: note: uninitialized use occurs here
        if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
            ^~~~~~
 fs/ext4/inode.c:544:4: note: remove the 'if' if its condition is always true
                        BUG_ON(1);
                        ^
 include/asm-generic/bug.h:61:32: note: expanded from macro 'BUG_ON'
                               ^
 fs/ext4/inode.c:502:12: note: initialize the variable 'retval' to silence this warning

Change it to BUG() so clang can see that this code path can never
continue.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent d454a273
...@@ -711,7 +711,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode, ...@@ -711,7 +711,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
* We don't need to check unwritten extent because * We don't need to check unwritten extent because
* indirect-based file doesn't have it. * indirect-based file doesn't have it.
*/ */
BUG_ON(1); BUG();
} }
} else if (retval == 0) { } else if (retval == 0) {
if (ext4_es_is_written(es)) { if (ext4_es_is_written(es)) {
...@@ -780,7 +780,7 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes) ...@@ -780,7 +780,7 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
} }
p = &(*p)->rb_right; p = &(*p)->rb_right;
} else { } else {
BUG_ON(1); BUG();
return -EINVAL; return -EINVAL;
} }
} }
......
...@@ -541,7 +541,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, ...@@ -541,7 +541,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
map->m_len = retval; map->m_len = retval;
retval = 0; retval = 0;
} else { } else {
BUG_ON(1); BUG();
} }
#ifdef ES_AGGRESSIVE_TEST #ifdef ES_AGGRESSIVE_TEST
ext4_map_blocks_es_recheck(handle, inode, map, ext4_map_blocks_es_recheck(handle, inode, map,
...@@ -1876,7 +1876,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, ...@@ -1876,7 +1876,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
else if (ext4_es_is_unwritten(&es)) else if (ext4_es_is_unwritten(&es))
map->m_flags |= EXT4_MAP_UNWRITTEN; map->m_flags |= EXT4_MAP_UNWRITTEN;
else else
BUG_ON(1); BUG();
#ifdef ES_AGGRESSIVE_TEST #ifdef ES_AGGRESSIVE_TEST
ext4_map_blocks_es_recheck(NULL, inode, map, &orig_map, 0); ext4_map_blocks_es_recheck(NULL, inode, map, &orig_map, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment