Commit 22d89cc8 authored by Narcisa Ana Maria Vasile's avatar Narcisa Ana Maria Vasile Committed by Greg Kroah-Hartman
Browse files

staging: rtl8712: Invert comparison to reduce indentation



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: default avatarNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ad93cc9f
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1965,13 +1965,12 @@ static int r871x_get_ap_info(struct net_device *dev,
			break;
	}
	pdata->flags = 0;
	if (pdata->length >= 32) {
	if (pdata->length < 32)
		return -EINVAL;
	if (copy_from_user(data, pdata->pointer, 32))
		return -EINVAL;
	data[32] = 0;
	} else {
		return -EINVAL;
	}

	spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL);
	phead = &queue->queue;
	plist = phead->next;