virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: gregkh@suse.de, Haiyang Zhang <haiyangz@microsoft.com>,
	dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org,
	virtualization@lists.osdl.org, linux-input@vger.kernel.org,
	devel@linuxdriverproject.org
Subject: Re: [PATCH 1/1] Staging: hv: mousevsc: Move the mouse driver out of staging
Date: Mon, 17 Oct 2011 01:28:47 +0300	[thread overview]
Message-ID: <20111016222847.GM18470@longonot.mountain> (raw)
In-Reply-To: <1318660596.6035.27.camel@Joe-Laptop>

On Fri, Oct 14, 2011 at 11:36:36PM -0700, Joe Perches wrote:
> This do {} while (1); seems like it could be simpler,
> less indented and less confusing if it used continues
> or gotos like below (if I wrote it correctly...)
> 
> loop:
> 	ret = vmbus_bus_recvpacket_raw(device->channel, buffer,
> 				       bufferlen, &bytes_recvd, &req_id);
> 	switch (ret) {
> 	case -ENOBUFS:
> 		/* Handle large packet */
> 		bufferlen = bytes_recvd;
> 		buffer = kzalloc(bytes_recvd, GFP_ATOMIC);
> /*
> Why kzalloc and not kmalloc?
> The stack variable packet is not memset to 0,
> why should buffer be zeroed?
> */
> 		if (!buffer)
> 			return;
> 		goto loop;
> 	case 0:
> 		if (bytes_recvd <= 0)
> 			goto loop;

In the original we called break here (which is equivelent to a
return).  Btw setting a stack variable and then returning immediately
like the original code did is pointless.

regards,
dan carpenter

  parent reply	other threads:[~2011-10-16 22:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-15  6:08 [PATCH 1/1] Staging: hv: mousevsc: Move the mouse driver out of staging K. Y. Srinivasan
2011-10-15  6:36 ` Joe Perches
2011-10-15 13:24   ` KY Srinivasan
2011-10-16 22:28   ` Dan Carpenter [this message]
2011-10-16 23:03     ` Joe Perches
2011-10-23  7:24 ` Dmitry Torokhov
2011-10-23 14:33   ` KY Srinivasan
2011-10-23 15:45   ` KY Srinivasan
2011-10-27  0:09     ` Dmitry Torokhov
2011-10-27  1:19       ` KY Srinivasan
2011-10-27  4:31         ` Dmitry Torokhov

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=20111016222847.GM18470@longonot.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=devel@linuxdriverproject.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@suse.de \
    --cc=haiyangz@microsoft.com \
    --cc=joe@perches.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.osdl.org \
    /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;
as well as URLs for NNTP newsgroup(s).