From 0ede25eddcab4c46860bf09d759c7b38c3d1490e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 8 Aug 2013 14:00:46 +0300 Subject: [PATCH] tools/scotest: Don't try BT_VOICE unless a non-zero voice setting was given --- tools/scotest.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/scotest.c b/tools/scotest.c index 7148be6fb..1d46f1b2f 100644 --- a/tools/scotest.c +++ b/tools/scotest.c @@ -69,7 +69,6 @@ static int do_connect(char *svr) { struct sockaddr_sco addr; struct sco_conninfo conn; - struct bt_voice opts; socklen_t optlen; int sk; @@ -92,13 +91,18 @@ static int do_connect(char *svr) goto error; } - /* SCO voice setting */ - memset(&opts, 0, sizeof(opts)); - opts.setting = voice; - if (setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &opts, sizeof(opts)) < 0) { - syslog(LOG_ERR, "Can't set socket options: %s (%d)", - strerror(errno), errno); - goto error; + if (voice) { + struct bt_voice opts; + + /* SCO voice setting */ + memset(&opts, 0, sizeof(opts)); + opts.setting = voice; + if (setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &opts, sizeof(opts)) < 0) { + syslog(LOG_ERR, + "Can't set voice socket option: %s (%d)", + strerror(errno), errno); + goto error; + } } /* Connect to remote device */ -- 2.47.3