Skip to contentSkip to conversation

staging: speakup: main: switch multiple assignment for one assignment per line

PATCH In review Lourdes Pedrajas 2 participants 3 messages Mar 15, 2020 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: speakup: main: switch multiple assignment for one assignment per line

One assignment per line is preferred, instead of multiple assignments. To prevent possible undefined behavior.
Issue found with checkpath.

---
 drivers/staging/speakup/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/speakup/main.c +2 -1
index 488f2539aa9a..d363009863e3 100644
@@ -2117,7 +2117,8 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
 			spk_keydown = 0;
 			goto out;
 		}
-		value = spk_lastkey = pad_chars[value];
+		spk_lastkey = pad_chars[value];
+		value = pad_chars[value];
 		spk_keydown++;
 		spk_parked &= 0xfe;
 		goto no_map;
Signature · 1 line
2.17.1
#1 lore raw

Hello,

Lourdes Pedrajas, le dim. 15 mars 2020 05:40:51 +0100, a ecrit:

Quoted 2 lines

One assignment per line is preferred, instead of multiple assignments. To prevent possible undefined behavior.

Here the behavior is completely defined, but one assignment per line makes it more readable.

Quoted 12 lines

Issue found with checkpath.

---
 drivers/staging/speakup/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/speakup/main.c +0 -0
index 488f2539aa9a..d363009863e3 100644

drivers/staging/speakup/main.c speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, · line 2121

Quoted 6 lines
drivers/staging/speakup/main.c +2 -1
@@ -2117,7 +2117,8 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
 			spk_keydown = 0;
 			goto out;
 		}
-		value = spk_lastkey = pad_chars[value];
+		spk_lastkey = pad_chars[value];
+		value = pad_chars[value];

Please rather use

		value = pad_chars[value];
		spk_lastkey = value

To make it clear that it's the same value which is used, and to have the spk_something assignment next to the other spk_something assignments.

Quoted 6 lines
drivers/staging/speakup/main.c +0 -0
 		spk_keydown++;
 		spk_parked &= 0xfe;
 		goto no_map;
Signature · 1 line
2.17.1
#2 lore raw
Quoted 10 lines · Samuel Thibault

Hello,

Lourdes Pedrajas, le dim. 15 mars 2020 05:40:51 +0100, a ecrit:

Quoted 2 lines

One assignment per line is preferred, instead of multiple assignments. To prevent possible undefined behavior.

Here the behavior is completely defined, but one assignment per line makes it more readable.

Quoted 8 lines

Please rather use

		value = pad_chars[value];
		spk_lastkey = value

To make it clear that it's the same value which is used, and to have the spk_something assignment next to the other spk_something assignments.

Thank you for the explanation, I makes sense to me. I will make the changes,

Lourdes.