staging: ion: simplify ioctl args checking function
authorBenjamin Gaignard <benjamin.gaignard@linaro.org>
Mon, 23 Oct 2017 15:55:36 +0000 (17:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Nov 2017 10:44:46 +0000 (11:44 +0100)
Make arguments checking more easy to read.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Acked-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/ion-ioctl.c

index d9f8b1424da18b5790aa8613e18a3ec287d66283..e26b7864db16a4bada0a8d571d5f776fb6aebd54 100644 (file)
@@ -27,19 +27,18 @@ union ion_ioctl_arg {
 
 static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
 {
-       int ret = 0;
-
        switch (cmd) {
        case ION_IOC_HEAP_QUERY:
-               ret = arg->query.reserved0 != 0;
-               ret |= arg->query.reserved1 != 0;
-               ret |= arg->query.reserved2 != 0;
+               if (arg->query.reserved0 ||
+                   arg->query.reserved1 ||
+                   arg->query.reserved2 )
+                       return -EINVAL;
                break;
        default:
                break;
        }
 
-       return ret ? -EINVAL : 0;
+       return 0;
 }
 
 /* fix up the cases where the ioctl direction bits are incorrect */