Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1666393 > unrolled thread

[PATCH] USB: gtco: remove unnecessary variable assignments

Started by"Gustavo A. R. Silva" <garsilva@embeddedor.com>
First post2017-06-15 04:40 +0200
Last post2017-06-15 22:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] USB: gtco: remove unnecessary variable assignments "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-15 04:40 +0200
    Re: [PATCH] USB: gtco: remove unnecessary variable assignments Joe Perches <joe@perches.com> - 2017-06-15 07:10 +0200
      Re: [PATCH] USB: gtco: remove unnecessary variable assignments ulrik.debie-os@e2big.org - 2017-06-15 22:10 +0200

#1666393 — [PATCH] USB: gtco: remove unnecessary variable assignments

From"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Date2017-06-15 04:40 +0200
Subject[PATCH] USB: gtco: remove unnecessary variable assignments
Message-ID<tSsRs-52d-21@gated-at.bofh.it>
Remove unnecessary variable assignments.
Variable _val_ is overwritten before the value stored in it can be used.

Addresses-Coverity-ID: 1397695
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/input/tablet/gtco.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index b796e89..d9de13c 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -652,8 +652,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
 		switch (device->buffer[0]) {
 		case 5:
 			/* Pressure is 9 bits */
-			val = ((u16)(device->buffer[8]) << 1);
-			val |= (u16)(device->buffer[7] >> 7);
 			input_report_abs(inputdev, ABS_PRESSURE,
 					 device->buffer[8]);
 
-- 
2.5.0

[toc] | [next] | [standalone]


#1666455

FromJoe Perches <joe@perches.com>
Date2017-06-15 07:10 +0200
Message-ID<tSvcC-6Fv-5@gated-at.bofh.it>
In reply to#1666393
On Wed, 2017-06-14 at 20:50 -0500, Gustavo A. R. Silva wrote:
> Remove unnecessary variable assignments.
> Variable _val_ is overwritten before the value stored in it can be used.
> 
> Addresses-Coverity-ID: 1397695
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/input/tablet/gtco.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
> index b796e89..d9de13c 100644
> --- a/drivers/input/tablet/gtco.c
> +++ b/drivers/input/tablet/gtco.c
> @@ -652,8 +652,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
>  		switch (device->buffer[0]) {
>  		case 5:
>  			/* Pressure is 9 bits */
> -			val = ((u16)(device->buffer[8]) << 1);
> -			val |= (u16)(device->buffer[7] >> 7);
>  			input_report_abs(inputdev, ABS_PRESSURE,
>  					 device->buffer[8]);

Perhaps more likely to be

			input_report_abs(inputdev, ABS_PRESSURE, val);

[toc] | [prev] | [next] | [standalone]


#1667223

Fromulrik.debie-os@e2big.org
Date2017-06-15 22:10 +0200
Message-ID<tSJfz-726-7@gated-at.bofh.it>
In reply to#1666455
Hi Joe, Gustavo,

On Wed, Jun 14, 2017 at 10:00:48PM -0700, Joe Perches wrote:
> On Wed, 2017-06-14 at 20:50 -0500, Gustavo A. R. Silva wrote:
> > Remove unnecessary variable assignments.
> > Variable _val_ is overwritten before the value stored in it can be used.
> > 
> > Addresses-Coverity-ID: 1397695
> > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> > ---
> >  drivers/input/tablet/gtco.c | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
> > index b796e89..d9de13c 100644
> > --- a/drivers/input/tablet/gtco.c
> > +++ b/drivers/input/tablet/gtco.c
> > @@ -652,8 +652,6 @@ static void gtco_urb_callback(struct urb *urbinfo)
> >  		switch (device->buffer[0]) {
> >  		case 5:
> >  			/* Pressure is 9 bits */
> > -			val = ((u16)(device->buffer[8]) << 1);
> > -			val |= (u16)(device->buffer[7] >> 7);
> >  			input_report_abs(inputdev, ABS_PRESSURE,
> >  					 device->buffer[8]);
> 
> Perhaps more likely to be
> 
> 			input_report_abs(inputdev, ABS_PRESSURE, val);

Probably that was the original intention but changing it that way now
would give a shift of factor 2 to userspace.

But if the 2 lines are deleted, I would update the comment above it so it
is clear the lowest significant bit in buffer[7] is not included in the
report call.

Kind regards,
Ulrik

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web