From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 2/3] client: Remove argument checks
Date: Wed, 22 Nov 2017 15:00:18 +0200 [thread overview]
Message-ID: <20171122130019.14173-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20171122130019.14173-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is now done automatically by bt_shell with the use of the
arguments entered in the command table.
---
client/main.c | 93 -----------------------------------------------------------
1 file changed, 93 deletions(-)
diff --git a/client/main.c b/client/main.c
index a510851e3..38028c6c0 100644
--- a/client/main.c
+++ b/client/main.c
@@ -804,14 +804,6 @@ static gboolean parse_argument(int argc, char *argv[], const char **arg_table,
{
const char **opt;
- if (!argc || !strlen(argv[0])) {
- if (msg)
- bt_shell_printf("Missing on/off/%s argument\n", msg);
- else
- bt_shell_printf("Missing on/off argument\n");
- return FALSE;
- }
-
if (!strcmp(argv[0], "on") || !strcmp(argv[0], "yes")) {
*value = TRUE;
if (option)
@@ -889,11 +881,6 @@ static void cmd_select(int argc, char *argv[])
{
struct adapter *adapter;
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing controller address argument\n");
- return;
- }
-
adapter = find_ctrl_by_address(ctrl_list, argv[0]);
if (!adapter) {
bt_shell_printf("Controller %s not available\n", argv[0]);
@@ -959,11 +946,6 @@ static void cmd_system_alias(int argc, char *argv[])
{
char *name;
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing name argument\n");
- return;
- }
-
if (check_default_ctrl() == FALSE)
return;
@@ -1637,11 +1619,6 @@ static void cmd_remove(int argc, char *argv[])
{
GDBusProxy *proxy;
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing device address argument\n");
- return;
- }
-
if (check_default_ctrl() == FALSE)
return;
@@ -1688,11 +1665,6 @@ static void cmd_connect(int argc, char *argv[])
{
GDBusProxy *proxy;
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing device address argument\n");
- return;
- }
-
if (check_default_ctrl() == FALSE)
return;
@@ -1773,11 +1745,6 @@ static void cmd_set_alias(int argc, char *argv[])
{
char *name;
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing name argument\n");
- return;
- }
-
if (!default_dev) {
bt_shell_printf("No device connected\n");
return;
@@ -1797,11 +1764,6 @@ static void cmd_select_attribute(int argc, char *argv[])
{
GDBusProxy *proxy;
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing attribute argument\n");
- return;
- }
-
if (!default_dev) {
bt_shell_printf("No device connected\n");
return;
@@ -1889,11 +1851,6 @@ static void cmd_read(int argc, char *argv[])
static void cmd_write(int argc, char *argv[])
{
- if (!argc || !strlen(argv[0])) {
- bt_shell_printf("Missing data argument\n");
- return;
- }
-
if (!default_attr) {
bt_shell_printf("No attribute selected\n");
return;
@@ -1978,11 +1935,6 @@ static void cmd_register_service(int argc, char *argv[])
if (check_default_ctrl() == FALSE)
return;
- if (!argc) {
- bt_shell_printf("Missing argument\n");
- return;
- }
-
gatt_register_service(dbus_conn, default_ctrl->proxy, argc, argv);
}
@@ -1991,11 +1943,6 @@ static void cmd_unregister_service(int argc, char *argv[])
if (check_default_ctrl() == FALSE)
return;
- if (!argc) {
- bt_shell_printf("Missing argument\n");
- return;
- }
-
gatt_unregister_service(dbus_conn, default_ctrl->proxy, argc, argv);
}
@@ -2004,11 +1951,6 @@ static void cmd_register_characteristic(int argc, char *argv[])
if (check_default_ctrl() == FALSE)
return;
- if (argc < 2) {
- bt_shell_printf("Missing arguments\n");
- return;
- }
-
gatt_register_chrc(dbus_conn, default_ctrl->proxy, argc, argv);
}
@@ -2017,11 +1959,6 @@ static void cmd_unregister_characteristic(int argc, char *argv[])
if (check_default_ctrl() == FALSE)
return;
- if (argc < 1) {
- bt_shell_printf("Missing arguments\n");
- return;
- }
-
gatt_unregister_chrc(dbus_conn, default_ctrl->proxy, argc, argv);
}
@@ -2030,11 +1967,6 @@ static void cmd_register_descriptor(int argc, char *argv[])
if (check_default_ctrl() == FALSE)
return;
- if (argc < 2) {
- bt_shell_printf("Missing arguments\n");
- return;
- }
-
gatt_register_desc(dbus_conn, default_ctrl->proxy, argc, argv);
}
@@ -2043,11 +1975,6 @@ static void cmd_unregister_descriptor(int argc, char *argv[])
if (check_default_ctrl() == FALSE)
return;
- if (argc < 1) {
- bt_shell_printf("Missing arguments\n");
- return;
- }
-
gatt_unregister_desc(dbus_conn, default_ctrl->proxy, argc, argv);
}
@@ -2208,11 +2135,6 @@ static void cmd_set_advertise_tx_power(int argc, char *argv[])
static void cmd_set_advertise_name(int argc, char *argv[])
{
- if (!argc || strlen(argv[0]) == 0) {
- bt_shell_printf("Missing on/off argument\n");
- return;
- }
-
if (strcmp(argv[0], "on") == 0 || strcmp(argv[0], "yes") == 0) {
ad_advertise_name(dbus_conn, true);
return;
@@ -2231,11 +2153,6 @@ static void cmd_set_advertise_appearance(int argc, char *argv[])
long int value;
char *endptr = NULL;
- if (!argc || strlen(argv[0]) == 0) {
- bt_shell_printf("Missing value argument\n");
- return;
- }
-
if (strcmp(argv[0], "on") == 0 || strcmp(argv[0], "yes") == 0) {
ad_advertise_appearance(dbus_conn, true);
return;
@@ -2260,11 +2177,6 @@ static void cmd_set_advertise_duration(int argc, char *argv[])
long int value;
char *endptr = NULL;
- if (!argc || strlen(argv[0]) == 0) {
- bt_shell_printf("Missing value argument\n");
- return;
- }
-
value = strtol(argv[0], &endptr, 0);
if (!endptr || *endptr != '\0' || value > UINT16_MAX) {
bt_shell_printf("Invalid argument\n");
@@ -2279,11 +2191,6 @@ static void cmd_set_advertise_timeout(int argc, char *argv[])
long int value;
char *endptr = NULL;
- if (!argc || strlen(argv[0]) == 0) {
- bt_shell_printf("Missing value argument\n");
- return;
- }
-
value = strtol(argv[0], &endptr, 0);
if (!endptr || *endptr != '\0' || value > UINT16_MAX) {
bt_shell_printf("Invalid argument\n");
--
2.13.6
next prev parent reply other threads:[~2017-11-22 13:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 13:00 [PATCH BlueZ 1/3] shared/shell: Detect if the arguments are properly set Luiz Augusto von Dentz
2017-11-22 13:00 ` Luiz Augusto von Dentz [this message]
2017-11-22 13:00 ` [PATCH BlueZ 3/3] client: Fix format of arguments of set-service and set-manufacturer Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171122130019.14173-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).