From 7566e2ed71b1ef79b82eac05e77e901e650b8f2d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 15 Jun 2015 22:15:07 +0000 Subject: [PATCH] Avoid that compiler warnings depend on the build mode It is annoying that some warnings are only reported in release mode. Modify scst_debug.h such that the compiler does not report variables that are only used in debug builds as unused. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6315 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/iscsi.h | 2 -- iscsi-scst/kernel/iscsi_dbg.h | 2 +- scst/include/scst.h | 10 ++++++++++ scst/include/scst_debug.h | 32 ++++++++++++++++++------------ scst/src/dev_handlers/scst_vdisk.c | 3 +-- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/iscsi-scst/kernel/iscsi.h b/iscsi-scst/kernel/iscsi.h index 908068bd0..5875fbd2a 100644 --- a/iscsi-scst/kernel/iscsi.h +++ b/iscsi-scst/kernel/iscsi.h @@ -280,9 +280,7 @@ struct iscsi_conn { struct list_head rd_list_entry; -#ifdef CONFIG_SCST_EXTRACHECKS struct task_struct *rd_task; -#endif unsigned long last_rcv_time; diff --git a/iscsi-scst/kernel/iscsi_dbg.h b/iscsi-scst/kernel/iscsi_dbg.h index 6f6e247b8..408cdc4c8 100644 --- a/iscsi-scst/kernel/iscsi_dbg.h +++ b/iscsi-scst/kernel/iscsi_dbg.h @@ -52,7 +52,7 @@ extern unsigned long iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag( struct iscsi_cmnd *cmnd); #else #define iscsi_dump_pdu(x) do {} while (0) -#define iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag(x) do {} while (0) +#define iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag(x) 0 #endif #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) diff --git a/scst/include/scst.h b/scst/include/scst.h index 975463def..c393205fa 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -247,6 +247,16 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) #endif #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) && \ + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6) +/* + * See also patch "Add a dummy printk function for the maintenance of unused + * printks" (commit 12fdff3fc2483f906ae6404a6e8dcf2550310b6f). + */ +static inline __attribute__ ((format (printf, 1, 2))) +int no_printk(const char *s, ...) { return 0; } +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) /* * See also patch "sched: Fix softirq time accounting" (commit ID diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 878d188b6..28c396466 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -224,9 +224,12 @@ do { \ #define TRACING_MINOR() (false) -#define TRACE(trace, format, args...) do {} while (0) -#define PRINT_BUFFER(message, buff, len) do {} while (0) -#define PRINT_BUFF_FLAG(flag, message, buff, len) do {} while (0) +#define TRACE(trace, format, args...) \ + ((void)(trace), no_printk(format, ##args)) +#define PRINT_BUFFER(message, buff, len) \ + ((void)(message), (void)(buff), (void)(len)) +#define PRINT_BUFF_FLAG(flag, message, buff, len) \ + ((void)(flag), (void)(message), (void)(buff), (void)(len)) #endif /* CONFIG_SCST_DEBUG || CONFIG_SCST_TRACING */ @@ -353,17 +356,20 @@ do { \ #else /* CONFIG_SCST_DEBUG */ -#define TRACE_MEM(format, args...) do {} while (0) -#define TRACE_SG(format, args...) do {} while (0) -#define TRACE_DBG(format, args...) do {} while (0) -#define TRACE_DBG_FLAG(format, args...) do {} while (0) -#define TRACE_DBG_SPECIAL(format, args...) do {} while (0) -#define TRACE_MGMT_DBG(format, args...) do {} while (0) -#define TRACE_MGMT_DBG_SPECIAL(format, args...) do {} while (0) +#define TRACE_MEM(format, args...) no_printk(format, ##args) +#define TRACE_SG(format, args...) no_printk(format, ##args) +#define TRACE_DBG(format, args...) no_printk(format, ##args) +#define TRACE_DBG_FLAG(flag, format, args...) \ + ((void)(flag), no_printk(format, ##args)) +#define TRACE_DBG_SPECIAL(format, args...) no_printk(format, ##args) +#define TRACE_MGMT_DBG(format, args...) no_printk(format, ##args) +#define TRACE_MGMT_DBG_SPECIAL(format, args...) no_printk(format, ##args) #define TRACE_PR(format, args...) do {} while (0) -#define TRACE_BLOCK(format, args...) do {} while (0) -#define TRACE_BUFFER(message, buff, len) do {} while (0) -#define TRACE_BUFF_FLAG(flag, message, buff, len) do {} while (0) +#define TRACE_BLOCK(format, args...) no_printk(format, ##args) +#define TRACE_BUFFER(message, buff, len) \ + ((void)(message), (void)(buff), (void)(len)) +#define TRACE_BUFF_FLAG(flag, message, buff, len) \ + ((void)(flag), (void)(message), (void)(buff), (void)(len)) #ifndef GENERATING_UPSTREAM_PATCH #define TRACE_ENTRY() do {} while (0) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index e25753ec1..2ac5a37c4 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -60,10 +60,9 @@ #include "scst.h" #endif -#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) - #define TRACE_ORDER 0x80000000 +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) static struct scst_trace_log vdisk_local_trace_tbl[] = { { TRACE_ORDER, "order" }, { 0, NULL }