Skip to content

Commit 68c467c

Browse files
committed
btrfs: separate definition of assertion failure handlers
There's a report where objtool detects unreachable instructions, eg.: fs/btrfs/ctree.o: warning: objtool: btrfs_search_slot()+0x2d4: unreachable instruction This seems to be a false positive due to compiler version. The cause is in the ASSERT macro implementation that does the conditional check as IS_DEFINED(CONFIG_BTRFS_ASSERT) and not an #ifdef. To avoid that, use the ifdefs directly. There are still 2 reports that aren't fixed: fs/btrfs/extent_io.o: warning: objtool: __set_extent_bit()+0x71f: unreachable instruction fs/btrfs/relocation.o: warning: objtool: find_data_references()+0x4e0: unreachable instruction Co-developed-by: Josh Poimboeuf <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Reported-by: Randy Dunlap <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent a69976b commit 68c467c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

fs/btrfs/ctree.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,17 +3157,21 @@ do { \
31573157
rcu_read_unlock(); \
31583158
} while (0)
31593159

3160-
__cold
3161-
static inline void assfail(const char *expr, const char *file, int line)
3160+
#ifdef CONFIG_BTRFS_ASSERT
3161+
__cold __noreturn
3162+
static inline void assertfail(const char *expr, const char *file, int line)
31623163
{
3163-
if (IS_ENABLED(CONFIG_BTRFS_ASSERT)) {
3164-
pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
3165-
BUG();
3166-
}
3164+
pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
3165+
BUG();
31673166
}
31683167

3169-
#define ASSERT(expr) \
3170-
(likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
3168+
#define ASSERT(expr) \
3169+
(likely(expr) ? (void)0 : assertfail(#expr, __FILE__, __LINE__))
3170+
3171+
#else
3172+
static inline void assertfail(const char *expr, const char* file, int line) { }
3173+
#define ASSERT(expr) (void)(expr)
3174+
#endif
31713175

31723176
/*
31733177
* Use that for functions that are conditionally exported for sanity tests but

0 commit comments

Comments
 (0)