All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: speakup: Remove else after return
@ 2018-03-15 18:40 Nishka Dasgupta
  2018-03-15 18:53 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Nishka Dasgupta @ 2018-03-15 18:40 UTC (permalink / raw)
  To: samuel.thibault, w.d.hubbs, chris, kirk, gregkh, outreachy-kernel
  Cc: Nishka Dasgupta

Remove else after return and modify code accordingly. Issue found with
checkpatch.

Signed-off-by: Nishka Dasgupta <nishka.dasgupta_ug18@ashoka.edu.in>
---
 drivers/staging/speakup/keyhelp.c | 82 +++++++++++++++++++++++----------------
 1 file changed, 48 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c
index 5f1bda3..020e0ea 100644
--- a/drivers/staging/speakup/keyhelp.c
+++ b/drivers/staging/speakup/keyhelp.c
@@ -153,6 +153,21 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
 			return 1;
 		}
 		cur_item = letter_offsets[ch - 'a'];
+		name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
+		func = funcvals[cur_item];
+		synth_printf("%s", name);
+		if (key_offsets[func] == 0) {
+			synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
+			return 1;
+		}
+		p_keys = key_data + key_offsets[func];
+		for (n = 0; p_keys[n]; n++) {
+			val = p_keys[n];
+			if (n > 0)
+				synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
+			say_key(val);
+		}
+		return 1;
 	} else if (type == KT_CUR) {
 		if (ch == 0 &&
 		    (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END)
@@ -161,49 +176,48 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
 			cur_item--;
 		else
 			return -1;
+		name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
+		func = funcvals[cur_item];
+		synth_printf("%s", name);
+		if (key_offsets[func] == 0) {
+			synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
+			return 1;
+		}
+		p_keys = key_data + key_offsets[func];
+		for (n = 0; p_keys[n]; n++) {
+			val = p_keys[n];
+			if (n > 0)
+				synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
+			say_key(val);
+		}
+		return 1;
 	} else if (type == KT_SPKUP && ch == SPEAKUP_HELP &&
 		   !spk_special_handler) {
 		spk_special_handler = spk_handle_help;
 		synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO));
 		build_key_data(); /* rebuild each time in case new mapping */
 		return 1;
-	} else {
-		name = NULL;
-		if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
-			synth_printf("%s\n",
-				     spk_msg_get(MSG_KEYNAMES_START + key - 1));
-			return 1;
-		}
-		for (i = 0; funcvals[i] != 0 && !name; i++) {
-			if (ch == funcvals[i])
-				name = spk_msg_get(MSG_FUNCNAMES_START + i);
-		}
-		if (!name)
-			return -1;
-		kp = spk_our_keys[key] + 1;
-		for (i = 0; i < nstates; i++) {
-			if (ch == kp[i])
-				break;
-		}
-		key += (state_tbl[i] << 8);
-		say_key(key);
-		synth_printf(spk_msg_get(MSG_KEYDESC), name);
-		synth_printf("\n");
-		return 1;
 	}
-	name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
-	func = funcvals[cur_item];
-	synth_printf("%s", name);
-	if (key_offsets[func] == 0) {
-		synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
+	name = NULL;
+	if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
+		synth_printf("%s\n",
+			     spk_msg_get(MSG_KEYNAMES_START + key - 1));
 		return 1;
 	}
