* [PATCH] client: Display address if calling 'disconnect' without arguments
@ 2015-06-04 19:06 Mateusz Lemusisk
2015-06-05 14:32 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Lemusisk @ 2015-06-04 19:06 UTC (permalink / raw)
To: linux-bluetooth
Before:
[PHILIPS BTM2180]# disconnect
Attempting to disconnect from
Successful disconnected
After:
[PHILIPS BTM2180]# disconnect
Attempting to disconnect from XX:XX:XX:XX:XX:XX
Successful disconnected
---
client/main.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/client/main.c b/client/main.c
index 41e95b2..88ae5ed 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1422,7 +1422,19 @@ static void cmd_disconn(const char *arg)
return;
}
- rl_printf("Attempting to disconnect from %s\n", arg);
+ if (strlen(arg) == 0) {
+ const char *default_address;
+ DBusMessageIter iter;
+
+ if (g_dbus_proxy_get_property(proxy, "Address", &iter) == FALSE)
+ default_address = "";
+ else
+ dbus_message_iter_get_basic(&iter, &default_address);
+
+ rl_printf("Attempting to disconnect from %s\n", default_address);
+ } else {
+ rl_printf("Attempting to disconnect from %s\n", arg);
+ }
}
static void cmd_list_attributes(const char *arg)
--
2.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] client: Display address if calling 'disconnect' without arguments
2015-06-04 19:06 [PATCH] client: Display address if calling 'disconnect' without arguments Mateusz Lemusisk
@ 2015-06-05 14:32 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2015-06-05 14:32 UTC (permalink / raw)
To: Mateusz Lemusisk; +Cc: linux-bluetooth@vger.kernel.org
Hi Mateusz,
On Thu, Jun 4, 2015 at 10:06 PM, Mateusz Lemusisk <mrlemux@gmail.com> wrote:
> Before:
>
> [PHILIPS BTM2180]# disconnect
> Attempting to disconnect from
> Successful disconnected
>
> After:
>
> [PHILIPS BTM2180]# disconnect
> Attempting to disconnect from XX:XX:XX:XX:XX:XX
> Successful disconnected
>
> ---
> client/main.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/client/main.c b/client/main.c
> index 41e95b2..88ae5ed 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -1422,7 +1422,19 @@ static void cmd_disconn(const char *arg)
> return;
> }
>
> - rl_printf("Attempting to disconnect from %s\n", arg);
> + if (strlen(arg) == 0) {
> + const char *default_address;
> + DBusMessageIter iter;
> +
> + if (g_dbus_proxy_get_property(proxy, "Address", &iter) == FALSE)
> + default_address = "";
> + else
> + dbus_message_iter_get_basic(&iter, &default_address);
> +
> + rl_printf("Attempting to disconnect from %s\n", default_address);
> + } else {
> + rl_printf("Attempting to disconnect from %s\n", arg);
> + }
> }
Please check the columns limit is 80:
WARNING:LONG_LINE: line over 80 characters
#19: FILE: client/main.c:1434:
+ rl_printf("Attempting to disconnect from %s\n", default_address);
Also there is no need to add braces to single line if/else statements
and perhaps you could move rl_printf line out of them and make it
common so in case you have an arg you just assign it to address
variable, in fact it might be possible to use arg directly.
> static void cmd_list_attributes(const char *arg)
> --
> 2.4.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-05 14:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-04 19:06 [PATCH] client: Display address if calling 'disconnect' without arguments Mateusz Lemusisk
2015-06-05 14:32 ` Luiz Augusto von Dentz
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).