Skip to contentSkip to conversation

iwlwifi print formatting fixes

PATCH In review Johannes Berg 2 participants 8 messages May 16, 2012 Networking drivers (wireless)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

cover iwlwifi print formatting fixes

These are fixes for iwlwifi's debug statements and the addition of the __printf attribute.

I ended up marking the %pM one for stable since I think %pM can cause crashes if the pointer is completely bogus.

johannes

author maintainer
#1 lore raw

PATCH 1/3 iwlwifi: fix prints in iwl_rx_handle

From: Emmanuel Grumbach <[email protected]>

The debug prints were wrong and buggy. The HW pointer wasn't printed correctly, it was mixed up with the pointer to the rxbuf.

---
 drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +3 -3
index 08517d3..1a7eb2a 100644
@@ -497,7 +497,7 @@ static void iwl_rx_handle(struct iwl_trans *trans)
 
 	/* Rx interrupt, but nothing sent from uCode */
 	if (i == r)
-		IWL_DEBUG_RX(trans, "r = %d, i = %d\n", r, i);
+		IWL_DEBUG_RX(trans, "HW = SW = %d\n", r);
 
 	/* calculate total frames need to be restock after handling RX */
 	total_empty = r - rxq->write_actual;
@@ -513,8 +513,8 @@ static void iwl_rx_handle(struct iwl_trans *trans)
 		rxb = rxq->queue[i];
 		rxq->queue[i] = NULL;
 
-		IWL_DEBUG_RX(trans, "rxbuf: r = %d, i = %d (%p)\n", rxb);
-
+		IWL_DEBUG_RX(trans, "rxbuf: HW = %d, SW = %d (%p)\n",
+			     r, i, rxb);
 		iwl_rx_handle_rxbuf(trans, rxb);
 
 		i = (i + 1) & RX_QUEUE_MASK;
Signature · 1 line
1.7.10
author maintainer
#2 lore raw

PATCH 2/3 iwlwifi: fix debug print in iwl_sta_calc_ht_flags

In reply to Johannes Berg

From: Meenakshi Venkataraman <[email protected]>

We missed passing an argument to the
debug print. Fix it.

---
 drivers/net/wireless/iwlwifi/iwl-agn-sta.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/iwlwifi/iwl-agn-sta.c +1 -0
index 67e6f1d..76c1f72 100644
@@ -236,6 +236,7 @@ static void iwl_sta_calc_ht_flags(struct iwl_priv *priv,
 	mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
 
 	IWL_DEBUG_INFO(priv, "STA %pM SM PS mode: %s\n",
+			sta->addr,
 			(mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ?
 			"static" :
 			(mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ?
Signature · 1 line
1.7.10
author maintainer
#3 lore raw

PATCH 3/3 iwlwifi: add __printf argument checking

In reply to Johannes Berg

From: Johannes Berg <[email protected]>

Joe Perches suggested adding the __printf attribute to the __iwl_dbg function to check arguments; add it to all of the logging functions (err, warn, info, dbg and crit.)

Change-Id I7a2ffcd3f625ff29c65519b0c3d474bace884f9d

Reviewed-on: http://git-mwg.jer.intel.com/gerrit/2022

Tested-by Jenkins
---
 drivers/net/wireless/iwlwifi/iwl-debug.h |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/iwlwifi/iwl-debug.h +6 -6
index 8376b84..f6bf91c 100644
@@ -38,10 +38,10 @@ static inline bool iwl_have_debug_level(u32 level)
 }
 
 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
-		const char *fmt, ...);
-void __iwl_warn(struct device *dev, const char *fmt, ...);
-void __iwl_info(struct device *dev, const char *fmt, ...);
-void __iwl_crit(struct device *dev, const char *fmt, ...);
+		const char *fmt, ...) __printf(4, 5);
+void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);
 
 /* No matter what is m (priv, bus, trans), this will work */
 #define IWL_ERR(m, f, a...) __iwl_err((m)->dev, false, false, f, ## a)
