* [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables
@ 2021-04-22 12:11 Colin King
2021-04-22 12:52 ` Johan Hovold
0 siblings, 1 reply; 6+ messages in thread
From: Colin King @ 2021-04-22 12:11 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Lee Jones, linux-serial
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Several variables are being assigned with values that are never
read and being updated later with a new value. The initializations
are redundant and can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/tty/serial/jsm/jsm_cls.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
index b507a2cec926..b58ea4344aaf 100644
--- a/drivers/tty/serial/jsm/jsm_cls.c
+++ b/drivers/tty/serial/jsm/jsm_cls.c
@@ -349,8 +349,8 @@ static void cls_assert_modem_signals(struct jsm_channel *ch)
static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
{
- int qleft = 0;
- u8 linestatus = 0;
+ int qleft;
+ u8 linestatus;
u8 error_mask = 0;
u16 head;
u16 tail;
@@ -365,8 +365,6 @@ static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
head = ch->ch_r_head & RQUEUEMASK;
tail = ch->ch_r_tail & RQUEUEMASK;
- /* Get our cached LSR */
- linestatus = ch->ch_cached_lsr;
ch->ch_cached_lsr = 0;
/* Store how much space we have left in the queue */
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables
2021-04-22 12:11 [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables Colin King
@ 2021-04-22 12:52 ` Johan Hovold
2021-04-22 12:53 ` Colin Ian King
0 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2021-04-22 12:52 UTC (permalink / raw)
To: Colin King
Cc: Greg Kroah-Hartman, Jiri Slaby, Lee Jones, linux-serial,
kernel-janitors, linux-kernel
On Thu, Apr 22, 2021 at 01:11:15PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Several variables are being assigned with values that are never
> read and being updated later with a new value. The initializations
> are redundant and can be removed.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/tty/serial/jsm/jsm_cls.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
> index b507a2cec926..b58ea4344aaf 100644
> --- a/drivers/tty/serial/jsm/jsm_cls.c
> +++ b/drivers/tty/serial/jsm/jsm_cls.c
> @@ -349,8 +349,8 @@ static void cls_assert_modem_signals(struct jsm_channel *ch)
>
> static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> {
> - int qleft = 0;
> - u8 linestatus = 0;
> + int qleft;
> + u8 linestatus;
> u8 error_mask = 0;
> u16 head;
> u16 tail;
> @@ -365,8 +365,6 @@ static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> head = ch->ch_r_head & RQUEUEMASK;
> tail = ch->ch_r_tail & RQUEUEMASK;
>
> - /* Get our cached LSR */
> - linestatus = ch->ch_cached_lsr;
> ch->ch_cached_lsr = 0;
Why leave this assignment in? Looks like this was all copy-pasta, but
this assignment makes even less sense now that you remove the comment
and load.
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables
2021-04-22 12:52 ` Johan Hovold
@ 2021-04-22 12:53 ` Colin Ian King
2021-04-22 12:56 ` Johan Hovold
0 siblings, 1 reply; 6+ messages in thread
From: Colin Ian King @ 2021-04-22 12:53 UTC (permalink / raw)
To: Johan Hovold
Cc: Greg Kroah-Hartman, Jiri Slaby, Lee Jones, linux-serial,
kernel-janitors, linux-kernel
On 22/04/2021 13:52, Johan Hovold wrote:
> On Thu, Apr 22, 2021 at 01:11:15PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Several variables are being assigned with values that are never
>> read and being updated later with a new value. The initializations
>> are redundant and can be removed.
>>
>> Addresses-Coverity: ("Unused value")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/tty/serial/jsm/jsm_cls.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
>> index b507a2cec926..b58ea4344aaf 100644
>> --- a/drivers/tty/serial/jsm/jsm_cls.c
>> +++ b/drivers/tty/serial/jsm/jsm_cls.c
>> @@ -349,8 +349,8 @@ static void cls_assert_modem_signals(struct jsm_channel *ch)
>>
>> static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
>> {
>> - int qleft = 0;
>> - u8 linestatus = 0;
>> + int qleft;
>> + u8 linestatus;
>> u8 error_mask = 0;
>> u16 head;
>> u16 tail;
>> @@ -365,8 +365,6 @@ static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
>> head = ch->ch_r_head & RQUEUEMASK;
>> tail = ch->ch_r_tail & RQUEUEMASK;
>>
>> - /* Get our cached LSR */
>> - linestatus = ch->ch_cached_lsr;
>> ch->ch_cached_lsr = 0;
>
> Why leave this assignment in? Looks like this was all copy-pasta, but
> this assignment makes even less sense now that you remove the comment
> and load.
Which assignment are you referring to?
>
> Johan
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables
2021-04-22 12:53 ` Colin Ian King
@ 2021-04-22 12:56 ` Johan Hovold
2021-04-22 13:01 ` Colin Ian King
0 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2021-04-22 12:56 UTC (permalink / raw)
To: Colin Ian King
Cc: Greg Kroah-Hartman, Jiri Slaby, Lee Jones, linux-serial,
kernel-janitors, linux-kernel
On Thu, Apr 22, 2021 at 01:53:03PM +0100, Colin Ian King wrote:
> On 22/04/2021 13:52, Johan Hovold wrote:
> > On Thu, Apr 22, 2021 at 01:11:15PM +0100, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> Several variables are being assigned with values that are never
> >> read and being updated later with a new value. The initializations
> >> are redundant and can be removed.
> >>
> >> Addresses-Coverity: ("Unused value")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >> ---
> >> drivers/tty/serial/jsm/jsm_cls.c | 6 ++----
> >> 1 file changed, 2 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
> >> index b507a2cec926..b58ea4344aaf 100644
> >> --- a/drivers/tty/serial/jsm/jsm_cls.c
> >> +++ b/drivers/tty/serial/jsm/jsm_cls.c
> >> @@ -349,8 +349,8 @@ static void cls_assert_modem_signals(struct jsm_channel *ch)
> >>
> >> static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> >> {
> >> - int qleft = 0;
> >> - u8 linestatus = 0;
> >> + int qleft;
> >> + u8 linestatus;
> >> u8 error_mask = 0;
> >> u16 head;
> >> u16 tail;
> >> @@ -365,8 +365,6 @@ static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> >> head = ch->ch_r_head & RQUEUEMASK;
> >> tail = ch->ch_r_tail & RQUEUEMASK;
> >>
> >> - /* Get our cached LSR */
> >> - linestatus = ch->ch_cached_lsr;
> >> ch->ch_cached_lsr = 0;
> >
> > Why leave this assignment in? Looks like this was all copy-pasta, but
> > this assignment makes even less sense now that you remove the comment
> > and load.
>
> Which assignment are you referring to?
The one just above my comment:
ch->ch_cached_lsr = 0;
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables
2021-04-22 12:56 ` Johan Hovold
@ 2021-04-22 13:01 ` Colin Ian King
2021-04-22 13:15 ` Johan Hovold
0 siblings, 1 reply; 6+ messages in thread
From: Colin Ian King @ 2021-04-22 13:01 UTC (permalink / raw)
To: Johan Hovold
Cc: Greg Kroah-Hartman, Jiri Slaby, Lee Jones, linux-serial,
kernel-janitors, linux-kernel
On 22/04/2021 13:56, Johan Hovold wrote:
> On Thu, Apr 22, 2021 at 01:53:03PM +0100, Colin Ian King wrote:
>> On 22/04/2021 13:52, Johan Hovold wrote:
>>> On Thu, Apr 22, 2021 at 01:11:15PM +0100, Colin King wrote:
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> Several variables are being assigned with values that are never
>>>> read and being updated later with a new value. The initializations
>>>> are redundant and can be removed.
>>>>
>>>> Addresses-Coverity: ("Unused value")
>>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>>> ---
>>>> drivers/tty/serial/jsm/jsm_cls.c | 6 ++----
>>>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
>>>> index b507a2cec926..b58ea4344aaf 100644
>>>> --- a/drivers/tty/serial/jsm/jsm_cls.c
>>>> +++ b/drivers/tty/serial/jsm/jsm_cls.c
>>>> @@ -349,8 +349,8 @@ static void cls_assert_modem_signals(struct jsm_channel *ch)
>>>>
>>>> static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
>>>> {
>>>> - int qleft = 0;
>>>> - u8 linestatus = 0;
>>>> + int qleft;
>>>> + u8 linestatus;
>>>> u8 error_mask = 0;
>>>> u16 head;
>>>> u16 tail;
>>>> @@ -365,8 +365,6 @@ static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
>>>> head = ch->ch_r_head & RQUEUEMASK;
>>>> tail = ch->ch_r_tail & RQUEUEMASK;
>>>>
>>>> - /* Get our cached LSR */
>>>> - linestatus = ch->ch_cached_lsr;
>>>> ch->ch_cached_lsr = 0;
>>>
>>> Why leave this assignment in? Looks like this was all copy-pasta, but
>>> this assignment makes even less sense now that you remove the comment
>>> and load.
>>
>> Which assignment are you referring to?
>
> The one just above my comment:
>
> ch->ch_cached_lsr = 0;
that cached value is being used in jsm_neo.c, so removing the zero'ing
may cause some issues.
>
> Johan
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables
2021-04-22 13:01 ` Colin Ian King
@ 2021-04-22 13:15 ` Johan Hovold
0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2021-04-22 13:15 UTC (permalink / raw)
To: Colin Ian King
Cc: Greg Kroah-Hartman, Jiri Slaby, Lee Jones, linux-serial,
kernel-janitors, linux-kernel
On Thu, Apr 22, 2021 at 02:01:36PM +0100, Colin Ian King wrote:
> On 22/04/2021 13:56, Johan Hovold wrote:
> > On Thu, Apr 22, 2021 at 01:53:03PM +0100, Colin Ian King wrote:
> >> On 22/04/2021 13:52, Johan Hovold wrote:
> >>> On Thu, Apr 22, 2021 at 01:11:15PM +0100, Colin King wrote:
> >>>> From: Colin Ian King <colin.king@canonical.com>
> >>>>
> >>>> Several variables are being assigned with values that are never
> >>>> read and being updated later with a new value. The initializations
> >>>> are redundant and can be removed.
> >>>>
> >>>> Addresses-Coverity: ("Unused value")
> >>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >>>> ---
> >>>> drivers/tty/serial/jsm/jsm_cls.c | 6 ++----
> >>>> 1 file changed, 2 insertions(+), 4 deletions(-)
> >>>>
> >>>> diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
> >>>> index b507a2cec926..b58ea4344aaf 100644
> >>>> --- a/drivers/tty/serial/jsm/jsm_cls.c
> >>>> +++ b/drivers/tty/serial/jsm/jsm_cls.c
> >>>> @@ -349,8 +349,8 @@ static void cls_assert_modem_signals(struct jsm_channel *ch)
> >>>>
> >>>> static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> >>>> {
> >>>> - int qleft = 0;
> >>>> - u8 linestatus = 0;
> >>>> + int qleft;
> >>>> + u8 linestatus;
> >>>> u8 error_mask = 0;
> >>>> u16 head;
> >>>> u16 tail;
> >>>> @@ -365,8 +365,6 @@ static void cls_copy_data_from_uart_to_queue(struct jsm_channel *ch)
> >>>> head = ch->ch_r_head & RQUEUEMASK;
> >>>> tail = ch->ch_r_tail & RQUEUEMASK;
> >>>>
> >>>> - /* Get our cached LSR */
> >>>> - linestatus = ch->ch_cached_lsr;
> >>>> ch->ch_cached_lsr = 0;
> >>>
> >>> Why leave this assignment in? Looks like this was all copy-pasta, but
> >>> this assignment makes even less sense now that you remove the comment
> >>> and load.
> >>
> >> Which assignment are you referring to?
> >
> > The one just above my comment:
> >
> > ch->ch_cached_lsr = 0;
>
> that cached value is being used in jsm_neo.c, so removing the zero'ing
> may cause some issues.
That's for you to determine, right? Only doing half of a clean may
actually be worse than doing nothing at all. At least now it's somewhat
clear why that statement is there.
The jsm_neo.c implements support for a different class of devices and
only those actually use ch_cached_lsr AFAICT.
It would be good if you include some context in the commit message such
as which commit added this code and that it has never been used.
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-22 13:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 12:11 [PATCH][next] tty: serial: jsm: remove redundant assignments of several variables Colin King
2021-04-22 12:52 ` Johan Hovold
2021-04-22 12:53 ` Colin Ian King
2021-04-22 12:56 ` Johan Hovold
2021-04-22 13:01 ` Colin Ian King
2021-04-22 13:15 ` Johan Hovold
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).