Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Narcisa Ana Maria Vasile and committed by
Greg Kroah-Hartman
22d89cc8 ad93cc9f

+5 -6
+5 -6
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
··· 1965 1965 break; 1966 1966 } 1967 1967 pdata->flags = 0; 1968 - if (pdata->length >= 32) { 1969 - if (copy_from_user(data, pdata->pointer, 32)) 1970 - return -EINVAL; 1971 - data[32] = 0; 1972 - } else { 1968 + if (pdata->length < 32) 1973 1969 return -EINVAL; 1974 - } 1970 + if (copy_from_user(data, pdata->pointer, 32)) 1971 + return -EINVAL; 1972 + data[32] = 0; 1973 + 1975 1974 spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL); 1976 1975 phead = &queue->queue; 1977 1976 plist = phead->next;