Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1605358 > unrolled thread

[PATCH staging/speakup v3 0/3] cleanup error and initilization

Started by"Pranay Kr. Srivastava" <pranjas@gmail.com>
First post2017-03-21 08:20 +0100
Last post2017-03-21 08:40 +0100
Articles 3 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH staging/speakup v3 0/3] cleanup error and initilization "Pranay Kr. Srivastava" <pranjas@gmail.com> - 2017-03-21 08:20 +0100
    [PATCH staging/speakup v3 1/3] return same error value from spk_set_key_info "Pranay Kr. Srivastava" <pranjas@gmail.com> - 2017-03-21 08:20 +0100
    [PATCH staging/speakup v3 2/3] remove unnecessary initial allocation of vc "Pranay Kr. Srivastava" <pranjas@gmail.com> - 2017-03-21 08:40 +0100

#1605358 — [PATCH staging/speakup v3 0/3] cleanup error and initilization

From"Pranay Kr. Srivastava" <pranjas@gmail.com>
Date2017-03-21 08:20 +0100
Subject[PATCH staging/speakup v3 0/3] cleanup error and initilization
Message-ID<tnmff-8tT-5@gated-at.bofh.it>
Changelog from v2:
	Fixed the message subject line.

Changelog from v1:
	1. fixed kbuild warning for i386 build as reported by kbuild robot
	2. split initialization code in two patches.



Pranay Kr. Srivastava (3):
  return same error value from spk_set_key_info
  remove unecessary initial allocation of vc
  use speakup_allocate as per required context

 drivers/staging/speakup/main.c | 46 +++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

-- 
2.10.2

[toc] | [next] | [standalone]


#1605361 — [PATCH staging/speakup v3 1/3] return same error value from spk_set_key_info

From"Pranay Kr. Srivastava" <pranjas@gmail.com>
Date2017-03-21 08:20 +0100
Subject[PATCH staging/speakup v3 1/3] return same error value from spk_set_key_info
Message-ID<tnmfg-8tT-19@gated-at.bofh.it>
In reply to#1605358
This patch makes spk_set_key_info return -EINVAL
in case of failure instead of returning 4 different
values for the type of error that occurred.

Print the offending values instead as debug message.

Signed-off-by: Pranay Kr. Srivastava <pranjas@gmail.com>
---
 drivers/staging/speakup/main.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index c2f70ef..a1d5b66 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1216,13 +1216,19 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
 	u_char ch, version, num_keys;
 
 	version = *cp++;
-	if (version != KEY_MAP_VER)
-		return -1;
+	if (version != KEY_MAP_VER) {
+		pr_debug("version found %d should be %d\n",
+			 version, KEY_MAP_VER);
+		return -EINVAL;
+	}
 	num_keys = *cp;
 	states = (int)cp[1];
 	key_data_len = (states + 1) * (num_keys + 1);
-	if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf))
-		return -2;
+	if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) {
+		pr_debug("too many key_infos (%d over %u)\n",
+			 key_data_len + SHIFT_TBL_SIZE + 4, (unsigned int)(sizeof(spk_key_buf)));
+		return -EINVAL;
+	}
 	memset(k_buffer, 0, SHIFT_TBL_SIZE);
 	memset(spk_our_keys, 0, sizeof(spk_our_keys));
 	spk_shift_table = k_buffer;
@@ -1233,14 +1239,19 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
 	cp1 += 2;		/* now pointing at shift states */
 	for (i = 1; i <= states; i++) {
 		ch = *cp1++;
-		if (ch >= SHIFT_TBL_SIZE)
-			return -3;
+		if (ch >= SHIFT_TBL_SIZE) {
+			pr_debug("(%d) not valid shift state (max_allowed = %d)\n", ch,
+				 SHIFT_TBL_SIZE);
+			return -EINVAL;
+		}
 		spk_shift_table[ch] = i;
 	}
 	keymap_flags = *cp1++;
 	while ((ch = *cp1)) {
-		if (ch >= MAX_KEY)
-			return -4;
+		if (ch >= MAX_KEY) {
+			pr_debug("(%d), not valid key, (max_allowed = %d)\n", ch, MAX_KEY);
+			return -EINVAL;
+		}
 		spk_our_keys[ch] = cp1;
 		cp1 += states + 1;
 	}
-- 
2.10.2

[toc] | [prev] | [next] | [standalone]


#1605364 — [PATCH staging/speakup v3 2/3] remove unnecessary initial allocation of vc

From"Pranay Kr. Srivastava" <pranjas@gmail.com>
Date2017-03-21 08:40 +0100
Subject[PATCH staging/speakup v3 2/3] remove unnecessary initial allocation of vc
Message-ID<tnmyB-8M-1@gated-at.bofh.it>
In reply to#1605358
This patch removes the unnecessary allocation of
current foreground vc during initialization.

This initialization is already handled in the loop
that follows it for all available virtual consoles.

Signed-off-by: Pranay Kr. Srivastava <pranjas@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 drivers/staging/speakup/main.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index a1d5b66..ca817ca 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -2317,7 +2317,6 @@ static int __init speakup_init(void)
 {
 	int i;
 	long err = 0;
-	struct st_spk_t *first_console;
 	struct vc_data *vc = vc_cons[fg_console].d;
 	struct var_t *var;
 
@@ -2342,15 +2341,6 @@ static int __init speakup_init(void)
 	if (err)
 		goto error_virtkeyboard;
 
-	first_console = kzalloc(sizeof(*first_console), GFP_KERNEL);
-	if (!first_console) {
-		err = -ENOMEM;
-		goto error_alloc;
-	}
-
-	speakup_console[vc->vc_num] = first_console;
-	speakup_date(vc);
-
 	for (i = 0; i < MAX_NR_CONSOLES; i++)
 		if (vc_cons[i].d) {
 			err = speakup_allocate(vc_cons[i].d);
@@ -2412,7 +2402,6 @@ static int __init speakup_init(void)
 	for (i = 0; i < MAX_NR_CONSOLES; i++)
 		kfree(speakup_console[i]);
 
-error_alloc:
 	speakup_remove_virtual_keyboard();
 
 error_virtkeyboard:
-- 
2.10.2

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web