-	p_keys = key_data + key_offsets[func];
-	for (n = 0; p_keys[n]; n++) {
-		val = p_keys[n];
-		if (n > 0)
-			synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
-		say_key(val);
+	for (i = 0; funcvals[i] != 0 && !name; i++) {
+		if (ch == funcvals[i])
+			name = spk_msg_get(MSG_FUNCNAMES_START + i);
+	}
+	if (!name)
+		return -1;
+	kp = spk_our_keys[key] + 1;
+	for (i = 0; i < nstates; i++) {
+		if (ch == kp[i])
+			break;
 	}
+	key += (state_tbl[i] << 8);
+	say_key(key);
+	synth_printf(spk_msg_get(MSG_KEYDESC), name);
+	synth_printf("\n");
 	return 1;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: speakup: Remove else after return
  2018-03-15 18:40 [PATCH] staging: speakup: Remove else after return Nishka Dasgupta
@ 2018-03-15 18:53 ` Julia Lawall
  2018-03-15 19:02   ` Nishka Dasgupta
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2018-03-15 18:53 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: samuel.thibault, w.d.hubbs, chris, kirk, gregkh, outreachy-kernel



On Thu, 15 Mar 2018, Nishka Dasgupta wrote:

> Remove else after return and modify code accordingly. Issue found with
> checkpatch.
>
> Signed-off-by: Nishka Dasgupta <nishka.dasgupta_ug18@ashoka.edu.in>
> ---
>  drivers/staging/speakup/keyhelp.c | 82 +++++++++++++++++++++++----------------
>  1 file changed, 48 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c
> index 5f1bda3..020e0ea 100644
> --- a/drivers/staging/speakup/keyhelp.c
> +++ b/drivers/staging/speakup/keyhelp.c
> @@ -153,6 +153,21 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
>  			return 1;
>  		}
>  		cur_item = letter_offsets[ch - 'a'];
> +		name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
> +		func = funcvals[cur_item];
> +		synth_printf("%s", name);
> +		if (key_offsets[func] == 0) {
> +			synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
> +			return 1;
> +		}
> +		p_keys = key_data + key_offsets[func];
> +		for (n = 0; p_keys[n]; n++) {
> +			val = p_keys[n];
> +			if (n > 0)
> +				synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
> +			say_key(val);
> +		}
> +		return 1;

Are you sure this is ok?  If you are removing an else and ajusting the
indentation of the code, I would expect that each hunk would contain
removed code, but this one does not.

julia


>  	} else if (type == KT_CUR) {
>  		if (ch == 0 &&
>  		    (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END)
> @@ -161,49 +176,48 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
>  			cur_item--;
>  		else
>  			return -1;
> +		name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
> +		func = funcvals[cur_item];
> +		synth_printf("%s", name);
> +		if (key_offsets[func] == 0) {
> +			synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
> +			return 1;
> +		}
> +		p_keys = key_data + key_offsets[func];
> +		for (n = 0; p_keys[n]; n++) {
> +			val = p_keys[n];
> +			if (n > 0)
> +				synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
> +			say_key(val);
> +		}
> +		return 1;
>  	} else if (type == KT_SPKUP && ch == SPEAKUP_HELP &&
>  		   !spk_special_handler) {
>  		spk_special_handler = spk_handle_help;
>  		synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO));
>  		build_key_data(); /* rebuild each time in case new mapping */
>  		return 1;
> -	} else {
> -		name = NULL;
> -		if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
> -			synth_printf("%s\n",
> -				     spk_msg_get(MSG_KEYNAMES_START + key - 1));
> -			return 1;
> -		}
> -		for (i = 0; funcvals[i] != 0 && !name; i++) {
> -			if (ch == funcvals[i])
> -				name = spk_msg_get(MSG_FUNCNAMES_START + i);
> -		}
> -		if (!name)
> -			return -1;
> -		kp = spk_our_keys[key] + 1;
> -		for (i = 0; i < nstates; i++) {
> -			if (ch == kp[i])
> -				break;
> -		}
> -		key += (state_tbl[i] << 8);
> -		say_key(key);
> -		synth_printf(spk_msg_get(MSG_KEYDESC), name);
> -		synth_printf("\n");
> -		return 1;
>  	}
> -	name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
> -	func = funcvals[cur_item];
> -	synth_printf("%s", name);
> -	if (key_offsets[func] == 0) {
> -		synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
> +	name = NULL;
> +	if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
> +		synth_printf("%s\n",
> +			     spk_msg_get(MSG_KEYNAMES_START + key - 1));
>  		return 1;
>  	}
> -	p_keys = key_data + key_offsets[func];
> -	for (n = 0; p_keys[n]; n++) {
> -		val = p_keys[n];
> -		if (n > 0)
> -			synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
> -		say_key(val);
> +	for (i = 0; funcvals[i] != 0 && !name; i++) {
> +		if (ch == funcvals[i])
> +			name = spk_msg_get(MSG_FUNCNAMES_START + i);
> +	}
> +	if (!name)
> +		return -1;
> +	kp = spk_our_keys[key] + 1;
> +	for (i = 0; i < nstates; i++) {
> +		if (ch == kp[i])
> +			break;
>  	}
> +	key += (state_tbl[i] << 8);
> +	say_key(key);
> +	synth_printf(spk_msg_get(MSG_KEYDESC), name);
> +	synth_printf("\n");
>  	return 1;
>  }
> --
> 2.7.4
>
> --
> 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@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1521139235-6133-1-git-send-email-nishka.dasgupta_ug18%40ashoka.edu.in.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: speakup: Remove else after return
  2018-03-15 18:53 ` [Outreachy kernel] " Julia Lawall
@ 2018-03-15 19:02   ` Nishka Dasgupta
  2018-03-15 19:32     ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Nishka Dasgupta @ 2018-03-15 19:02 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Samuel Thibault, William Hubbs, Christopher Brannon, kirk,
	gregkh, outreachy-kernel

