Re: [Outreachy kernel] [PATCH 5/6] staging: speakup: Avoid multiple assignments on same line

From: Julia Lawall
Date: Fri Mar 03 2017 - 13:47:45 EST




On Sat, 4 Mar 2017, Arushi Singhal wrote:

> This patch fixes the checkpatch.pl warning "multiple assignments
> should be avoided."
>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@xxxxxxxxx>
> ---
> drivers/staging/speakup/main.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index 4c3b5c627718..7915e75664f4 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -269,9 +269,12 @@ static unsigned char get_attributes(struct vc_data *vc, u16 *pos)
>
> static void speakup_date(struct vc_data *vc)
> {
> - spk_x = spk_cx = vc->vc_x;
> - spk_y = spk_cy = vc->vc_y;
> - spk_pos = spk_cp = vc->vc_pos;
> + spk_x = vc->vc_x;
> + spk_cx = vc->vc_x;
> + spk_y = vc->vc_y;
> + spk_cy = vc->vc_y;
> + spk_pos = vc->vc_pos;
> + spk_cp = vc->vc_pos;
> spk_old_attr = spk_attr;
> spk_attr = get_attributes(vc, (u_short *)spk_pos);
> }
> @@ -1643,9 +1646,12 @@ static int speak_highlight(struct vc_data *vc)
> spk_do_flush();
> spkup_write(speakup_console[vc_num]->ht.highbuf[hc],
> speakup_console[vc_num]->ht.highsize[hc]);
> - spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc];
> - spk_x = spk_cx = speakup_console[vc_num]->ht.rx[hc];
> - spk_y = spk_cy = speakup_console[vc_num]->ht.ry[hc];
> + spk_pos = speakup_console[vc_num]->ht.rpos[hc];
> + spk_cp = speakup_console[vc_num]->ht.rpos[hc];
> + spk_x = speakup_console[vc_num]->ht.rx[hc];
> + spk_cx = speakup_console[vc_num]->ht.rx[hc];
> + spk_y = speakup_console[vc_num]->ht.ry[hc];
> + spk_cy = speakup_console[vc_num]->ht.ry[hc];

It could be better to put eg spk_cp = spk_pos;. Repeating th big
expression on the right hand side could be error prone in the long term.

julia

> return 1;
> }
> return 0;
> --
> 2.11.0
>
> --
> 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@xxxxxxxxxxxxxxxxx
> To post to this group, send email to outreachy-kernel@xxxxxxxxxxxxxxxxx
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170303183707.14830-6-arushisinghal19971997%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>