diff mbox series

[v2] ath5k: Remove unused BUG_ON

Message ID 20180921193235.1723-1-natechancellor@gmail.com (mailing list archive)
State Accepted
Commit 0891c7f4a2532de13df49d77d14cb2f5cf099183
Delegated to: Kalle Valo
Headers show
Series [v2] ath5k: Remove unused BUG_ON | expand

Commit Message

Nathan Chancellor Sept. 21, 2018, 7:32 p.m. UTC
Clang warns that the address of a pointer will always evaluated as true
in a boolean context:

drivers/net/wireless/ath/ath5k/debug.c:1031:14: warning: address of
array 'ah->sbands' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        BUG_ON(!ah->sbands);
               ~~~~~^~~~~~
./include/asm-generic/bug.h:61:45: note: expanded from macro 'BUG_ON'
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                            ^~~~~~~~~
./include/linux/compiler.h:77:42: note: expanded from macro 'unlikely'
# define unlikely(x)    __builtin_expect(!!(x), 0)
                                            ^
1 warning generated.

Given that this condition is always false because of the logical not,
just remove it.

Link: https://github.com/ClangBuiltLinux/linux/issues/130
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

v1 -> v2:

* Fix incorrect link

 drivers/net/wireless/ath/ath5k/debug.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Kalle Valo Oct. 1, 2018, 3:36 p.m. UTC | #1
Nathan Chancellor <natechancellor@gmail.com> wrote:

> Clang warns that the address of a pointer will always evaluated as true
> in a boolean context:
> 
> drivers/net/wireless/ath/ath5k/debug.c:1031:14: warning: address of
> array 'ah->sbands' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         BUG_ON(!ah->sbands);
>                ~~~~~^~~~~~
> ./include/asm-generic/bug.h:61:45: note: expanded from macro 'BUG_ON'
> #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
>                                             ^~~~~~~~~
> ./include/linux/compiler.h:77:42: note: expanded from macro 'unlikely'
> # define unlikely(x)    __builtin_expect(!!(x), 0)
>                                             ^
> 1 warning generated.
> 
> Given that this condition is always false because of the logical not,
> just remove it.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/130
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Patch applied to wireless-drivers-next.git, thanks.

0891c7f4a253 ath5k: Remove unused BUG_ON
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index e01faf641288..94f70047d3fc 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -1028,8 +1028,6 @@  ath5k_debug_dump_bands(struct ath5k_hw *ah)
 	if (likely(!(ah->debug.level & ATH5K_DEBUG_DUMPBANDS)))
 		return;
 
-	BUG_ON(!ah->sbands);
-
 	for (b = 0; b < NUM_NL80211_BANDS; b++) {
 		struct ieee80211_supported_band *band = &ah->sbands[b];
 		char bname[6];