As far as I understand it, there was an isolated "if" statement at the
beginning, then 3 "if-else" statements, then an "else" statement and
then a block of code. Of these, the only places where I did not add
the block of code are the "else" statement (because it returns on its
own), the "if" statement just before that (it also returns) and the
first isolated "if" statement. In other places I cut and paste the
code that used to be below the "else". Should I also have done the
same below "help_init()" of the first "if" statement?

Thanking you,
Nishka Dasgupta

On Fri, Mar 16, 2018 at 12:23 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Thu, 15 Mar 2018, Nishka Dasgupta wrote:
>
>> Remove else after return and modify code accordingly. Issue found with
>> checkpatch.
>>
>> Signed-off-by: Nishka Dasgupta <nishka.dasgupta_ug18@ashoka.edu.in>
>> ---
>>  drivers/staging/speakup/keyhelp.c | 82 +++++++++++++++++++++++----------------
>>  1 file changed, 48 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c
>> index 5f1bda3..020e0ea 100644
>> --- a/drivers/staging/speakup/keyhelp.c
>> +++ b/drivers/staging/speakup/keyhelp.c
>> @@ -153,6 +153,21 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
>>                       return 1;
>>               }
>>               cur_item = letter_offsets[ch - 'a'];
>> +             name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
>> +             func = funcvals[cur_item];
>> +             synth_printf("%s", name);
>> +             if (key_offsets[func] == 0) {
>> +                     synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
>> +                     return 1;
>> +             }
>> +             p_keys = key_data + key_offsets[func];
>> +             for (n = 0; p_keys[n]; n++) {
>> +                     val = p_keys[n];
>> +                     if (n > 0)
>> +                             synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
>> +                     say_key(val);
>> +             }
>> +             return 1;
>
> Are you sure this is ok?  If you are removing an else and ajusting the
> indentation of the code, I would expect that each hunk would contain
> removed code, but this one does not.
>
> julia
>
>
>>       } else if (type == KT_CUR) {
>>               if (ch == 0 &&
>>                   (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END)
>> @@ -161,49 +176,48 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
>>                       cur_item--;
>>               else
>>                       return -1;
>> +             name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
>> +             func = funcvals[cur_item];
>> +             synth_printf("%s", name);
>> +             if (key_offsets[func] == 0) {
>> +                     synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
>> +                     return 1;
>> +             }
>> +             p_keys = key_data + key_offsets[func];
>> +             for (n = 0; p_keys[n]; n++) {
>> +                     val = p_keys[n];
>> +                     if (n > 0)
>> +                             synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
>> +                     say_key(val);
>> +             }
>> +             return 1;
>>       } else if (type == KT_SPKUP && ch == SPEAKUP_HELP &&
>>                  !spk_special_handler) {
>>               spk_special_handler = spk_handle_help;
>>               synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO));
>>               build_key_data(); /* rebuild each time in case new mapping */
>>               return 1;
>> -     } else {
>> -             name = NULL;
>> -             if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
>> -                     synth_printf("%s\n",
>> -                                  spk_msg_get(MSG_KEYNAMES_START + key - 1));
>> -                     return 1;
>> -             }
>> -             for (i = 0; funcvals[i] != 0 && !name; i++) {
>> -                     if (ch == funcvals[i])
>> -                             name = spk_msg_get(MSG_FUNCNAMES_START + i);
>> -             }
>> -             if (!name)
>> -                     return -1;
>> -             kp = spk_our_keys[key] + 1;
>> -             for (i = 0; i < nstates; i++) {
>> -                     if (ch == kp[i])
>> -                             break;
>> -             }
>> -             key += (state_tbl[i] << 8);
>> -             say_key(key);
>> -             synth_printf(spk_msg_get(MSG_KEYDESC), name);
>> -             synth_printf("\n");
>> -             return 1;
>>       }
>> -     name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
>> -     func = funcvals[cur_item];
>> -     synth_printf("%s", name);
>> -     if (key_offsets[func] == 0) {
>> -             synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
>> +     name = NULL;
>> +     if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
>> +             synth_printf("%s\n",
>> +                          spk_msg_get(MSG_KEYNAMES_START + key - 1));
>>               return 1;
>>       }
>> -     p_keys = key_data + key_offsets[func];
>> -     for (n = 0; p_keys[n]; n++) {
>> -             val = p_keys[n];
>> -             if (n > 0)
>> -                     synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
>> -             say_key(val);
>> +     for (i = 0; funcvals[i] != 0 && !name; i++) {
>> +             if (ch == funcvals[i])
>> +                     name = spk_msg_get(MSG_FUNCNAMES_START + i);
>> +     }
>> +     if (!name)
>> +             return -1;
>> +     kp = spk_our_keys[key] + 1;
>> +     for (i = 0; i < nstates; i++) {
>> +             if (ch == kp[i])
>> +                     break;
>>       }
>> +     key += (state_tbl[i] << 8);
>> +     say_key(key);
>> +     synth_printf(spk_msg_get(MSG_KEYDESC), name);
>> +     synth_printf("\n");
>>       return 1;
>>  }
>> --
>> 2.7.4
>>
>> --
>> 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@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1521139235-6133-1-git-send-email-nishka.dasgupta_ug18%40ashoka.edu.in.
>> For more options, visit https://groups.google.com/d/optout.
>>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: speakup: Remove else after return
  2018-03-15 19:02   ` Nishka Dasgupta
@ 2018-03-15 19:32     ` Julia Lawall
  2018-03-15 21:10       ` Samuel Thibault
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2018-03-15 19:32 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: Samuel Thibault, William Hubbs, Christopher Brannon, kirk,
	gregkh, outreachy-kernel



On Fri, 16 Mar 2018, Nishka Dasgupta wrote:

> As far as I understand it, there was an isolated "if" statement at the
> beginning, then 3 "if-else" statements, then an "else" statement and
> then a block of code. Of these, the only places where I did not add
> the block of code are the "else" statement (because it returns on its
> own), the "if" statement just before that (it also returns) and the
> first isolated "if" statement. In other places I cut and paste the
> code that used to be below the "else". Should I also have done the
> same below "help_init()" of the first "if" statement?

OK.  I expected something like:

  if (...) {
    ...
  }
- else
-   foo();
+ foo();

But I see that the code has a lot of returns, so that would not be
appropriate here.

But the new code is longer and has more code duplication, so I think that
the code was better off the way it was.

julia

>
> Thanking you,
> Nishka Dasgupta
>
> On Fri, Mar 16, 2018 at 12:23 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> >
> > On Thu, 15 Mar 2018, Nishka Dasgupta wrote:
> >
> >> Remove else after return and modify code accordingly. Issue found with
> >> checkpatch.
> >>
> >> Signed-off-by: Nishka Dasgupta <nishka.dasgupta_ug18@ashoka.edu.in>
> >> ---
> >>  drivers/staging/speakup/keyhelp.c | 82 +++++++++++++++++++++++----------------
> >>  1 file changed, 48 insertions(+), 34 deletions(-)
> >>
> >> diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c
> >> index 5f1bda3..020e0ea 100644
> >> --- a/drivers/staging/speakup/keyhelp.c
> >> +++ b/drivers/staging/speakup/keyhelp.c
> >> @@ -153,6 +153,21 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
> >>                       return 1;
> >>               }
> >>               cur_item = letter_offsets[ch - 'a'];
> >> +             name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
> >> +             func = funcvals[cur_item];
> >> +             synth_printf("%s", name);
> >> +             if (key_offsets[func] == 0) {
> >> +                     synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
> >> +                     return 1;
> >> +             }
> >> +             p_keys = key_data + key_offsets[func];
> >> +             for (n = 0; p_keys[n]; n++) {
> >> +                     val = p_keys[n];
> >> +                     if (n > 0)
> >> +                             synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
> >> +                     say_key(val);
> >> +             }
> >> +             return 1;
> >
> > Are you sure this is ok?  If you are removing an else and ajusting the
> > indentation of the code, I would expect that each hunk would contain
> > removed code, but this one does not.
> >
> > julia
> >
> >
> >>       } else if (type == KT_CUR) {
> >>               if (ch == 0 &&
> >>                   (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END)
> >> @@ -161,49 +176,48 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
> >>                       cur_item--;
> >>               else
> >>                       return -1;
> >> +             name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
> >> +             func = funcvals[cur_item];
> >> +             synth_printf("%s", name);
> >> +             if (key_offsets[func] == 0) {
> >> +                     synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
> >> +                     return 1;
> >> +             }
> >> +             p_keys = key_data + key_offsets[func];
> >> +             for (n = 0; p_keys[n]; n++) {
> >> +                     val = p_keys[n];
> >> +                     if (n > 0)
> >> +                             synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
> >> +                     say_key(val);
> >> +             }
> >> +             return 1;
> >>       } else if (type == KT_SPKUP && ch == SPEAKUP_HELP &&
> >>                  !spk_special_handler) {
> >>               spk_special_handler = spk_handle_help;
> >>               synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO));
> >>               build_key_data(); /* rebuild each time in case new mapping */
> >>               return 1;
> >> -     } else {
> >> -             name = NULL;
> >> -             if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
> >> -                     synth_printf("%s\n",
> >> -                                  spk_msg_get(MSG_KEYNAMES_START + key - 1));
> >> -                     return 1;
> >> -             }
> >> -             for (i = 0; funcvals[i] != 0 && !name; i++) {
> >> -                     if (ch == funcvals[i])
> >> -                             name = spk_msg_get(MSG_FUNCNAMES_START + i);
> >> -             }
> >> -             if (!name)
> >> -                     return -1;
> >> -             kp = spk_our_keys[key] + 1;
> >> -             for (i = 0; i < nstates; i++) {
> >> -                     if (ch == kp[i])
> >> -                             break;
> >> -             }
> >> -             key += (state_tbl[i] << 8);
> >> -             say_key(key);
> >> -             synth_printf(spk_msg_get(MSG_KEYDESC), name);
> >> -             synth_printf("\n");
> >> -             return 1;
> >>       }
> >> -     name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
> >> -     func = funcvals[cur_item];
> >> -     synth_printf("%s", name);
> >> -     if (key_offsets[func] == 0) {
> >> -             synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
> >> +     name = NULL;
> >> +     if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
> >> +             synth_printf("%s\n",
> >> +                          spk_msg_get(MSG_KEYNAMES_START + key - 1));
> >>               return 1;
> >>       }
> >> -     p_keys = key_data + key_offsets[func];
> >> -     for (n = 0; p_keys[n]; n++) {
> >> -             val = p_keys[n];
> >> -             if (n > 0)
> >> -                     synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
> >> -             say_key(val);
> >> +     for (i = 0; funcvals[i] != 0 && !name; i++) {
> >> +             if (ch == funcvals[i])
> >> +                     name = spk_msg_get(MSG_FUNCNAMES_START + i);
> >> +     }
> >> +     if (!name)
> >> +             return -1;
> >> +     kp = spk_our_keys[key] + 1;
> >> +     for (i = 0; i < nstates; i++) {
> >> +             if (ch == kp[i])
> >> +                     break;
> >>       }
> >> +     key += (state_tbl[i] << 8);
> >> +     say_key(key);
> >> +     synth_printf(spk_msg_get(MSG_KEYDESC), name);
> >> +     synth_printf("\n");
> >>       return 1;
> >>  }
> >> --
> >> 2.7.4
> >>
> >> --
> >> 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@googlegroups.com.
> >> To post to this group, send email to outreachy-kernel@googlegroups.com.
> >> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1521139235-6133-1-git-send-email-nishka.dasgupta_ug18%40ashoka.edu.in.
> >> For more options, visit https://groups.google.com/d/optout.
> >>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: speakup: Remove else after return
  2018-03-15 19:32     ` Julia Lawall
@ 2018-03-15 21:10       ` Samuel Thibault
  0 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2018-03-15 21:10 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Nishka Dasgupta, William Hubbs, Christopher Brannon, kirk,
	gregkh, outreachy-kernel

Julia Lawall, on jeu. 15 mars 2018 20:32:35 +0100, wrote:
> But the new code is longer and has more code duplication, so I think that
> the code was better off the way it was.

Yes, please :)

Samuel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-15 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15 18:40 [PATCH] staging: speakup: Remove else after return Nishka Dasgupta
2018-03-15 18:53 ` [Outreachy kernel] " Julia Lawall
2018-03-15 19:02   ` Nishka Dasgupta
2018-03-15 19:32     ` Julia Lawall
2018-03-15 21:10       ` Samuel Thibault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.