Skip to contentSkip to conversation

shell: Set empty argument if optarg is NULL

PATCH Applied Luiz Augusto von Dentz 3 participants 4 messages Aug 29, 2022 – Aug 30, 2022 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 shell: Set empty argument if optarg is NULL

From: Luiz Augusto von Dentz <[email protected]>

This sets enmpty string ("") when argument don't set any optarg so the application can tell when an option was set or not.

---
 src/shared/shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/shell.c +1 -1
index dfda8128af91..4658819a4bde 100644
@@ -1158,7 +1158,7 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
 				return;
 			}
 
-			*opt->optarg[index - offset] = optarg;
+			*opt->optarg[index - offset] = optarg ? : "";
 		}
 
 		index = -1;
Signature · 1 line
2.37.2
author maintainer
#1 lore raw

PATCH 2/2 client: Add -e/--endpoint option to auto register endpoints

From: Luiz Augusto von Dentz <[email protected]>

This adds -e/--endpoint option that can be used to auto register supported endpoints.

---
 client/main.c   |  14 ++++--
 client/player.c | 122 ++++++++++++++++++++++++++++++++++--------------
 2 files changed, 98 insertions(+), 38 deletions(-)
client/main.c +11 -3
index 54f21fbdf9a0..6773d52627db 100644
@@ -3109,23 +3109,27 @@ static const struct bt_shell_menu main_menu = {
 
 static const struct option options[] = {
 	{ "agent",	required_argument, 0, 'a' },
+	{ "endpoints",	no_argument, 0, 'e' },
 	{ 0, 0, 0, 0 }
 };
 
 static const char *agent_option;
+static const char *endpoint_option;
 
 static const char **optargs[] = {
-	&agent_option
+	&agent_option,
+	&endpoint_option
 };
 
 static const char *help[] = {
-	"Register agent handler: <capability>"
+	"Register agent handler: <capability>",
+	"Register Media endpoints"
 };
 
 static const struct bt_shell_opt opt = {
 	.options = options,
 	.optno = sizeof(options) / sizeof(struct option),
-	.optstr = "a:",
+	.optstr = "a:e",
 	.optarg = optargs,
 	.help = help,
 };
@@ -3158,6 +3162,10 @@ int main(int argc, char *argv[])
 
 	bt_shell_set_env("DBUS_CONNECTION", dbus_conn);
 
+	if (endpoint_option)
+		bt_shell_set_env("AUTO_REGISTER_ENDPOINT",
+					(void *)endpoint_option);
+
 	admin_add_submenu();
 	player_add_submenu();
 
client/player.c +87 -35

145 lines not on this page · raw message

Signature · 1 line
2.37.2
#2 lore raw
In reply to Luiz Augusto von Dentz

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=672191

---Test result---

Test Summary:

CheckPatch                    FAIL      2.26 seconds
GitLint                       PASS      1.52 seconds
Prep - Setup ELL              PASS      32.33 seconds
Build - Prep                  PASS      0.79 seconds
Build - Configure             PASS      10.36 seconds
Build - Make                  PASS      958.09 seconds
Make Check                    PASS      13.15 seconds
Make Check w/Valgrind         PASS      348.11 seconds
Make Distcheck                PASS      292.00 seconds
Build w/ext ELL - Configure   PASS      10.67 seconds
Build w/ext ELL - Make        PASS      100.25 seconds
Incremental Build w/ patches  PASS      237.25 seconds
Scan Build                    WARNING   643.54 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf Output:
[BlueZ,2/2] client: Add -e/--endpoint option to auto register endpoints WARNING:LINE_SPACING: Missing a blank line after declarations #216: FILE: client/player.c:625:
+ GDBusProxy *proxy = l->data;
+ print_player(proxy, NULL);

/github/workspace/src/12958474.patch total: 0 errors, 1 warnings, 185 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/12958474.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: Scan Build - WARNING
Desc: Run Scan Build with patches
Output:
*****************************************************************************
The bugs reported by the scan-build may or may not be caused by your patches. Please check the list and fix the bugs if they are caused by your patch.
*****************************************************************************
client/player.c:1758:25: warning: Dereference of null pointer

        iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
                               ^~~~~~~~~~~~~~~~~~~~~
1 warning generated.
src/shared/shell.c:1135:19: warning: Null pointer passed to 1st parameter expecting 'nonnull'
                        data.timeout = atoi(optarg);
                                       ^~~~~~~~~~~~
src/shared/shell.c:1155:13: warning: Access to field 'options' results in a dereference of a null pointer (loaded from variable 'opt')
                        if (c != opt->options[index - offset].val) {
                                 ^~~~~~~~~~~~

2 warnings generated.

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Mon, 29 Aug 2022 14:37:37 -0700 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This sets enmpty string ("") when argument don't set any optarg so the application can tell when an option was set or not.

---
 src/shared/shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [BlueZ,1/2] shell: Set empty argument if optarg is NULL

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=75f73f6d6264
  - [BlueZ,2/2] client: Add -e/--endpoint option to auto register endpoints
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d297a5873d21

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html