]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: rtl8712: Invert comparison to reduce indentation
authorNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Tue, 21 Mar 2017 22:53:36 +0000 (00:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Mar 2017 13:24:45 +0000 (14:24 +0100)
Check the condition: "pdata->length < 32" first, to be able to return immediately
in case of error and then continue with the rest of the function without one
extra indentation level.

This was found using the following Coccinelle script:

@disable neg_if@
expression e,E;
statement S;
@@

*if (e)
    S
    else { return -E; }

    @disable neg_if@
    expression e,E;
    statement S;
    identifier l;
    @@

    *if
(e)
    S
    else
{ rc = -E; goto l; }

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8712/rtl871x_ioctl_linux.c

index 3d6e818a7cc25ca37d45e076cf82ed176c5cbcfc..e30a5be5f318c62ebc62d617385ffa832d2a054e 100644 (file)
@@ -1965,13 +1965,12 @@ static int r871x_get_ap_info(struct net_device *dev,
                        break;
        }
        pdata->flags = 0;
-       if (pdata->length >= 32) {
-               if (copy_from_user(data, pdata->pointer, 32))
-                       return -EINVAL;
-               data[32] = 0;
-       } else {
+       if (pdata->length < 32)
                return -EINVAL;
-       }
+       if (copy_from_user(data, pdata->pointer, 32))
+               return -EINVAL;
+       data[32] = 0;
+
        spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL);
        phead = &queue->queue;
        plist = phead->next;