@@ -52,9 +52,9 @@ void __iwl_crit(struct device *dev, const char *fmt, ...);
 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
 void __iwl_dbg(struct device *dev,
 	       u32 level, bool limit, const char *function,
-	       const char *fmt, ...);
+	       const char *fmt, ...) __printf(5, 6);
 #else
-static inline void
+__printf(5, 6) static inline void
 __iwl_dbg(struct device *dev,
 	  u32 level, bool limit, const char *function,
 	  const char *fmt, ...)
Signature · 1 line
1.7.10
#4 lore raw

Re: [PATCH 3/3] iwlwifi: add __printf argument checking

Quoted 7 lines · Johannes Berg

From: Johannes Berg <[email protected]>

Joe Perches suggested adding the __printf attribute to the __iwl_dbg function to check arguments; add it to all of the logging functions (err, warn, info, dbg and crit.)

Quoted 5 lines
Change-Id I7a2ffcd3f625ff29c65519b0c3d474bace884f9d

Reviewed-on: http://git-mwg.jer.intel.com/gerrit/2022

Tested-by Jenkins

Trivial comments:

Odd Reviewed-on: and Tested-by: lines.
The intel.com link does not resolve here too.

drivers/net/wireless/iwlwifi/iwl-debug.h

Quoted 1 line
drivers/net/wireless/iwlwifi/iwl-debug.h +0 -0

[]

drivers/net/wireless/iwlwifi/iwl-debug.h static inline bool iwl_have_debug_level(u32 level) · line 44

Quoted 12 lines
drivers/net/wireless/iwlwifi/iwl-debug.h +4 -4
@@ -38,10 +38,10 @@ static inline bool iwl_have_debug_level(u32 level)
 }
 
 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
-		const char *fmt, ...);
-void __iwl_warn(struct device *dev, const char *fmt, ...);
-void __iwl_info(struct device *dev, const char *fmt, ...);
-void __iwl_crit(struct device *dev, const char *fmt, ...);
+		const char *fmt, ...) __printf(4, 5);
+void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);

As far as I know, there are very few in-kernel uses of __printf after the function prototype (6 out of 183).

$ git grep -E "\b__printf\s*\(\s*\w+\s*,\s*\w+\s*\)\s*;" | wc -l
6
$ git grep -E "\b__printf\s*\(\s*\w+\s*,\s*\w+\s*\)" | wc -l
183

I'd prefer to keep the __printf before the return type.

author maintainer
#5 lore raw

Re: [PATCH 3/3] iwlwifi: add __printf argument checking

Quoted 10 lines · Joe Perches
Quoted 5 lines
Change-Id I7a2ffcd3f625ff29c65519b0c3d474bace884f9d

Reviewed-on: http://git-mwg.jer.intel.com/gerrit/2022

Tested-by Jenkins

Trivial comments:

Odd Reviewed-on: and Tested-by: lines.
The intel.com link does not resolve here too.

Meh, second time I've messed this up... It's not supposed to, so I guess that's good. I'll send a new version of this.

Quoted 18 lines

drivers/net/wireless/iwlwifi/iwl-debug.h

Quoted 1 line
drivers/net/wireless/iwlwifi/iwl-debug.h +0 -0

[]

drivers/net/wireless/iwlwifi/iwl-debug.h static inline bool iwl_have_debug_level(u32 level) · line 44

Quoted 12 lines
drivers/net/wireless/iwlwifi/iwl-debug.h +4 -4
@@ -38,10 +38,10 @@ static inline bool iwl_have_debug_level(u32 level)
 }
 
 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
-		const char *fmt, ...);
-void __iwl_warn(struct device *dev, const char *fmt, ...);
-void __iwl_info(struct device *dev, const char *fmt, ...);
-void __iwl_crit(struct device *dev, const char *fmt, ...);
+		const char *fmt, ...) __printf(4, 5);
+void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);

As far as I know, there are very few in-kernel uses of __printf after the function prototype (6 out of 183).

Quoted 6 lines
$ git grep -E "\b__printf\s*\(\s*\w+\s*,\s*\w+\s*\)\s*;" | wc -l
6
$ git grep -E "\b__printf\s*\(\s*\w+\s*,\s*\w+\s*\)" | wc -l
183

