* [PATCH] Input: cyapa - Remove superfluous type check in cyapa_gen5_read_idac_data()
@ 2015-02-12 14:16 Geert Uytterhoeven
2015-03-02 4:20 ` Dudley Du
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2015-02-12 14:16 UTC (permalink / raw)
To: Dmitry Torokhov, Dudley Du; +Cc: linux-input, linux-kernel, Geert Uytterhoeven
drivers/input/mouse/cyapa_gen5.c: In function ‘cyapa_gen5_read_idac_data’:
drivers/input/mouse/cyapa_gen5.c:1876: warning: ‘max_element_cnt’ may be used uninitialized in this function
drivers/input/mouse/cyapa_gen5.c:1873: warning: ‘offset’ may be used uninitialized in this function
If *data_size is non-zero, and idac_data_type contains an unknown type,
max_element_cnt and offset will be uninitialized, and the loop will
process non-existing data.
However, this cannot happen (for now), as there's a test for unknown
types at the top of cyapa_gen5_read_idac_data().
As no "if ... else if ..." is used in other places, remove the
superfluous "if" to silence the compiler warning.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Alternatively, we can pre-initialize max_element_cnt and offset to zero,
and add "if (!max_element_cnt) goto out;" before the loop.
drivers/input/mouse/cyapa_gen5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c
index ddf5393a118098fc..88c465b70e9d8776 100644
--- a/drivers/input/mouse/cyapa_gen5.c
+++ b/drivers/input/mouse/cyapa_gen5.c
@@ -1926,7 +1926,7 @@ static int cyapa_gen5_read_idac_data(struct cyapa *cyapa,
electrodes_tx = cyapa->electrodes_x;
max_element_cnt = ((cyapa->aligned_electrodes_rx + 7) &
~7u) * electrodes_tx;
- } else if (idac_data_type == GEN5_RETRIEVE_SELF_CAP_PWC_DATA) {
+ } else {
offset = 2;
max_element_cnt = cyapa->electrodes_x +
cyapa->electrodes_y;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] Input: cyapa - Remove superfluous type check in cyapa_gen5_read_idac_data()
2015-02-12 14:16 [PATCH] Input: cyapa - Remove superfluous type check in cyapa_gen5_read_idac_data() Geert Uytterhoeven
@ 2015-03-02 4:20 ` Dudley Du
2015-03-02 17:40 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Dudley Du @ 2015-03-02 4:20 UTC (permalink / raw)
To: Geert Uytterhoeven, Dmitry Torokhov
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Thanks for the check.
This fix is verified okay.
Dudley
> -----Original Message-----
> From: Geert Uytterhoeven [mailto:geert@linux-m68k.org]
> Sent: 2015年2月12日 22:16
> To: Dmitry Torokhov; Dudley Du
> Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; Geert Uytterhoeven
> Subject: [PATCH] Input: cyapa - Remove superfluous type check in
> cyapa_gen5_read_idac_data()
>
> drivers/input/mouse/cyapa_gen5.c: In function ‘cyapa_gen5_read_idac_data’:
> drivers/input/mouse/cyapa_gen5.c:1876: warning: ‘max_element_cnt’ may be
> used uninitialized in this function
> drivers/input/mouse/cyapa_gen5.c:1873: warning: ‘offset’ may be used
> uninitialized in this function
>
> If *data_size is non-zero, and idac_data_type contains an unknown type,
> max_element_cnt and offset will be uninitialized, and the loop will
> process non-existing data.
>
> However, this cannot happen (for now), as there's a test for unknown
> types at the top of cyapa_gen5_read_idac_data().
>
> As no "if ... else if ..." is used in other places, remove the
> superfluous "if" to silence the compiler warning.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Alternatively, we can pre-initialize max_element_cnt and offset to zero,
> and add "if (!max_element_cnt) goto out;" before the loop.
>
> drivers/input/mouse/cyapa_gen5.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c
> index ddf5393a118098fc..88c465b70e9d8776 100644
> --- a/drivers/input/mouse/cyapa_gen5.c
> +++ b/drivers/input/mouse/cyapa_gen5.c
> @@ -1926,7 +1926,7 @@ static int cyapa_gen5_read_idac_data(struct cyapa
> *cyapa,
> electrodes_tx = cyapa->electrodes_x;
> max_element_cnt = ((cyapa->aligned_electrodes_rx + 7) &
> ~7u) * electrodes_tx;
> -} else if (idac_data_type == GEN5_RETRIEVE_SELF_CAP_PWC_DATA) {
> +} else {
> offset = 2;
> max_element_cnt = cyapa->electrodes_x +
> cyapa->electrodes_y;
> --
> 1.9.1
This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: cyapa - Remove superfluous type check in cyapa_gen5_read_idac_data()
2015-03-02 4:20 ` Dudley Du
@ 2015-03-02 17:40 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2015-03-02 17:40 UTC (permalink / raw)
To: Dudley Du
Cc: Geert Uytterhoeven, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
On Mon, Mar 02, 2015 at 04:20:34AM +0000, Dudley Du wrote:
> Thanks for the check.
> This fix is verified okay.
Applied, thank you.
>
> Dudley
>
> > -----Original Message-----
> > From: Geert Uytterhoeven [mailto:geert@linux-m68k.org]
> > Sent: 2015年2月12日 22:16
> > To: Dmitry Torokhov; Dudley Du
> > Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; Geert Uytterhoeven
> > Subject: [PATCH] Input: cyapa - Remove superfluous type check in
> > cyapa_gen5_read_idac_data()
> >
> > drivers/input/mouse/cyapa_gen5.c: In function ‘cyapa_gen5_read_idac_data’:
> > drivers/input/mouse/cyapa_gen5.c:1876: warning: ‘max_element_cnt’ may be
> > used uninitialized in this function
> > drivers/input/mouse/cyapa_gen5.c:1873: warning: ‘offset’ may be used
> > uninitialized in this function
> >
> > If *data_size is non-zero, and idac_data_type contains an unknown type,
> > max_element_cnt and offset will be uninitialized, and the loop will
> > process non-existing data.
> >
> > However, this cannot happen (for now), as there's a test for unknown
> > types at the top of cyapa_gen5_read_idac_data().
> >
> > As no "if ... else if ..." is used in other places, remove the
> > superfluous "if" to silence the compiler warning.
> >
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> > Alternatively, we can pre-initialize max_element_cnt and offset to zero,
> > and add "if (!max_element_cnt) goto out;" before the loop.
> >
> > drivers/input/mouse/cyapa_gen5.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c
> > index ddf5393a118098fc..88c465b70e9d8776 100644
> > --- a/drivers/input/mouse/cyapa_gen5.c
> > +++ b/drivers/input/mouse/cyapa_gen5.c
> > @@ -1926,7 +1926,7 @@ static int cyapa_gen5_read_idac_data(struct cyapa
> > *cyapa,
> > electrodes_tx = cyapa->electrodes_x;
> > max_element_cnt = ((cyapa->aligned_electrodes_rx + 7) &
> > ~7u) * electrodes_tx;
> > -} else if (idac_data_type == GEN5_RETRIEVE_SELF_CAP_PWC_DATA) {
> > +} else {
> > offset = 2;
> > max_element_cnt = cyapa->electrodes_x +
> > cyapa->electrodes_y;
> > --
> > 1.9.1
>
>
> This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-02 17:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 14:16 [PATCH] Input: cyapa - Remove superfluous type check in cyapa_gen5_read_idac_data() Geert Uytterhoeven
2015-03-02 4:20 ` Dudley Du
2015-03-02 17:40 ` Dmitry Torokhov
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).