Re: [PATCH] staging: speakup: separate 80+ chars lines.

From: Willy Tarreau
Date: Thu Apr 19 2018 - 02:55:52 EST


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@xxxxxxxxx>
> ---
> 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