Skip to contentSkip to conversation

staging: speakup: Clean up parentheses

PATCH In review Sreya Mittal 2 participants 2 messages Feb 28, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 staging: speakup: Clean up parentheses

Align next line of print statements
to the right of open parentheses and
remove extra parentheses.

---

No changes from previous patch.

 drivers/staging/speakup/keyhelp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/speakup/keyhelp.c +5 -5
index ce94cb1..c373762 100644
@@ -115,9 +115,9 @@ static void say_key(int key)
 		if (state & masks[i])
 			synth_printf(" %s", spk_msg_get(MSG_STATES_START + i));
 	}
-	if ((key > 0) && (key <= num_key_names))
+	if (key > 0 && key <= num_key_names)
 		synth_printf(" %s\n",
-				spk_msg_get(MSG_KEYNAMES_START + (key - 1)));
+			     spk_msg_get(MSG_KEYNAMES_START + (key - 1)));
 }
 
 static int help_init(void)
@@ -164,7 +164,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
 		cur_item = letter_offsets[ch - 'a'];
 	} else if (type == KT_CUR) {
 		if (ch == 0
-		    && (MSG_FUNCNAMES_START + cur_item + 1) <=
+		    && MSG_FUNCNAMES_START + cur_item + 1 <=
 		    MSG_FUNCNAMES_END)
 			cur_item++;
 		else if (ch == 3 && cur_item > 0)
@@ -180,9 +180,9 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
 		return 1;
 	} else {
 		name = NULL;
-		if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
+		if (type != KT_SPKUP && key > 0 && key <= num_key_names) {
 			synth_printf("%s\n",
-				spk_msg_get(MSG_KEYNAMES_START + key - 1));
+				     spk_msg_get(MSG_KEYNAMES_START + key - 1));
 			return 1;
 		}
 		for (i = 0; funcvals[i] != 0 && !name; i++) {
Signature · 1 line
2.9.3
#1 lore raw
Quoted 17 lines · Sreya Mittal

Align next line of print statements
to the right of open parentheses and
remove extra parentheses.

---

No changes from previous patch.

 drivers/staging/speakup/keyhelp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/speakup/keyhelp.c +0 -0
index ce94cb1..c373762 100644

drivers/staging/speakup/keyhelp.c static void say_key(int key) · line 118

Quoted 5 lines
drivers/staging/speakup/keyhelp.c +1 -1
@@ -115,9 +115,9 @@ static void say_key(int key)
 		if (state & masks[i])
 			synth_printf(" %s", spk_msg_get(MSG_STATES_START + i));
 	}
-	if ((key > 0) && (key <= num_key_names))
+	if (key > 0 && key <= num_key_names)

Why are these "extra"? They make sense to keep to me, they make it more obvious to the reader what is going on here.

drivers/staging/speakup/keyhelp.c static void say_key(int key) · line 120

Quoted 3 lines
drivers/staging/speakup/keyhelp.c +1 -1
 		synth_printf(" %s\n",
-				spk_msg_get(MSG_KEYNAMES_START + (key - 1)));
+			     spk_msg_get(MSG_KEYNAMES_START + (key - 1)));

This is a different type of change than the one above, so it should be in a separate patch. Rememeber, only do one "type" of thing per patch.

drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) · line 168

Quoted 8 lines
drivers/staging/speakup/keyhelp.c +1 -1
 static int help_init(void)
@@ -164,7 +164,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
 		cur_item = letter_offsets[ch - 'a'];
 	} else if (type == KT_CUR) {
 		if (ch == 0
-		    && (MSG_FUNCNAMES_START + cur_item + 1) <=
+		    && MSG_FUNCNAMES_START + cur_item + 1 <=
 		    MSG_FUNCNAMES_END)

Again, ick, no.

Really, the statement should look like:
if (ch == 0 &&
(MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END)

which is much more readable by a person, don't you think?

thanks,

greg k-h