I'd prefer to keep the __printf before the return type.

Well, maybe now it's 3 more? :-)

To me, before looks really strange, and while maybe __printf is almost always before, if you do the same grep with, say, __releases() or __acquires(), it's almost always after, so ...

johannes

#6 lore raw

Re: [PATCH 3/3] iwlwifi: add __printf argument checking

Quoted 34 lines · Johannes Berg
Quoted 10 lines · Joe Perches
Quoted 5 lines
Change-Id I7a2ffcd3f625ff29c65519b0c3d474bace884f9d

Reviewed-on: http://git-mwg.jer.intel.com/gerrit/2022

Tested-by Jenkins

Trivial comments:

Odd Reviewed-on: and Tested-by: lines.
The intel.com link does not resolve here too.

Meh, second time I've messed this up... It's not supposed to, so I guess that's good. I'll send a new version of this.

Quoted 18 lines

drivers/net/wireless/iwlwifi/iwl-debug.h

Quoted 1 line
drivers/net/wireless/iwlwifi/iwl-debug.h +0 -0

[]

drivers/net/wireless/iwlwifi/iwl-debug.h static inline bool iwl_have_debug_level(u32 level) · line 44

Quoted 12 lines
drivers/net/wireless/iwlwifi/iwl-debug.h +4 -4
@@ -38,10 +38,10 @@ static inline bool iwl_have_debug_level(u32 level)
 }
 
 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
-		const char *fmt, ...);
-void __iwl_warn(struct device *dev, const char *fmt, ...);
-void __iwl_info(struct device *dev, const char *fmt, ...);
-void __iwl_crit(struct device *dev, const char *fmt, ...);
+		const char *fmt, ...) __printf(4, 5);
+void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);

As far as I know, there are very few in-kernel uses of __printf after the function prototype (6 out of 183).

Quoted 8 lines
Quoted 6 lines
$ git grep -E "\b__printf\s*\(\s*\w+\s*,\s*\w+\s*\)\s*;" | wc -l
6
$ git grep -E "\b__printf\s*\(\s*\w+\s*,\s*\w+\s*\)" | wc -l
183

I'd prefer to keep the __printf before the return type.

Well, maybe now it's 3 more? :-)

Hope not.

You noticed you _have_ to put it before the function on the static inlines so why not keep it there in all cases?

author maintainer
#7 lore raw

PATCH v2 3/3 iwlwifi: add __printf argument checking

In reply to Johannes Berg

From: Johannes Berg <[email protected]>

Joe Perches suggested adding the __printf attribute to the __iwl_dbg function to check arguments; add it to all of the logging functions (err, warn, info, dbg and crit.)

---
v2: remove gerrit junk from commit log

drivers/net/wireless/iwlwifi/iwl-debug.h +6 -6
index 8376b84..f6bf91c 100644
@@ -38,10 +38,10 @@ static inline bool iwl_have_debug_level(u32 level)
 }
 
 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
-		const char *fmt, ...);
-void __iwl_warn(struct device *dev, const char *fmt, ...);
-void __iwl_info(struct device *dev, const char *fmt, ...);
-void __iwl_crit(struct device *dev, const char *fmt, ...);
+		const char *fmt, ...) __printf(4, 5);
+void __iwl_warn(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_info(struct device *dev, const char *fmt, ...) __printf(2, 3);
+void __iwl_crit(struct device *dev, const char *fmt, ...) __printf(2, 3);
 
 /* No matter what is m (priv, bus, trans), this will work */
 #define IWL_ERR(m, f, a...) __iwl_err((m)->dev, false, false, f, ## a)
@@ -52,9 +52,9 @@ void __iwl_crit(struct device *dev, const char *fmt, ...);
 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
 void __iwl_dbg(struct device *dev,
 	       u32 level, bool limit, const char *function,
-	       const char *fmt, ...);
+	       const char *fmt, ...) __printf(5, 6);
 #else
-static inline void
+__printf(5, 6) static inline void
 __iwl_dbg(struct device *dev,
 	  u32 level, bool limit, const char *function,
 	  const char *fmt, ...)