* [PATCH] staging: vt6656: move local var init closer to usage
@ 2016-02-12 7:00 Alison Schofield
2016-02-12 7:14 ` [Outreachy kernel] " Julia Lawall
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Alison Schofield @ 2016-02-12 7:00 UTC (permalink / raw)
To: outreachy-kernel
Move init of struct urb to after sk_buf is verified otherwise
the init is wasted if we exit early.
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
---
drivers/staging/vt6656/usbpipe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index bec5baf..3648d16 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -209,12 +209,12 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
int status = 0;
struct urb *urb;
- urb = rcb->urb;
if (!rcb->skb) {
dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
return status;
}
+ urb = rcb->urb;
usb_fill_bulk_urb(urb,
priv->usb,
usb_rcvbulkpipe(priv->usb, 2),
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: vt6656: move local var init closer to usage
2016-02-12 7:00 [PATCH] staging: vt6656: move local var init closer to usage Alison Schofield
@ 2016-02-12 7:14 ` Julia Lawall
2016-02-12 17:23 ` Tejun Heo
2016-02-12 18:44 ` [PATCH v2] staging: vt6656: move local var init into declaration Alison Schofield
2 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2016-02-12 7:14 UTC (permalink / raw)
To: Alison Schofield; +Cc: outreachy-kernel
On Thu, 11 Feb 2016, Alison Schofield wrote:
> Move init of struct urb to after sk_buf is verified otherwise
> the init is wasted if we exit early.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> drivers/staging/vt6656/usbpipe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> index bec5baf..3648d16 100644
> --- a/drivers/staging/vt6656/usbpipe.c
> +++ b/drivers/staging/vt6656/usbpipe.c
> @@ -209,12 +209,12 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
> int status = 0;
> struct urb *urb;
>
> - urb = rcb->urb;
> if (!rcb->skb) {
> dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
> return status;
> }
>
> + urb = rcb->urb;
> usb_fill_bulk_urb(urb,
> priv->usb,
> usb_rcvbulkpipe(priv->usb, 2),
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160212070014.GA13288%40d830.WORKGROUP.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: vt6656: move local var init closer to usage
2016-02-12 7:00 [PATCH] staging: vt6656: move local var init closer to usage Alison Schofield
2016-02-12 7:14 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-12 17:23 ` Tejun Heo
2016-02-12 18:16 ` Alison Schofield
2016-02-12 18:44 ` [PATCH v2] staging: vt6656: move local var init into declaration Alison Schofield
2 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2016-02-12 17:23 UTC (permalink / raw)
To: Alison Schofield; +Cc: outreachy-kernel
Hello, Alison.
On Thu, Feb 11, 2016 at 11:00:22PM -0800, Alison Schofield wrote:
> Move init of struct urb to after sk_buf is verified otherwise
> the init is wasted if we exit early.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> ---
> drivers/staging/vt6656/usbpipe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> index bec5baf..3648d16 100644
> --- a/drivers/staging/vt6656/usbpipe.c
> +++ b/drivers/staging/vt6656/usbpipe.c
> @@ -209,12 +209,12 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
> int status = 0;
> struct urb *urb;
>
> - urb = rcb->urb;
> if (!rcb->skb) {
> dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
> return status;
> }
>
> + urb = rcb->urb;
> usb_fill_bulk_urb(urb,
> priv->usb,
> usb_rcvbulkpipe(priv->usb, 2),
I'd actually go the other way and do
struct urb *urb = rcb->urb;
Compilers can easily optimize these orderings. The focus should be on
brevity and readability instead of micro optimizations which don't
really yield anything.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: vt6656: move local var init closer to usage
2016-02-12 17:23 ` Tejun Heo
@ 2016-02-12 18:16 ` Alison Schofield
0 siblings, 0 replies; 8+ messages in thread
From: Alison Schofield @ 2016-02-12 18:16 UTC (permalink / raw)
To: Tejun Heo; +Cc: outreachy-kernel
On Fri, Feb 12, 2016 at 12:23:17PM -0500, Tejun Heo wrote:
> Hello, Alison.
>
> On Thu, Feb 11, 2016 at 11:00:22PM -0800, Alison Schofield wrote:
> > Move init of struct urb to after sk_buf is verified otherwise
> > the init is wasted if we exit early.
> >
> > Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> > ---
> > drivers/staging/vt6656/usbpipe.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> > index bec5baf..3648d16 100644
> > --- a/drivers/staging/vt6656/usbpipe.c
> > +++ b/drivers/staging/vt6656/usbpipe.c
> > @@ -209,12 +209,12 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
> > int status = 0;
> > struct urb *urb;
> >
> > - urb = rcb->urb;
> > if (!rcb->skb) {
> > dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
> > return status;
> > }
> >
> > + urb = rcb->urb;
> > usb_fill_bulk_urb(urb,
> > priv->usb,
> > usb_rcvbulkpipe(priv->usb, 2),
>
> I'd actually go the other way and do
>
> struct urb *urb = rcb->urb;
>
> Compilers can easily optimize these orderings. The focus should be on
> brevity and readability instead of micro optimizations which don't
> really yield anything.
>
> Thanks.
>
> --
> tejun
This was suggested to me, but I chose to mimic what another
funtion was doing in same file. I'll change both instances
for brevity & readabiity!
Thanks,
alison
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] staging: vt6656: move local var init into declaration
2016-02-12 7:00 [PATCH] staging: vt6656: move local var init closer to usage Alison Schofield
2016-02-12 7:14 ` [Outreachy kernel] " Julia Lawall
2016-02-12 17:23 ` Tejun Heo
@ 2016-02-12 18:44 ` Alison Schofield
2016-02-12 18:58 ` [Outreachy kernel] " Julia Lawall
2 siblings, 1 reply; 8+ messages in thread
From: Alison Schofield @ 2016-02-12 18:44 UTC (permalink / raw)
To: outreachy-kernel
Improve readability by initializing local variables at declaration.
In one instance, vnt_start_interrupt_urb_complete(), also use that
local variable in subsequent switch.
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
---
Changes in v2:
- moved local variable initialization to declaration,
rather than after first exit.
- cleaned up 2 additional instances in same file
- modified commit message and changelog to match
drivers/staging/vt6656/usbpipe.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index bec5baf..f27eb9a 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -101,9 +101,9 @@ void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data)
static void vnt_start_interrupt_urb_complete(struct urb *urb)
{
struct vnt_private *priv = urb->context;
- int status;
+ int status = urb->status;
- switch (urb->status) {
+ switch (status) {
case 0:
case -ETIMEDOUT:
break;
@@ -116,8 +116,6 @@ static void vnt_start_interrupt_urb_complete(struct urb *urb)
break;
}
- status = urb->status;
-
if (status != STATUS_SUCCESS) {
priv->int_buf.in_use = false;
@@ -207,9 +205,8 @@ static void vnt_submit_rx_urb_complete(struct urb *urb)
int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
{
int status = 0;
- struct urb *urb;
+ struct urb *urb = rcb->urb;
- urb = rcb->urb;
if (!rcb->skb) {
dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
return status;
@@ -269,15 +266,13 @@ int vnt_tx_context(struct vnt_private *priv,
struct vnt_usb_send_context *context)
{
int status;
- struct urb *urb;
+ struct urb *urb = context->urb;
if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) {
context->in_use = false;
return STATUS_RESOURCES;
}
- urb = context->urb;
-
usb_fill_bulk_urb(urb,
priv->usb,
usb_sndbulkpipe(priv->usb, 3),
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Outreachy kernel] [PATCH v2] staging: vt6656: move local var init into declaration
2016-02-12 18:44 ` [PATCH v2] staging: vt6656: move local var init into declaration Alison Schofield
@ 2016-02-12 18:58 ` Julia Lawall
2016-02-16 20:58 ` Alison Schofield
0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2016-02-12 18:58 UTC (permalink / raw)
To: Alison Schofield; +Cc: outreachy-kernel
On Fri, 12 Feb 2016, Alison Schofield wrote:
> Improve readability by initializing local variables at declaration.
>
> In one instance, vnt_start_interrupt_urb_complete(), also use that
> local variable in subsequent switch.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> ---
> Changes in v2:
> - moved local variable initialization to declaration,
> rather than after first exit.
> - cleaned up 2 additional instances in same file
> - modified commit message and changelog to match
>
> drivers/staging/vt6656/usbpipe.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> index bec5baf..f27eb9a 100644
> --- a/drivers/staging/vt6656/usbpipe.c
> +++ b/drivers/staging/vt6656/usbpipe.c
> @@ -101,9 +101,9 @@ void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data)
> static void vnt_start_interrupt_urb_complete(struct urb *urb)
> {
> struct vnt_private *priv = urb->context;
> - int status;
> + int status = urb->status;
>
> - switch (urb->status) {
> + switch (status) {
> case 0:
> case -ETIMEDOUT:
> break;
> @@ -116,8 +116,6 @@ static void vnt_start_interrupt_urb_complete(struct urb *urb)
> break;
> }
>
> - status = urb->status;
> -
> if (status != STATUS_SUCCESS) {
Not related to this patch, but this test is very unlikeable.
SUCCESS_STATUS is defined in the following (vt6656/device.h)
enum {
STATUS_SUCCESS = 0,
STATUS_FAILURE,
STATUS_RESOURCES,
STATUS_PENDING,
};
This is not at all the same kind of value as -ETIMEDOUT, etc. The urb
status is something that is not set in this driver as well. I guess is it
set in the USB library, where STATUS_SUCCESS is not known. So status
should not be compared against this value.
julia
> priv->int_buf.in_use = false;
>
> @@ -207,9 +205,8 @@ static void vnt_submit_rx_urb_complete(struct urb *urb)
> int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
> {
> int status = 0;
> - struct urb *urb;
> + struct urb *urb = rcb->urb;
>
> - urb = rcb->urb;
> if (!rcb->skb) {
> dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
> return status;
> @@ -269,15 +266,13 @@ int vnt_tx_context(struct vnt_private *priv,
> struct vnt_usb_send_context *context)
> {
> int status;
> - struct urb *urb;
> + struct urb *urb = context->urb;
>
> if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) {
> context->in_use = false;
> return STATUS_RESOURCES;
> }
>
> - urb = context->urb;
> -
> usb_fill_bulk_urb(urb,
> priv->usb,
> usb_sndbulkpipe(priv->usb, 3),
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1455302683-5119-1-git-send-email-amsfield22%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Outreachy kernel] [PATCH v2] staging: vt6656: move local var init into declaration
2016-02-12 18:58 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-16 20:58 ` Alison Schofield
2016-02-17 0:58 ` Julia Lawall
0 siblings, 1 reply; 8+ messages in thread
From: Alison Schofield @ 2016-02-16 20:58 UTC (permalink / raw)
To: Julia Lawall; +Cc: outreachy-kernel
On Fri, Feb 12, 2016 at 07:58:05PM +0100, Julia Lawall wrote:
>
>
> On Fri, 12 Feb 2016, Alison Schofield wrote:
>
> > Improve readability by initializing local variables at declaration.
> >
> > In one instance, vnt_start_interrupt_urb_complete(), also use that
> > local variable in subsequent switch.
> >
> > Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> > ---
.............snip
> >
> > diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> > index bec5baf..f27eb9a 100644
> > --- a/drivers/staging/vt6656/usbpipe.c
> > +++ b/drivers/staging/vt6656/usbpipe.c
> > @@ -101,9 +101,9 @@ void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data)
> > static void vnt_start_interrupt_urb_complete(struct urb *urb)
> > {
> > struct vnt_private *priv = urb->context;
> > - int status;
> > + int status = urb->status;
> >
> > - switch (urb->status) {
> > + switch (status) {
> > case 0:
> > case -ETIMEDOUT:
> > break;
> > @@ -116,8 +116,6 @@ static void vnt_start_interrupt_urb_complete(struct urb *urb)
> > break;
> > }
> >
> > - status = urb->status;
> > -
> > if (status != STATUS_SUCCESS) {
>
> Not related to this patch, but this test is very unlikeable.
> SUCCESS_STATUS is defined in the following (vt6656/device.h)
>
> enum {
> STATUS_SUCCESS = 0,
> STATUS_FAILURE,
> STATUS_RESOURCES,
> STATUS_PENDING,
> };
>
> This is not at all the same kind of value as -ETIMEDOUT, etc. The urb
> status is something that is not set in this driver as well. I guess is it
> set in the USB library, where STATUS_SUCCESS is not known. So status
> should not be compared against this value.
>
> julia
>
I see that a "successful" urb status is simply 0 and the failures
are standard E* statuses. This is evident directly above in the
switch, and I confirmed it in drivers/usb code samples.
The STATUS_SUCCESS is used correctly elsewhere for NDIS status per it's
definition.
I'll send a patch for this.
When I do a subsequent patch like this, should I send it as a reply
here in this email thread, or post a new message? I'm not sure if it
would get buried in here since Greg has already taken the first patch?
Thanks,
alison
.................snip
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Outreachy kernel] [PATCH v2] staging: vt6656: move local var init into declaration
2016-02-16 20:58 ` Alison Schofield
@ 2016-02-17 0:58 ` Julia Lawall
0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2016-02-17 0:58 UTC (permalink / raw)
To: Alison Schofield; +Cc: outreachy-kernel
On Tue, 16 Feb 2016, Alison Schofield wrote:
> On Fri, Feb 12, 2016 at 07:58:05PM +0100, Julia Lawall wrote:
> >
> >
> > On Fri, 12 Feb 2016, Alison Schofield wrote:
> >
> > > Improve readability by initializing local variables at declaration.
> > >
> > > In one instance, vnt_start_interrupt_urb_complete(), also use that
> > > local variable in subsequent switch.
> > >
> > > Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> > > ---
>
> .............snip
>
> > >
> > > diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> > > index bec5baf..f27eb9a 100644
> > > --- a/drivers/staging/vt6656/usbpipe.c
> > > +++ b/drivers/staging/vt6656/usbpipe.c
> > > @@ -101,9 +101,9 @@ void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data)
> > > static void vnt_start_interrupt_urb_complete(struct urb *urb)
> > > {
> > > struct vnt_private *priv = urb->context;
> > > - int status;
> > > + int status = urb->status;
> > >
> > > - switch (urb->status) {
> > > + switch (status) {
> > > case 0:
> > > case -ETIMEDOUT:
> > > break;
> > > @@ -116,8 +116,6 @@ static void vnt_start_interrupt_urb_complete(struct urb *urb)
> > > break;
> > > }
> > >
> > > - status = urb->status;
> > > -
> > > if (status != STATUS_SUCCESS) {
> >
> > Not related to this patch, but this test is very unlikeable.
> > SUCCESS_STATUS is defined in the following (vt6656/device.h)
> >
> > enum {
> > STATUS_SUCCESS = 0,
> > STATUS_FAILURE,
> > STATUS_RESOURCES,
> > STATUS_PENDING,
> > };
> >
> > This is not at all the same kind of value as -ETIMEDOUT, etc. The urb
> > status is something that is not set in this driver as well. I guess is it
> > set in the USB library, where STATUS_SUCCESS is not known. So status
> > should not be compared against this value.
> >
> > julia
> >
> I see that a "successful" urb status is simply 0 and the failures
> are standard E* statuses. This is evident directly above in the
> switch, and I confirmed it in drivers/usb code samples.
>
> The STATUS_SUCCESS is used correctly elsewhere for NDIS status per it's
> definition.
>
> I'll send a patch for this.
>
> When I do a subsequent patch like this, should I send it as a reply
> here in this email thread, or post a new message? I'm not sure if it
> would get buried in here since Greg has already taken the first patch?
If Greg already took the first patch, it could be better to start a new
thread.
julia
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-02-17 0:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-12 7:00 [PATCH] staging: vt6656: move local var init closer to usage Alison Schofield
2016-02-12 7:14 ` [Outreachy kernel] " Julia Lawall
2016-02-12 17:23 ` Tejun Heo
2016-02-12 18:16 ` Alison Schofield
2016-02-12 18:44 ` [PATCH v2] staging: vt6656: move local var init into declaration Alison Schofield
2016-02-12 18:58 ` [Outreachy kernel] " Julia Lawall
2016-02-16 20:58 ` Alison Schofield
2016-02-17 0:58 ` Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.