diff mbox series

[BlueZ,v1] shared/shell: Remove readline color escapes

Message ID 20231117211819.257212-1-luiz.dentz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [BlueZ,v1] shared/shell: Remove readline color escapes | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:TYPO_SPELLING: 'usefull' may be misspelled - perhaps 'useful'? #71: used them with prompt since they are only really usefull when readline ^^^^^^^ WARNING:TYPO_SPELLING: 'lenth' may be misspelled - perhaps 'length'? #72: is rendering the text, so it can calculate the prompt lenth properly. ^^^^^ /github/workspace/src/src/13459641.patch total: 0 errors, 2 warnings, 37 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13459641.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake fail BluezMake FAIL: src/shared/shell.c: In function ‘bt_shell_set_prompt’: src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 1427 | asprintf(&prompt, "\001%s\002", string); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:4684: all] Error 2
tedd_an/MakeCheck fail BlueZ Make Check FAIL:
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind fail Check Valgrind FAIL: src/shared/shell.c: In function ‘bt_shell_set_prompt’: src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 1427 | asprintf(&prompt, "\001%s\002", string); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:12172: check] Error 2
tedd_an/CheckSmatch fail CheckSparse: FAIL: src/shared/crypto.c:271:21: warning: Variable length array is used. src/shared/crypto.c:272:23: warning: Variable length array is used. src/shared/gatt-helpers.c:768:31: warning: Variable length array is used. src/shared/gatt-helpers.c:830:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used. src/shared/gatt-server.c:276:25: warning: Variable length array is used. src/shared/gatt-server.c:619:25: warning: Variable length array is used. src/shared/gatt-server.c:718:25: warning: Variable length array is used. src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h): /usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' src/shared/shell.c: In function ‘bt_shell_set_prompt’: src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 1427 | asprintf(&prompt, "\001%s\002", string); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:4684: all] Error 2
tedd_an/bluezmakeextell fail Make External ELL FAIL: src/shared/shell.c: In function ‘bt_shell_set_prompt’: src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 1427 | asprintf(&prompt, "\001%s\002", string); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:4684: all] Error 2
tedd_an/IncrementalBuild fail [BlueZ,v1] shared/shell: Remove readline color escapes src/shared/shell.c: In function ‘bt_shell_set_prompt’: src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 1427 | asprintf(&prompt, "\001%s\002", string); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:4684: all] Error 2
tedd_an/ScanBuild fail Scan Build FAIL

Commit Message

Luiz Augusto von Dentz Nov. 17, 2023, 9:18 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This removes readline color escapes from color defines and instead only
used them with prompt since they are only really usefull when readline
is rendering the text, so it can calculate the prompt lenth properly.

Fixes: https://github.com/bluez/bluez/issues/10
---
 src/shared/shell.c |  6 +++++-
 src/shared/shell.h | 16 ++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

Comments

bluez.test.bot@gmail.com Nov. 17, 2023, 9:50 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=802072

---Test result---

Test Summary:
CheckPatch                    FAIL      0.72 seconds
GitLint                       PASS      0.30 seconds
BuildEll                      PASS      24.12 seconds
BluezMake                     FAIL      18.17 seconds
MakeCheck                     FAIL      34.93 seconds
MakeDistcheck                 PASS      150.89 seconds
CheckValgrind                 FAIL      15.62 seconds
CheckSmatch                   FAIL      21.80 seconds
bluezmakeextell               FAIL      14.04 seconds
IncrementalBuild              FAIL      18.67 seconds
ScanBuild                     FAIL      489.16 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v1] shared/shell: Remove readline color escapes
WARNING:TYPO_SPELLING: 'usefull' may be misspelled - perhaps 'useful'?
#71: 
used them with prompt since they are only really usefull when readline
                                                 ^^^^^^^

WARNING:TYPO_SPELLING: 'lenth' may be misspelled - perhaps 'length'?
#72: 
is rendering the text, so it can calculate the prompt lenth properly.
                                                      ^^^^^

/github/workspace/src/src/13459641.patch total: 0 errors, 2 warnings, 37 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13459641.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: BluezMake - FAIL
Desc: Build BlueZ
Output:

src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4684: all] Error 2
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:

src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8413: src/shared/libshared_glib_la-shell.lo] Error 1
make: *** [Makefile:12172: check] Error 2
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:

src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:12172: check] Error 2
##############################
Test: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:

