public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Omri Arad <omriarad3@gmail.com>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Florian Schilhabel <florian.c.schilhabel@googlemail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8712: fix coding style error reported from checkpatch
Date: Mon, 12 Sep 2016 11:14:54 -0700	[thread overview]
Message-ID: <1473704094.11006.21.camel@perches.com> (raw)
In-Reply-To: <1473703345-14320-1-git-send-email-omriarad3@gmail.com>

On Mon, 2016-09-12 at 21:02 +0300, Omri Arad wrote:
[]
> diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
[]
> @@ -1976,9 +1976,9 @@ static int r871x_get_ap_info(struct net_device *dev,
>  	if (pdata->length >= 32) {
>  		if (copy_from_user(data, pdata->pointer, 32))
>  			return -EINVAL;
> -                data[32] = 0;
> +		data[32] = 0;
>  	} else {
> -		 return -EINVAL;
> +		return -EINVAL;
>  	}
>  	spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL);
>  	phead = &queue->queue;

Please don't blindly follow checkpatch messages but look to see
how the code can be improved beyond what checkpatch emits.

Perhaps more pleasant to read would be to rewrite this block like:

	if (pdata->length < 32 ||
	    copy_from_user(data, pdata->pointer, 32))
		return -EINVAL;
	data[32] = 0;

Perhaps as well the literal 32 uses here and the 33 in the declaration
of data uses should be some #define or sizeof or ARRAY_SIZE.

      reply	other threads:[~2016-09-12 18:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 18:02 [PATCH] staging: rtl8712: fix coding style error reported from checkpatch Omri Arad
2016-09-12 18:14 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473704094.11006.21.camel@perches.com \
    --to=joe@perches.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=florian.c.schilhabel@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=omriarad3@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox