Skip to contentSkip to conversation

staging: ced1401: fix sparse warning for ced1401

PATCH In review Seunghun Lee 3 participants 4 messages Jun 14, 2014 – Jun 19, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: ced1401: fix sparse warning for ced1401

This patch fixes below warning.

drivers/staging/ced1401/ced_ioc.c:703:30: warning: incorrect type in assignment (different address spaces)

	drivers/staging/ced1401/ced_ioc.c:703:30:    expected void *[usertype] lpvBuff
	drivers/staging/ced1401/ced_ioc.c:703:30:    got char [noderef] <asn:1>*puBuf
---
 drivers/staging/ced1401/ced_ioc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/ced1401/ced_ioc.c +1 -1
index ebbc509..963b941 100644
@@ -700,7 +700,7 @@ static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf,
 		/*  kmap() or kmap_atomic() to get a virtual address. page_address will give you */
 		/*  (null) or at least it does in this context with an x86 machine. */
 		spin_lock_irq(&pdx->stagedLock);
-		pTA->lpvBuff = puBuf;	/*  keep start of region (user address) */
+		pTA->lpvBuff = (__force void *)puBuf;	/*  keep start of region (user address) */
 		pTA->dwBaseOffset = ulOffset;	/*  save offset in first page to start of xfer */
 		pTA->dwLength = dwLength;	/*  Size if the region in bytes */
 		pTA->pPages = pPages;	/*  list of pages that are used by buffer */
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 16 lines · Seunghun Lee

This patch fixes below warning.

drivers/staging/ced1401/ced_ioc.c:703:30: warning: incorrect type in assignment (different address spaces)

	drivers/staging/ced1401/ced_ioc.c:703:30:    expected void *[usertype] lpvBuff
	drivers/staging/ced1401/ced_ioc.c:703:30:    got char [noderef] <asn:1>*puBuf
---
 drivers/staging/ced1401/ced_ioc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/ced1401/ced_ioc.c +0 -0
index ebbc509..963b941 100644

drivers/staging/ced1401/ced_ioc.c static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf, · line 703

Quoted 5 lines
drivers/staging/ced1401/ced_ioc.c +1 -1
@@ -700,7 +700,7 @@ static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf,
 		/*  kmap() or kmap_atomic() to get a virtual address. page_address will give you */
 		/*  (null) or at least it does in this context with an x86 machine. */
 		spin_lock_irq(&pdx->stagedLock);
-		pTA->lpvBuff = puBuf;	/*  keep start of region (user address) */
+		pTA->lpvBuff = (__force void *)puBuf;	/*  keep start of region (user address) */

It's usually not good to use __force unless you have to. Can't you fix the type of the variable instead?

thanks,

greg k-h

#2 lore raw
In reply to Seunghun Lee
Quoted 7 lines · Seunghun Lee

This patch fixes below warning.

drivers/staging/ced1401/ced_ioc.c:703:30: warning: incorrect type in assignment (different address spaces)

	drivers/staging/ced1401/ced_ioc.c:703:30:    expected void *[usertype] lpvBuff
	drivers/staging/ced1401/ced_ioc.c:703:30:    got char [noderef] <asn:1>*puBuf

No. This silences the warning by disabling Sparse.

Fix the annotations instead.

regards,
dan carpenter

maintainer
#3 lore raw
In reply to Seunghun Lee
Quoted 16 lines · Seunghun Lee

This patch fixes below warning.

drivers/staging/ced1401/ced_ioc.c:703:30: warning: incorrect type in assignment (different address spaces)

	drivers/staging/ced1401/ced_ioc.c:703:30:    expected void *[usertype] lpvBuff
	drivers/staging/ced1401/ced_ioc.c:703:30:    got char [noderef] <asn:1>*puBuf
---
 drivers/staging/ced1401/ced_ioc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/ced1401/ced_ioc.c +0 -0
index ebbc509..963b941 100644

drivers/staging/ced1401/ced_ioc.c static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf, · line 703

Quoted 5 lines
drivers/staging/ced1401/ced_ioc.c +1 -1
@@ -700,7 +700,7 @@ static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf,
 		/*  kmap() or kmap_atomic() to get a virtual address. page_address will give you */
 		/*  (null) or at least it does in this context with an x86 machine. */
 		spin_lock_irq(&pdx->stagedLock);
-		pTA->lpvBuff = puBuf;	/*  keep start of region (user address) */
+		pTA->lpvBuff = (__force void *)puBuf;	/*  keep start of region (user address) */

Shouldn't you change the type of lpvBuff instead of having to force this cast?

thanks,

greg k-h