Skip to contentSkip to conversation

checkpatch: CHECK: No space is necessary after a cast

DISCUSSION Kalle Valo 2 participants 3 messages Sep 29, 2014 – Sep 30, 2014

Subsystems (2)
lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

Hi Joe,

I have a problem with checkpatch. On ath10k we have this function:

static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)

{
	BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
		     IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
	return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
}

And the BUILD_BUG_ON triggers this warning:

drivers/net/wireless/ath/ath10k/core.h:85: CHECK: No space is necessary after a cast

Any advice how to handle that?

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
maintainer
#1 lore raw
Quoted 11 lines · Kalle Valo

Hi Joe,

I have a problem with checkpatch. On ath10k we have this function:

static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)

{
	BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
		     IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
	return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
}
Quoted 5 lines

And the BUILD_BUG_ON triggers this warning:

drivers/net/wireless/ath/ath10k/core.h:85: CHECK: No space is necessary after a cast

Any advice how to handle that?

It's a checkpatch false positive that could be fixed.

It needs something like another test to look for sizeof(type) as not a cast and more arithmetic/comparison uses.

Maybe you can test this?

---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index 52a223e..6132329 100755
@@ -2515,7 +2515,8 @@ sub process {
 			}
 		}
 
-		if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|{)/) {
+		if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;\({\[\<\>])/ &&
+		    (!defined($1) || $1 !~ /sizeof\s*/)) {
 			if (CHK("SPACING",
 				"No space is necessary after a cast\n" . $herecurr) &&
 			    $fix) {
author Tested-by
#2 lore raw
Quoted 18 lines · Joe Perches
Quoted 11 lines · Kalle Valo

Hi Joe,

I have a problem with checkpatch. On ath10k we have this function:

static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)

{
	BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
		     IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
	return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
}
Quoted 5 lines

And the BUILD_BUG_ON triggers this warning:

drivers/net/wireless/ath/ath10k/core.h:85: CHECK: No space is necessary after a cast

Any advice how to handle that?

Quoted 7 lines

It's a checkpatch false positive that could be fixed.

It needs something like another test to look for sizeof(type) as not a cast and more arithmetic/comparison uses.

Maybe you can test this?

It works, thank you!

Signature · 1 line
Kalle Valo