All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: speakup: separate 80+ chars lines.
@ 2018-04-19  6:47 Andrew Jye Shih Chuang
  2018-04-19  6:55 ` Willy Tarreau
  2018-04-19  7:51 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Jye Shih Chuang @ 2018-04-19  6:47 UTC (permalink / raw)
  To: William Hubbs, Chris Brannon, Kirk Reiser, Samuel Thibault,
	Greg Kroah-Hartman, speakup, devel, linux-kernel, lkcamp-request
  Cc: andrewjschuang

Increase readability of code following the Kernel coding style by breaking long lines and thus eliminating the checkpatch.pl warning.

Signed-off-by: Andrew Jye Shih Chuang <andrewjschuang@gmail.com>
---
 drivers/staging/speakup/main.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index af30b70..2ba9989 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -899,12 +899,13 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc)
 	while (start < end) {
 		sentbuf[bn][i] = get_char(vc, (u_short *)start, &tmp);
 		if (i > 0) {
-			if (sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == '.' &&
+			if (sentbuf[bn][i] == SPACE &&
+			    sentbuf[bn][i - 1] == '.' &&
 			    numsentences[bn] < 9) {
 				/* Sentence Marker */
 				numsentences[bn]++;
 				sentmarks[bn][numsentences[bn]] =
-				    &sentbuf[bn][i];
+					&sentbuf[bn][i];
 			}
 		}
 		i++;
@@ -1233,7 +1234,8 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
 	key_data_len = (states + 1) * (num_keys + 1);
 	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)));
+			 key_data_len + SHIFT_TBL_SIZE + 4,
+			 (unsigned int)(sizeof(spk_key_buf)));
 		return -EINVAL;
 	}
 	memset(k_buffer, 0, SHIFT_TBL_SIZE);
@@ -1247,8 +1249,8 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
 	for (i = 1; i <= states; i++) {
 		ch = *cp1++;
 		if (ch >= SHIFT_TBL_SIZE) {
-			pr_debug("(%d) not valid shift state (max_allowed = %d)\n", 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;
@@ -1256,7 +1258,8 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
 	keymap_flags = *cp1++;
 	while ((ch = *cp1)) {
 		if (ch >= MAX_KEY) {
-			pr_debug("(%d), not valid key, (max_allowed = %d)\n", ch, MAX_KEY);
+			pr_debug("(%d), not valid key, (max_allowed = %d)\n",
+				 ch, MAX_KEY);
 			return -EINVAL;
 		}
 		spk_our_keys[ch] = cp1;
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: speakup: separate 80+ chars lines.
  2018-04-19  6:47 [PATCH] staging: speakup: separate 80+ chars lines Andrew Jye Shih Chuang
@ 2018-04-19  6:55 ` Willy Tarreau
  2018-04-19  7:51 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Willy Tarreau @ 2018-04-19  6:55 UTC (permalink / raw)
  To: Andrew Jye Shih Chuang
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, Samuel Thibault,
	Greg Kroah-Hartman, speakup, devel, linux-kernel, lkcamp-request

On Thu, Apr 19, 2018 at 03:47:10AM -0300, Andrew Jye Shih Chuang wrote:
> Increase readability of code following the Kernel coding style by breaking long lines and thus eliminating the checkpatch.pl warning.
> 
> Signed-off-by: Andrew Jye Shih Chuang <andrewjschuang@gmail.com>
> ---
>  drivers/staging/speakup/main.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index af30b70..2ba9989 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -899,12 +899,13 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc)
>  	while (start < end) {
>  		sentbuf[bn][i] = get_char(vc, (u_short *)start, &tmp);
>  		if (i > 0) {
> -			if (sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == '.' &&
> +			if (sentbuf[bn][i] == SPACE &&
> +			    sentbuf[bn][i - 1] == '.' &&
>  			    numsentences[bn] < 9) {
>  				/* Sentence Marker */
>  				numsentences[bn]++;
>  				sentmarks[bn][numsentences[bn]] =
> -				    &sentbuf[bn][i];
> +					&sentbuf[bn][i];
>  			}
>  		}

FWIW I personally feel that this multi-line condition block becomes even less
readable than it already was, and is one example where it's possibly better
to ignore the limit or organize the code different. Just as an example, this
one doing the same already looks more readable to me :


  		if (i > 0 && numsentences[bn] < 9 &&
		    sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == '.') {
			/* Sentence Marker */
  			numsentences[bn]++;
  			sentmarks[bn][numsentences[bn]] = &sentbuf[bn][i];
  		}

Willy

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

* Re: [PATCH] staging: speakup: separate 80+ chars lines.
  2018-04-19  6:47 [PATCH] staging: speakup: separate 80+ chars lines Andrew Jye Shih Chuang
  2018-04-19  6:55 ` Willy Tarreau
@ 2018-04-19  7:51 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-04-19  7:51 UTC (permalink / raw)
  To: Andrew Jye Shih Chuang
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, Samuel Thibault,
	Greg Kroah-Hartman, speakup, devel, linux-kernel, lkcamp-request

On Thu, Apr 19, 2018 at 03:47:10AM -0300, Andrew Jye Shih Chuang wrote:
> Increase readability of code following the Kernel coding style by breaking long lines and thus eliminating the checkpatch.pl warning.
> 

The commit message also needs to be wrapped.  I do it at 72 characters
like an email.  Roughly around the 70 character mark is fine.

> @@ -1233,7 +1234,8 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
>  	key_data_len = (states + 1) * (num_keys + 1);
>  	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)));
> +			 key_data_len + SHIFT_TBL_SIZE + 4,
> +			 (unsigned int)(sizeof(spk_key_buf)));

This cast isn't needed.  Just change the %u to %lu in the printk:

		pr_debug("too many key_infos (%d over %lu)\n",
			 key_data_len + SHIFT_TBL_SIZE + 4,
			 sizeof(spk_key_buf));

regards,
dan carpenter

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

end of thread, other threads:[~2018-04-19  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19  6:47 [PATCH] staging: speakup: separate 80+ chars lines Andrew Jye Shih Chuang
2018-04-19  6:55 ` Willy Tarreau
2018-04-19  7:51 ` Dan Carpenter

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.