All of lore.kernel.org
 help / color / mirror / Atom feed
From: Henrik Rydberg <rydberg@bitmath.org>
To: Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc: Dmitry Torokhov <dtor@mail.ru>, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: bcm5974.c initialize raw_w, raw_x and raw_y before it get used
Date: Sun, 13 Sep 2009 01:24:46 +0200	[thread overview]
Message-ID: <4AAC2DBE.9040303@bitmath.org> (raw)
In-Reply-To: <1252775770.3687.7.camel@ht.satnam>

Jaswinder Singh Rajput wrote:
> raw_w, raw_x and raw_y is used uninitialized for !raw_n

Thanks for the heads up, but actually not, since !raw_n also implies
!(ptest > PRESSURE_LOW).

> This also fixed these compilation warnings :
> 
>  CC [M]  drivers/input/mouse/bcm5974.o
> drivers/input/mouse/bcm5974.c: In function ‘report_tp_state’:
> drivers/input/mouse/bcm5974.c:319: warning: ‘raw_y’ may be used uninitialized in this function
> drivers/input/mouse/bcm5974.c:319: warning: ‘raw_x’ may be used uninitialized in this function
> drivers/input/mouse/bcm5974.c:319: warning: ‘raw_w’ may be used uninitialized in this function
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> ---
>  drivers/input/mouse/bcm5974.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
> index 2d8fc0b..171f345 100644
> --- a/drivers/input/mouse/bcm5974.c
> +++ b/drivers/input/mouse/bcm5974.c
> @@ -345,7 +345,8 @@ static int report_tp_state(struct bcm5974 *dev, int size)
>  		/* set the integrated button if applicable */
>  		if (c->tp_type == TYPE2)
>  			ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
> -	}
> +	} else
> +		raw_w = raw_x = raw_y = 0;
>  
>  	/* while tracking finger still valid, count all fingers */
>  	if (ptest > PRESSURE_LOW && origin) {

I would prefer treating raw_p on the same footing here, completing the set of
non-obviously initialized variables. It might also make sense to utilize the
same initialization technique already used in the code, thus:

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 2d8fc0b..2f85876 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -316,7 +316,7 @@ static int report_tp_state(struct bcm5974 *dev, int size)
 	const struct bcm5974_config *c = &dev->cfg;
 	const struct tp_finger *f;
 	struct input_dev *input = dev->input;
-	int raw_p, raw_w, raw_x, raw_y, raw_n;
+	int raw_p = 0, raw_w = 0, raw_x = 0, raw_y = 0, raw_n;
 	int ptest = 0, origin = 0, ibt = 0, nmin = 0, nmax = 0;
 	int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;


I wonder how many cpu cycles in the world are spent making compilers happy.

Cheers,
Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-09-12 23:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-12 17:16 [PATCH] Input: bcm5974.c initialize raw_w, raw_x and raw_y before it get used Jaswinder Singh Rajput
2009-09-12 23:24 ` Henrik Rydberg [this message]
2009-09-13  8:31   ` Jaswinder Singh Rajput
2009-09-13 11:39     ` Henrik Rydberg
2009-09-14  4:37       ` Dmitry Torokhov
2009-09-14  9:00       ` Jaswinder Singh Rajput
2009-09-15 11:23         ` Henrik Rydberg

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=4AAC2DBE.9040303@bitmath.org \
    --to=rydberg@bitmath.org \
    --cc=dtor@mail.ru \
    --cc=jaswinder@kernel.org \
    --cc=linux-input@vger.kernel.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 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.