Diff between 7ddeb00c1a1c6ab53535155558d07f6fd4acf66f and 0ede25eddcab4c46860bf09d759c7b38c3d1490e

Changed Files

File Additions Deletions Status
tools/scotest.c +12 -8 modified

Full Patch

diff --git a/tools/scotest.c b/tools/scotest.c
index 7148be6..1d46f1b 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 */