linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <egrumbach@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 10/24] iwlwifi: cause build error on missing newline
Date: Thu, 15 May 2014 20:04:27 +0300	[thread overview]
Message-ID: <1400173481-9047-10-git-send-email-egrumbach@gmail.com> (raw)
In-Reply-To: <5374F373.6040902@gmail.com>

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

If a (debug) message is missing a newline, cause build error
so we don't keep reintroducing this problem.

This also prevents using a non-constant argument as the format
string which is a good idea anyway (e.g. for security reasons.)

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

diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index c8cbdbe..2950835 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -47,12 +47,32 @@ 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);
 
+/* not all compilers can evaluate strlen() at compile time, so use sizeof() */
+#define CHECK_FOR_NEWLINE(f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n')
+
 /* 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)
-#define IWL_ERR_DEV(d, f, a...) __iwl_err((d), false, false, f, ## a)
-#define IWL_WARN(m, f, a...) __iwl_warn((m)->dev, f, ## a)
-#define IWL_INFO(m, f, a...) __iwl_info((m)->dev, f, ## a)
-#define IWL_CRIT(m, f, a...) __iwl_crit((m)->dev, f, ## a)
+#define IWL_ERR_DEV(d, f, a...)						\
+	do {								\
+		CHECK_FOR_NEWLINE(f);					\
+		__iwl_err((d), false, false, f, ## a);			\
+	} while (0)
+#define IWL_ERR(m, f, a...)						\
+	IWL_ERR_DEV((m)->dev, f, ## a)
+#define IWL_WARN(m, f, a...)						\
+	do {								\
+		CHECK_FOR_NEWLINE(f);					\
+		__iwl_warn((m)->dev, f, ## a);				\
+	} while (0)
+#define IWL_INFO(m, f, a...)						\
+	do {								\
+		CHECK_FOR_NEWLINE(f);					\
+		__iwl_info((m)->dev, f, ## a);				\
+	} while (0)
+#define IWL_CRIT(m, f, a...)						\
+	do {								\
+		CHECK_FOR_NEWLINE(f);					\
+		__iwl_crit((m)->dev, f, ## a);				\
+	} while (0)
 
 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
 void __iwl_dbg(struct device *dev,
@@ -72,12 +92,17 @@ do {									\
 		       DUMP_PREFIX_OFFSET, 16, 1, p, len, 1);		\
 } while (0)
 
+#define __IWL_DEBUG_DEV(dev, level, limit, fmt, args...)		\
+	do {								\
+		CHECK_FOR_NEWLINE(fmt);					\
+		__iwl_dbg(dev, level, limit, __func__, fmt, ##args);	\
+	} while (0)
 #define IWL_DEBUG(m, level, fmt, args...)				\
-	__iwl_dbg((m)->dev, level, false, __func__, fmt, ##args)
+	__IWL_DEBUG_DEV((m)->dev, level, false, fmt, ##args)
 #define IWL_DEBUG_DEV(dev, level, fmt, args...)				\
-	__iwl_dbg((dev), level, false, __func__, fmt, ##args)
+	__IWL_DEBUG_DEV(dev, level, false, fmt, ##args)
 #define IWL_DEBUG_LIMIT(m, level, fmt, args...)				\
-	__iwl_dbg((m)->dev, level, true, __func__, fmt, ##args)
+	__IWL_DEBUG_DEV((m)->dev, level, true, fmt, ##args)
 
 #ifdef CONFIG_IWLWIFI_DEBUG
 #define iwl_print_hex_dump(m, level, p, len)				\
-- 
1.8.3.2


  parent reply	other threads:[~2014-05-15 17:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 17:03 pull request iwlwifi-next 2014-05-15 Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 01/24] iwlwifi: add missing trailing newlines to debug messages Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 02/24] iwlwifi: dvm: don't use _ni mac80211's callbacks Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 03/24] iwlwifi: 8000: add default NVM file name in family 8000 Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 04/24] iwlwifi: pcie: try to get ownership several times Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 05/24] iwlwifi: mvm: add channel 14 to the low band list Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 06/24] iwlwifi: mvm: notify sched scan complete from stop routine Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 07/24] iwlwifi: mvm: stop sched scan before association Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 08/24] iwlwifi: mvm: Add power management support for P2P DCM Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 09/24] iwlwifi: mvm: Disable uAPSD for a DCM client Emmanuel Grumbach
2014-05-15 17:04 ` Emmanuel Grumbach [this message]
2014-05-15 17:04 ` [PATCH 11/24] iwlwifi: remove spurious newline in Kconfig Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 12/24] iwlwifi: remove CMD_SYNC Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 13/24] iwlwifi: use dev_printk instead of dev_dbg for debug logs Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 14/24] iwlwifi: pcie: disable BHs in iwl_pcie_txq_check_wrptrs Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 15/24] iwlwifi: mvm: set SKIP_OVER_DTIM flag only if needed Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 16/24] iwlwifi: mvm: BT Coex - fix boost register / LUT values Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 17/24] iwlwifi: mvm: revisit the NVM handling code Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 18/24] iwlwifi: mvm: enable RX chain diversity if needed Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 19/24] iwlwifi: allow dynamic configuration of internal memory Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 20/24] iwlwifi: mvm: add uapsd_disable module parameter Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 21/24] iwlwifi: mvm: BT Coex - send channel inhibition before association Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 22/24] iwlwifi: mvm: combine p2p and station mac context functions Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 23/24] iwlwifi: update nmi register Emmanuel Grumbach
2014-05-15 17:04 ` [PATCH 24/24] iwlwifi: fix LED support Kconfig dependencies Emmanuel Grumbach
2014-05-16 18:19 ` pull request iwlwifi-next 2014-05-15 John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400173481-9047-10-git-send-email-egrumbach@gmail.com \
    --to=egrumbach@gmail.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).