util/readline: errors clean-ups
v2 cover util/readline: errors clean-ups
This v2 version combines two fix of errors into one and replace tab indent by four spaces
Jules Irenge (2):
util/readline: add a space to fix errors by checkpatch tool
util: readline: replace tab indent by four spaces to fix checkpatch
errors
util/readline.c | 132 ++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 66 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 util/readline: add a space to fix errors by checkpatch tool
util/readline: add a space to fix errors reported by checkpatch.pl tool "ERROR: space required before the open parenthesis"
"ERROR: space required after that ..."
within "util/redline.c" file
--- util/readline.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
util/readline.c +17 -17
@@ -48,13 +48,13 @@ static void readline_update(ReadLineState *rs)if (rs->cmd_buf_size != rs->last_cmd_buf_size ||memcmp (rs->cmd_buf, rs->last_cmd_buf, rs->cmd_buf_size) !=0 ) { -for (i =0 ; i < rs->last_cmd_buf_index; i++) { +for (i =0 ; i < rs->last_cmd_buf_index; i++) { rs->printf_func (rs->opaque,"\033[D" ); } rs->cmd_buf[rs->cmd_buf_size] ='\0' ;if (rs->read_password) { len =strlen (rs->cmd_buf); -for (i =0 ; i < len; i++) +for (i =0 ; i < len; i++) rs->printf_func (rs->opaque,"*" ); }else { rs->printf_func (rs->opaque,"%s" , rs->cmd_buf);
@@ -67,12 +67,12 @@ static void readline_update(ReadLineState *rs)if (rs->cmd_buf_index != rs->last_cmd_buf_index) { delta = rs->cmd_buf_index - rs->last_cmd_buf_index;if (delta >0 ) { -for (i =0 ;i < delta; i++) { +for (i =0 ; i < delta; i++) { rs->printf_func (rs->opaque,"\033[C" ); } }else { delta = -delta; -for (i =0 ;i < delta; i++) { +for (i =0 ; i < delta; i++) { rs->printf_func (rs->opaque,"\033[D" ); } }
@@ -301,7 +301,7 @@ static void readline_completion(ReadLineState *rs)return ;if (rs->nb_completions ==1 ) { len =strlen (rs->completions[0 ]); -for (i = rs->completion_index; i < len; i++) { +for (i = rs->completion_index; i < len; i++) {readline_insert_char (rs, rs->completions[0 ][i]); }/* extra space for next argument. XXX: make it more generic */
@@ -312,15 +312,15 @@ static void readline_completion(ReadLineState *rs) completion_comp); rs->printf_func (rs->opaque,"\n" ); max_width =0 ; - max_prefix =0 ; -for (i =0 ; i < rs->nb_completions; i++) { + max_prefix =0 ; +for (i =0 ; i < rs->nb_completions; i++) { len =strlen (rs->completions[i]); -if (i==0 ) { +if (i ==0 ) { max_prefix = len; }else {if (len < max_prefix) max_prefix = len; -for (j=0 ; j<max_prefix; j++) { +for (j =0 ; j < max_prefix; j++) {if (rs->completions[i][j] != rs->completions[0 ][j]) max_prefix = j; }
@@ -328,8 +328,8 @@ static void readline_completion(ReadLineState *rs)if (len > max_width) max_width = len; } -if (max_prefix >0 ) -for (i = rs->completion_index; i < max_prefix; i++) { +if (max_prefix >0 ) +for (i = rs->completion_index; i < max_prefix; i++) {readline_insert_char (rs, rs->completions[0 ][i]); } max_width +=2 ;
@@ -339,7 +339,7 @@ static void readline_completion(ReadLineState *rs) max_width =80 ; nb_cols =80 / max_width; j =0 ; -for (i =0 ; i < rs->nb_completions; i++) { +for (i =0 ; i < rs->nb_completions; i++) { rs->printf_func (rs->opaque,"%-*s" , max_width, rs->completions[i]);if (++j == nb_cols || i == (rs->nb_completions -1 )) { rs->printf_func (rs->opaque,"\n" );
@@ -362,9 +362,9 @@ static void readline_clear_screen(ReadLineState *rs)/* return true if command handled */ void readline_handle_byte (ReadLineState *rs,int ch) { -switch (rs->esc_state) { +switch (rs->esc_state) {case IS_NORM : -switch (ch) { +switch (ch) {case 1 :readline_bol (rs);break ;
@@ -425,7 +425,7 @@ void readline_handle_byte(ReadLineState *rs, int ch) }break ;case IS_CSI : -switch (ch) { +switch (ch) {case 'A' :case 'F' :readline_up_char (rs);
@@ -444,7 +444,7 @@ void readline_handle_byte(ReadLineState *rs, int ch) rs->esc_param = rs->esc_param *10 + (ch -'0' ); goto the_end;case '~' : -switch (rs->esc_param) { +switch (rs->esc_param) {case 1 :readline_bol (rs);break ;
@@ -463,7 +463,7 @@ void readline_handle_byte(ReadLineState *rs, int ch) the_end:break ;case IS_SS3 : -switch (ch) { +switch (ch) {case 'F' :readline_eol (rs);break ;
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v2 1/2] util/readline: add a space to fix errors by checkpatch tool
Quoted 9 lines · Jules Irenge
util/readline: add a space to fix errors reported by checkpatch.pl tool "ERROR: space required before the open parenthesis"
"ERROR: space required after that ..."
within "util/redline.c" fileSigned-off-by Jules Irenge <[email protected]>--- util/readline.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
PATCH v2 2/2 util: readline: replace tab indent by four spaces to fix checkpatch errors
In reply to Jules IrengeReplace tab indent by four spaces to fix errors issued by checkpatch.pl tool "ERROR: code indent should never use tabs" within "util/readline.c" file.
--- util/readline.c | 98 ++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 49 deletions(-)
util/readline.c +49 -49
@@ -179,20 +179,20 @@ static void readline_up_char(ReadLineState *rs)int idx;if (rs->hist_entry ==0 ) -return ; +return ;if (rs->hist_entry ==-1 ) { -/* Find latest entry */ -for (idx =0 ; idx <READLINE_MAX_CMDS ; idx++) { -if (rs->history[idx] ==NULL ) -break ; - } - rs->hist_entry = idx; +/* Find latest entry */ +for (idx =0 ; idx <READLINE_MAX_CMDS ; idx++) { +if (rs->history[idx] ==NULL ) +break ; + } + rs->hist_entry = idx; } rs->hist_entry--;if (rs->hist_entry >=0 ) { -pstrcpy (rs->cmd_buf,sizeof (rs->cmd_buf), +pstrcpy (rs->cmd_buf,sizeof (rs->cmd_buf), rs->history[rs->hist_entry]); - rs->cmd_buf_index = rs->cmd_buf_size =strlen (rs->cmd_buf); + rs->cmd_buf_index = rs->cmd_buf_size =strlen (rs->cmd_buf); } }
@@ -202,11 +202,11 @@ static void readline_down_char(ReadLineState *rs)return ;if (rs->hist_entry <READLINE_MAX_CMDS -1 && rs->history[++rs->hist_entry] !=NULL ) { -pstrcpy (rs->cmd_buf,sizeof (rs->cmd_buf), +pstrcpy (rs->cmd_buf,sizeof (rs->cmd_buf), rs->history[rs->hist_entry]); }else { rs->cmd_buf[0 ] =0 ; - rs->hist_entry =-1 ; + rs->hist_entry =-1 ; } rs->cmd_buf_index = rs->cmd_buf_size =strlen (rs->cmd_buf); }
@@ -217,42 +217,42 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)int idx;if (cmdline[0 ] =='\0' ) -return ; +return ; new_entry =NULL ;if (rs->hist_entry !=-1 ) { -/* We were editing an existing history entry: replace it */ - hist_entry = rs->history[rs->hist_entry]; - idx = rs->hist_entry; -if (strcmp (hist_entry, cmdline) ==0 ) { - goto same_entry; - } +/* We were editing an existing history entry: replace it */ + hist_entry = rs->history[rs->hist_entry]; + idx = rs->hist_entry; +if (strcmp (hist_entry, cmdline) ==0 ) { + goto same_entry; + } }/* Search cmdline in history buffers */ for (idx =0 ; idx <READLINE_MAX_CMDS ; idx++) { - hist_entry = rs->history[idx]; -if (hist_entry ==NULL ) -break ; -if (strcmp (hist_entry, cmdline) ==0 ) { - same_entry: - new_entry = hist_entry; -/* Put this entry at the end of history */ -memmove (&rs->history[idx], &rs->history[idx +1 ], - (READLINE_MAX_CMDS - (idx +1 )) *sizeof (char *)); - rs->history[READLINE_MAX_CMDS -1 ] =NULL ; -for (; idx <READLINE_MAX_CMDS ; idx++) { -if (rs->history[idx] ==NULL ) -break ; - } -break ; - } + hist_entry = rs->history[idx]; +if (hist_entry ==NULL ) +break ; +if (strcmp (hist_entry, cmdline) ==0 ) { + same_entry: + new_entry = hist_entry; +/* Put this entry at the end of history */ +memmove (&rs->history[idx], &rs->history[idx +1 ], + (READLINE_MAX_CMDS - (idx +1 )) *sizeof (char *)); + rs->history[READLINE_MAX_CMDS -1 ] =NULL ; +for (; idx <READLINE_MAX_CMDS ; idx++) { +if (rs->history[idx] ==NULL ) +break ; + } +break ; + } }if (idx ==READLINE_MAX_CMDS ) { -/* Need to get one free slot */ +/* Need to get one free slot */ g_free (rs->history[0 ]); -memmove (rs->history, &rs->history[1 ], - (READLINE_MAX_CMDS -1 ) *sizeof (char *)); - rs->history[READLINE_MAX_CMDS -1 ] =NULL ; - idx =READLINE_MAX_CMDS -1 ; +memmove (rs->history, &rs->history[1 ], + (READLINE_MAX_CMDS -1 ) *sizeof (char *)); + rs->history[READLINE_MAX_CMDS -1 ] =NULL ; + idx =READLINE_MAX_CMDS -1 ; }if (new_entry ==NULL ) new_entry =g_strdup (cmdline);
@@ -403,9 +403,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)case 8 :readline_backspace (rs);break ; -case 155 : +case 155 : rs->esc_state =IS_CSI ; -break ; +break ;default :if (ch >=32 ) {readline_insert_char (rs, ch);
@@ -426,14 +426,14 @@ void readline_handle_byte(ReadLineState *rs, int ch)break ;case IS_CSI :switch (ch) { -case 'A' : -case 'F' : -readline_up_char (rs); -break ; -case 'B' : -case 'E' : -readline_down_char (rs); -break ; +case 'A' : +case 'F' : +readline_up_char (rs); +break ; +case 'B' : +case 'E' : +readline_down_char (rs); +break ;case 'D' :readline_backward_char (rs);break ;
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v2 2/2] util: readline: replace tab indent by four spaces to fix checkpatch errors
Quoted 7 lines · Jules Irenge
Replace tab indent by four spaces to fix errors issued by checkpatch.pl tool "ERROR: code indent should never use tabs" within "
util/readline.c" file.Signed-off-by Jules Irenge <[email protected]>--- util/readline.c | 98 ++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 49 deletions(-)
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v2 0/2] util/readline: errors clean-ups
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'2e75b209af util: readline: replace tab indent by four spaces to fix checkpatch errors d797524276 util/readline: add a space to fix errors by checkpatch tool
=== OUTPUT BEGIN ===
1/2 Checking commit d79752427670 (util/readline: add a space to fix errors by checkpatch tool)
ERROR: braces {} are necessary for all arms of this statement
#31: FILE: util/readline.c:57:
+ for (i = 0; i < len; i++)
[...]
total: 1 errors, 0 warnings, 109 lines checked
Patch 1/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/2 Checking commit 2e75b209af4f (util: readline: replace tab indent by four spaces to fix checkpatch errors)
ERROR: braces {} are necessary for all arms of this statement
#32: FILE: util/readline.c:186:
+ if (rs->history[idx] == NULL)
[...]
ERROR: braces {} are necessary for all arms of this statement #101: FILE: util/readline.c:233:
+ if (hist_entry == NULL)
[...]
ERROR: braces {} are necessary for all arms of this statement #111: FILE: util/readline.c:243:
+ if (rs->history[idx] == NULL)
[...]
total: 3 errors, 0 warnings, 145 lines checked
Patch 2/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Stefan Hajnoczi
AppliedQuoted 10 lines · Jules Irenge
This v2 version combines two fix of errors into one and replace tab indent by four spaces
Jules Irenge (2):
util/readline: add a space to fix errors by checkpatch tool
util: readline: replace tab indent by four spaces to fix checkpatch
errorsutil/readline.c | 132 ++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 66 deletions(-)
This file is unmaintained, I'll take this patch through my tree.
Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next
Stefan