mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sonyipi: fix sparse warnings
@ 2005-02-24 11:40 Alexey Dobriyan
  0 siblings, 0 replies; only message in thread
From: Alexey Dobriyan @ 2005-02-24 11:40 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

Also convert copy_{from,to}_user() of 1 and 2 byte variables to {get,put}_user().

Signed-off-by: Alexey Dobriyan <adobriyan@mail.ru>

Index: linux-2.6.11-rc4-bk9-warnings/drivers/char/sonypi.c
===================================================================
--- linux-2.6.11-rc4-bk9-warnings.orig/drivers/char/sonypi.c	2005-02-24 12:42:05.000000000 +0200
+++ linux-2.6.11-rc4-bk9-warnings/drivers/char/sonypi.c	2005-02-24 13:01:44.000000000 +0200
@@ -940,7 +940,8 @@ static int sonypi_misc_ioctl(struct inod
 			     unsigned int cmd, unsigned long arg)
 {
 	int ret = 0;
-	void __user *argp = (void __user *)arg;
+	u8 __user *argp8 = (u8 __user *) arg;
+	u16 __user *argp16 = (u16 __user *) arg;
 	u8 val8;
 	u16 val16;
 
@@ -951,11 +952,11 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user(argp, &val8, sizeof(val8)))
+		if (put_user(val8, argp8))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCSBRT:
-		if (copy_from_user(&val8, argp, sizeof(val8))) {
+		if (get_user(val8, argp8)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -967,7 +968,7 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user(argp, &val16, sizeof(val16)))
+		if (put_user(val16, argp16))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCGBAT1REM:
@@ -975,7 +976,7 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user(argp, &val16, sizeof(val16)))
+		if (put_user(val16, argp16))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCGBAT2CAP:
@@ -983,7 +984,7 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user(argp, &val16, sizeof(val16)))
+		if (put_user(val16, argp16))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCGBAT2REM:
@@ -991,7 +992,7 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user(argp, &val16, sizeof(val16)))
+		if (put_user(val16, argp16))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCGBATFLAGS:
@@ -1000,16 +1001,16 @@ static int sonypi_misc_ioctl(struct inod
 			break;
 		}
 		val8 &= 0x07;
-		if (copy_to_user(argp, &val8, sizeof(val8)))
+		if (put_user(val8, argp8))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCGBLUE:
 		val8 = sonypi_device.bluetooth_power;
-		if (copy_to_user(argp, &val8, sizeof(val8)))
+		if (put_user(val8, argp8))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCSBLUE:
-		if (copy_from_user(&val8, argp, sizeof(val8))) {
+		if (get_user(val8, argp8)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -1021,11 +1022,11 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user((u8 *)arg, &val8, sizeof(val8)))
+		if (put_user(val8, argp8))
 			ret = -EFAULT;
 		break;
 	case SONYPI_IOCSFAN:
-		if (copy_from_user(&val8, (u8 *)arg, sizeof(val8))) {
+		if (get_user(val8, argp8)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -1038,7 +1039,7 @@ static int sonypi_misc_ioctl(struct inod
 			ret = -EIO;
 			break;
 		}
-		if (copy_to_user((u8 *)arg, &val8, sizeof(val8)))
+		if (put_user(val8, argp8))
 			ret = -EFAULT;
 		break;
 	default:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-02-24 10:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24 11:40 [PATCH] sonyipi: fix sparse warnings Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®