Skip to content

Commit 1e83bc8

Browse files
arndbtytso
authored andcommitted
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: Arnd Bergmann <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Jan Kara <[email protected]>
1 parent d454a27 commit 1e83bc8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/ext4/extents_status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
711711
* We don't need to check unwritten extent because
712712
* indirect-based file doesn't have it.
713713
*/
714-
BUG_ON(1);
714+
BUG();
715715
}
716716
} else if (retval == 0) {
717717
if (ext4_es_is_written(es)) {
@@ -780,7 +780,7 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
780780
}
781781
p = &(*p)->rb_right;
782782
} else {
783-
BUG_ON(1);
783+
BUG();
784784
return -EINVAL;
785785
}
786786
}

fs/ext4/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
541541
map->m_len = retval;
542542
retval = 0;
543543
} else {
544-
BUG_ON(1);
544+
BUG();
545545
}
546546
#ifdef ES_AGGRESSIVE_TEST
547547
ext4_map_blocks_es_recheck(handle, inode, map,
@@ -1876,7 +1876,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
18761876
else if (ext4_es_is_unwritten(&es))
18771877
map->m_flags |= EXT4_MAP_UNWRITTEN;
18781878
else
1879-
BUG_ON(1);
1879+
BUG();
18801880

18811881
#ifdef ES_AGGRESSIVE_TEST
18821882
ext4_map_blocks_es_recheck(NULL, inode, map, &orig_map, 0);

0 commit comments

Comments
 (0)