Skip to contentSkip to conversation

staging: dgng: Fix Macros with complex values should be enclosed in parenthesis

PATCH In review Seunghun Lee 4 participants 6 messages Jul 24, 2014 – Jul 25, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 staging: dgng: Fix Macros with complex values should be enclosed in parenthesis

This patch fixes a checkpatch errors
"Macros with complex values should be enclosed in parenthesis"

---
 drivers/staging/dgnc/dgnc_driver.h |   40 ++++++++++++------------
 drivers/staging/dgnc/digi.h        |   60 ++++++++++++++++++------------------
 drivers/staging/dgnc/dpacompat.h   |   12 ++++----
 3 files changed, 56 insertions(+), 56 deletions(-)
drivers/staging/dgnc/dgnc_driver.h +20 -20
index fe5ea90..f7730a1 100644
@@ -111,32 +111,32 @@
 #endif
 
 #if defined TRC_TO_KMEM
-#define PRINTF_TO_KMEM(args) dgnc_tracef args
+#define PRINTF_TO_KMEM(args) do { dgnc_tracef args } while (0)
 #else /* !defined TRC_TO_KMEM */
 #define PRINTF_TO_KMEM(args)
 #endif
 
 #define	TRC(args)	{ PRINTF_TO_KMEM(args); PRINTF_TO_CONSOLE(args) }
 
-# define DPR_INIT(ARGS)		if (DBG_INIT) TRC(ARGS)
-# define DPR_BASIC(ARGS)	if (DBG_BASIC) TRC(ARGS)
-# define DPR_CORE(ARGS)		if (DBG_CORE) TRC(ARGS)
-# define DPR_OPEN(ARGS)		if (DBG_OPEN)  TRC(ARGS)
-# define DPR_CLOSE(ARGS)	if (DBG_CLOSE)  TRC(ARGS)
-# define DPR_READ(ARGS)		if (DBG_READ)  TRC(ARGS)
-# define DPR_WRITE(ARGS)	if (DBG_WRITE) TRC(ARGS)
-# define DPR_IOCTL(ARGS)	if (DBG_IOCTL) TRC(ARGS)
-# define DPR_PROC(ARGS)		if (DBG_PROC)  TRC(ARGS)
-# define DPR_PARAM(ARGS)	if (DBG_PARAM)  TRC(ARGS)
-# define DPR_PSCAN(ARGS)	if (DBG_PSCAN)  TRC(ARGS)
-# define DPR_EVENT(ARGS)	if (DBG_EVENT)  TRC(ARGS)
-# define DPR_DRAIN(ARGS)	if (DBG_DRAIN)  TRC(ARGS)
-# define DPR_CARR(ARGS)		if (DBG_CARR)  TRC(ARGS)
-# define DPR_MGMT(ARGS)		if (DBG_MGMT)  TRC(ARGS)
-# define DPR_INTR(ARGS)		if (DBG_INTR)  TRC(ARGS)
-# define DPR_MSIGS(ARGS)	if (DBG_MSIGS)  TRC(ARGS)
-
-# define DPR(ARGS)		if (dgnc_debug) TRC(ARGS)
+# define DPR_INIT(ARGS)		do { if (DBG_INIT) TRC(ARGS) } while (0)
+# define DPR_BASIC(ARGS)	do { if (DBG_BASIC) TRC(ARGS) } while (0)
+# define DPR_CORE(ARGS)		do { if (DBG_CORE) TRC(ARGS) } while (0)
+# define DPR_OPEN(ARGS)		do { if (DBG_OPEN)  TRC(ARGS) } while (0)
+# define DPR_CLOSE(ARGS)	do { if (DBG_CLOSE)  TRC(ARGS) } while (0)
+# define DPR_READ(ARGS)		do { if (DBG_READ)  TRC(ARGS) } while (0)
+# define DPR_WRITE(ARGS)	do { if (DBG_WRITE) TRC(ARGS) } while (0)
+# define DPR_IOCTL(ARGS)	do { if (DBG_IOCTL) TRC(ARGS) } while (0)
+# define DPR_PROC(ARGS)		do { if (DBG_PROC)  TRC(ARGS) } while (0)
+# define DPR_PARAM(ARGS)	do { if (DBG_PARAM)  TRC(ARGS) } while (0)
+# define DPR_PSCAN(ARGS)	do { if (DBG_PSCAN)  TRC(ARGS) } while (0)
+# define DPR_EVENT(ARGS)	do { if (DBG_EVENT)  TRC(ARGS) } while (0)
+# define DPR_DRAIN(ARGS)	do { if (DBG_DRAIN)  TRC(ARGS) } while (0)
+# define DPR_CARR(ARGS)		do { if (DBG_CARR)  TRC(ARGS) } while (0)
+# define DPR_MGMT(ARGS)		do { if (DBG_MGMT)  TRC(ARGS) } while (0)
+# define DPR_INTR(ARGS)		do { if (DBG_INTR)  TRC(ARGS) } while (0)
+# define DPR_MSIGS(ARGS)	do { if (DBG_MSIGS)  TRC(ARGS) } while (0)
+
+# define DPR(ARGS)		do { if (dgnc_debug) TRC(ARGS) } while (0)
 # define P(X)			dgnc_tracef(#X "=%p\n", X)
 # define X(X)			dgnc_tracef(#X "=%x\n", X)
 