src/shared/crypto.c:271:21: warning: Variable length array is used.
src/shared/crypto.c:272:23: warning: Variable length array is used.
src/shared/gatt-helpers.c:768:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:830:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used.
src/shared/gatt-server.c:276:25: warning: Variable length array is used.
src/shared/gatt-server.c:619:25: warning: Variable length array is used.
src/shared/gatt-server.c:718:25: warning: Variable length array is used.
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function'
/usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction'
/usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction'
/usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction'
src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4684: all] Error 2
##############################
Test: bluezmakeextell - FAIL
Desc: Build Bluez with External ELL
Output:

src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4684: all] Error 2
##############################
Test: IncrementalBuild - FAIL
Desc: Incremental build with the patches in the series
Output:
[BlueZ,v1] shared/shell: Remove readline color escapes

src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4684: all] Error 2
##############################
Test: ScanBuild - FAIL
Desc: Run Scan Build
Output:

src/shared/gatt-client.c:451:21: warning: Use of memory after it is freed
        gatt_db_unregister(op->client->db, op->db_id);
                           ^~~~~~~~~~
src/shared/gatt-client.c:696:2: warning: Use of memory after it is freed
        discovery_op_complete(op, false, att_ecode);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:993:2: warning: Use of memory after it is freed
        discovery_op_complete(op, success, att_ecode);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1099:2: warning: Use of memory after it is freed
        discovery_op_complete(op, success, att_ecode);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1291:2: warning: Use of memory after it is freed
        discovery_op_complete(op, success, att_ecode);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1356:2: warning: Use of memory after it is freed
        discovery_op_complete(op, success, att_ecode);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1631:6: warning: Use of memory after it is freed
        if (read_db_hash(op)) {
            ^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1636:2: warning: Use of memory after it is freed
        discover_all(op);
        ^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2140:6: warning: Use of memory after it is freed
        if (read_db_hash(op)) {
            ^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2148:8: warning: Use of memory after it is freed
                                                        discovery_op_ref(op),
                                                        ^~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3237:2: warning: Use of memory after it is freed
        complete_write_long_op(req, success, 0, false);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3259:2: warning: Use of memory after it is freed
        request_unref(req);
        ^~~~~~~~~~~~~~~~~~
12 warnings generated.
src/shared/shell.c: In function ‘bt_shell_set_prompt’:
src/shared/shell.c:1427:2: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result]
 1427 |  asprintf(&prompt, "\001%s\002", string);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8644: src/shared/libshared_mainloop_la-shell.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4684: all] Error 2


---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/src/shared/shell.c b/src/shared/shell.c
index fbccff5b54d9..fcce2d3aa5a4 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1419,10 +1419,14 @@  bool bt_shell_add_submenu(const struct bt_shell_menu *menu)
 
 void bt_shell_set_prompt(const char *string)
 {
+	char *prompt;
+
 	if (!data.init || data.mode)
 		return;
 
-	rl_set_prompt(string);
+	asprintf(&prompt, "\001%s\002", string);
+
+	rl_set_prompt(prompt);
 	rl_redisplay();
 }
 
diff --git a/src/shared/shell.h b/src/shared/shell.h
index 87fb5c415f20..a9a635bda959 100644
--- a/src/shared/shell.h
+++ b/src/shared/shell.h
@@ -10,14 +10,14 @@ 
 #include <getopt.h>
 #include <stdbool.h>
 
-#define COLOR_OFF	"\001\x1B[0m\002"
-#define COLOR_RED	"\001\x1B[0;91m\002"
-#define COLOR_GREEN	"\001\x1B[0;92m\002"
-#define COLOR_YELLOW	"\001\x1B[0;93m\002"
-#define COLOR_BLUE	"\001\x1B[0;94m\002"
-#define COLOR_BOLDGRAY	"\001\x1B[1;30m\002"
-#define COLOR_BOLDWHITE	"\001\x1B[1;37m\002"
-#define COLOR_HIGHLIGHT	"\001\x1B[1;39m\002"
+#define COLOR_OFF	"\x1B[0m"
+#define COLOR_RED	"\x1B[0;91m"
+#define COLOR_GREEN	"\x1B[0;92m"
+#define COLOR_YELLOW	"\x1B[0;93m"
+#define COLOR_BLUE	"\x1B[0;94m"
+#define COLOR_BOLDGRAY	"\x1B[1;30m"
+#define COLOR_BOLDWHITE	"\x1B[1;37m"
+#define COLOR_HIGHLIGHT	"\x1B[1;39m"
 
 struct bt_shell_menu;