linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iwlwifi: add __printf argument checking
@ 2012-05-15 13:01 Johannes Berg
  2012-05-16 17:41 ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2012-05-15 13:01 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

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.)

Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-debug.h |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 8376b84..f6bf91c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -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, ...)
-- 
1.7.10



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iwlwifi: add __printf argument checking
  2012-05-15 13:01 [PATCH] iwlwifi: add __printf argument checking Johannes Berg
@ 2012-05-16 17:41 ` John W. Linville
  2012-05-16 17:55   ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: John W. Linville @ 2012-05-16 17:41 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

This one causes a few warnings here -- can we fix those at the same time as we add this?

  CC      drivers/net/wireless/iwlwifi/iwl-agn-sta.o
drivers/net/wireless/iwlwifi/iwl-agn-sta.c: In function ‘iwl_sta_calc_ht_flags’:
drivers/net/wireless/iwlwifi/iwl-agn-sta.c:238:2: warning: too few arguments for format

  CC      drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.o
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c: In function ‘iwl_rx_handle’:
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c:516:3: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘struct iwl_rx_mem_buffer *’
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c:516:3: warning: too few arguments for format

On Tue, May 15, 2012 at 03:01:17PM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> 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.)
> 
> Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  drivers/net/wireless/iwlwifi/iwl-debug.h |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
> index 8376b84..f6bf91c 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-debug.h
> +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
> @@ -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, ...)
> -- 
> 1.7.10
> 
> 
> 

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iwlwifi: add __printf argument checking
  2012-05-16 17:41 ` John W. Linville
@ 2012-05-16 17:55   ` Johannes Berg
  2012-05-16 18:10     ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2012-05-16 17:55 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless

On Wed, 2012-05-16 at 13:41 -0400, John W. Linville wrote:
> This one causes a few warnings here -- can we fix those at the same time as we add this?
> 
>   CC      drivers/net/wireless/iwlwifi/iwl-agn-sta.o
> drivers/net/wireless/iwlwifi/iwl-agn-sta.c: In function ‘iwl_sta_calc_ht_flags’:
> drivers/net/wireless/iwlwifi/iwl-agn-sta.c:238:2: warning: too few arguments for format
> 
>   CC      drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.o
> drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c: In function ‘iwl_rx_handle’:
> drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c:516:3: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘struct iwl_rx_mem_buffer *’
> drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c:516:3: warning: too few arguments for format

I think they were gone by the time I did this, but you said you had to
skip a few patches (some of which fixed such bugs) as they didn't apply.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iwlwifi: add __printf argument checking
  2012-05-16 17:55   ` Johannes Berg
@ 2012-05-16 18:10     ` John W. Linville
  0 siblings, 0 replies; 4+ messages in thread
From: John W. Linville @ 2012-05-16 18:10 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Wed, May 16, 2012 at 07:55:28PM +0200, Johannes Berg wrote:
> On Wed, 2012-05-16 at 13:41 -0400, John W. Linville wrote:
> > This one causes a few warnings here -- can we fix those at the same time as we add this?
> > 
> >   CC      drivers/net/wireless/iwlwifi/iwl-agn-sta.o
> > drivers/net/wireless/iwlwifi/iwl-agn-sta.c: In function ‘iwl_sta_calc_ht_flags’:
> > drivers/net/wireless/iwlwifi/iwl-agn-sta.c:238:2: warning: too few arguments for format
> > 
> >   CC      drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.o
> > drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c: In function ‘iwl_rx_handle’:
> > drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c:516:3: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘struct iwl_rx_mem_buffer *’
> > drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c:516:3: warning: too few arguments for format
> 
> I think they were gone by the time I did this, but you said you had to
> skip a few patches (some of which fixed such bugs) as they didn't apply.

Ah, that could be true.  I'll bug you again later if it comes back... :-)

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-16 18:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-15 13:01 [PATCH] iwlwifi: add __printf argument checking Johannes Berg
2012-05-16 17:41 ` John W. Linville
2012-05-16 17:55   ` Johannes Berg
2012-05-16 18:10     ` John W. Linville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).