drivers/staging/dgnc/digi.h +30 -30

133 lines not on this page · raw message

drivers/staging/dgnc/dpacompat.h +6 -6
index f96963b..dc132c8 100644
@@ -51,7 +51,7 @@
 
 #define RW_READ		1
 #define RW_WRITE        2
-#define DIGI_KME        ('e'<<8) | 98           /* Read/Write Host */
+#define DIGI_KME	(('e'<<8) | 98)           /* Read/Write Host */
 
 #define SUBTYPE         0007
 #define T_PCXI          0000
@@ -106,10 +106,10 @@
 
 /* Ioctls needed for dpa operation */
 
-#define DIGI_GETDD      ('d'<<8) | 248          /* get driver info      */
-#define DIGI_GETBD      ('d'<<8) | 249          /* get board info       */
-#define DIGI_GET_NI_INFO ('d'<<8) | 250		/* nonintelligent state snfo */
+#define DIGI_GETDD		(('d'<<8) | 248)	/* get driver info      */
+#define DIGI_GETBD		(('d'<<8) | 249)	/* get board info       */
+#define DIGI_GET_NI_INFO	(('d'<<8) | 250)	/* nonintelligent state snfo */
 
 /* Other special ioctls */
-#define DIGI_TIMERIRQ ('d'<<8) | 251		/* Enable/disable RS_TIMER use */
-#define DIGI_LOOPBACK ('d'<<8) | 252		/* Enable/disable UART internal loopback */
+#define DIGI_TIMERIRQ		(('d'<<8) | 251)	/* Enable/disable RS_TIMER use */
+#define DIGI_LOOPBACK		(('d'<<8) | 252)	/* Enable/disable UART internal loopback */
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/3 staging: dgnc: Fix do not initialise statics to 0 or NULL

This patch fixes checkpatch errors
"do not initialise statics to 0 or NULL"

---
 drivers/staging/dgnc/dgnc_trace.c |    2 +-
 drivers/staging/dgnc/dgnc_tty.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/dgnc/dgnc_trace.c +1 -1
index 2f62f2a..9be4715 100644
@@ -43,7 +43,7 @@
 static char *dgnc_trcbuf;		/* the ringbuffer */
 
 #if defined(TRC_TO_KMEM)
-static int dgnc_trcbufi = 0;		/* index of the tilde at the end of */
+static int dgnc_trcbufi;		/* index of the tilde at the end of */
 #endif
 
 #if defined(TRC_TO_KMEM)
drivers/staging/dgnc/dgnc_tty.c +1 -1
index 714a069..919abda 100644
@@ -67,7 +67,7 @@
  * internal variables
  */
 static struct dgnc_board	*dgnc_BoardsByMajor[256];
-static uchar		*dgnc_TmpWriteBuf = NULL;
+static uchar		*dgnc_TmpWriteBuf;
 static DECLARE_MUTEX(dgnc_TmpWriteSem);
 
 /*
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 2/3] staging: dgnc: Fix do not initialise statics to 0 or NULL

Seunghun Lee schreef op vr 25-07-2014 om 00:26 [+0900]:

Quoted 14 lines

This patch fixes checkpatch errors
"do not initialise statics to 0 or NULL"

---
 drivers/staging/dgnc/dgnc_trace.c |    2 +-
 drivers/staging/dgnc/dgnc_tty.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/dgnc/dgnc_trace.c +0 -0
index 2f62f2a..9be4715 100644

drivers/staging/dgnc/dgnc_trace.c line 47

Quoted 6 lines
drivers/staging/dgnc/dgnc_trace.c +1 -1
@@ -43,7 +43,7 @@
 static char *dgnc_trcbuf;		/* the ringbuffer */
 
 #if defined(TRC_TO_KMEM)
-static int dgnc_trcbufi = 0;		/* index of the tilde at the end of */
+static int dgnc_trcbufi;		/* index of the tilde at the end of */
 #endif

I don't think TRC_TO_KMEM is defined anywhere. If that's correct, the proper, well, fix for this checkpatch warning would be to remove all code currently hidden behind the tests for that macro.

drivers/staging/dgnc/dgnc_trace.c line 48

Quoted 1 line
drivers/staging/dgnc/dgnc_trace.c +0 -0
 #if defined(TRC_TO_KMEM)

Paul Bolle

#3 lore raw

PATCH 3/3 staging: dgnc: Fix space required after that ','

In reply to Seunghun Lee

This patch fixes checkpatch errors:
"space required after that ','"

---
 drivers/staging/dgnc/dgnc_driver.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/dgnc/dgnc_driver.h +2 -2
index f7730a1..b68246a 100644
@@ -219,8 +219,8 @@
  * Makes spotting lock/unlock locations easier.
  */
 # define DGNC_SPINLOCK_INIT(x)		spin_lock_init(&(x))
-# define DGNC_LOCK(x,y)			spin_lock_irqsave(&(x), y)
-# define DGNC_UNLOCK(x,y)		spin_unlock_irqrestore(&(x), y)
+# define DGNC_LOCK(x, y)		spin_lock_irqsave(&(x), y)
+# define DGNC_UNLOCK(x, y)		spin_unlock_irqrestore(&(x), y)
 
 /*
  * All the possible states the driver can be while being loaded.
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Seunghun Lee
Quoted 2 lines · Seunghun Lee

This patch fixes a checkpatch errors
"Macros with complex values should be enclosed in parenthesis"

[]

drivers/staging/dgnc/dgnc_driver.h line 114

Quoted 8 lines
drivers/staging/dgnc/dgnc_driver.h +1 -1
@@ -111,32 +111,32 @@
 #endif
 
 #if defined TRC_TO_KMEM
-#define PRINTF_TO_KMEM(args) dgnc_tracef args
+#define PRINTF_TO_KMEM(args) do { dgnc_tracef args } while (0)

All this _TO_KMEM code is #if 0 in dgnc_trace.h

It'd be good to change the dgnc_tracef prototype to use __printf(1, 2)

and this code in drivers/staging/dgnc/dgnc_driver.h:

#if defined TRC_TO_CONSOLE
#define PRINTF_TO_CONSOLE(args) { printk(DRVSTR": "); printk args; } #else /* !defined TRACE_TO_CONSOLE */
#define PRINTF_TO_CONSOLE(args)
#endif

should really consolidate the printk to something like:

#define PRINTF_TO_CONSOLE(fmt, ...)			\
	printk(KERN_INFO DRVSTR ": " fmt, ##__VA_ARGS__)
#5 lore raw
In reply to Seunghun Lee
Quoted 15 lines · Seunghun Lee

This patch fixes a checkpatch errors
"Macros with complex values should be enclosed in parenthesis"

---
 drivers/staging/dgnc/dgnc_driver.h |   40 ++++++++++++------------
 drivers/staging/dgnc/digi.h        |   60 ++++++++++++++++++------------------
 drivers/staging/dgnc/dpacompat.h   |   12 ++++----
 3 files changed, 56 insertions(+), 56 deletions(-)
drivers/staging/dgnc/dgnc_driver.h +0 -0
index fe5ea90..f7730a1 100644

drivers/staging/dgnc/dgnc_driver.h line 114

Quoted 5 lines
drivers/staging/dgnc/dgnc_driver.h +1 -1
@@ -111,32 +111,32 @@
 #endif
 
 #if defined TRC_TO_KMEM
-#define PRINTF_TO_KMEM(args) dgnc_tracef args
+#define PRINTF_TO_KMEM(args) do { dgnc_tracef args } while (0)

This is *so* nasty... I suspect the only reason it works is because TRC_TO_KMEM is never defined.

regards,
dan carpenter