From c1b391d08b68f022c38e8897224e736df0d08792 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Fri, 9 Jan 2015 22:28:05 -0800 Subject: [PATCH] WiimoteReal: fix Linux Bluetooth connectivity on Linux >= 3.5 An uninitialized struct member "l2_bdaddr_type" was making most connect calls fail with "Invalid argument". The connection could succeed if the unitialized memory happened to have a zero byte in the appropriate location. --- Source/Core/Core/HW/WiimoteReal/IONix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteReal/IONix.cpp b/Source/Core/Core/HW/WiimoteReal/IONix.cpp index adcf9ab62b..67dd785a99 100644 --- a/Source/Core/Core/HW/WiimoteReal/IONix.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IONix.cpp @@ -166,7 +166,7 @@ WiimoteLinux::~WiimoteLinux() // Connect to a wiimote with a known address. bool WiimoteLinux::ConnectInternal() { - sockaddr_l2 addr; + sockaddr_l2 addr = {}; addr.l2_family = AF_BLUETOOTH; addr.l2_bdaddr = m_bdaddr; addr.l2_cid = 0; @@ -176,7 +176,7 @@ bool WiimoteLinux::ConnectInternal() if ((m_cmd_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1 || connect(m_cmd_sock, (sockaddr*)&addr, sizeof(addr)) < 0) { - DEBUG_LOG(WIIMOTE, "Unable to open output socket to wiimote."); + DEBUG_LOG(WIIMOTE, "Unable to open output socket to wiimote: %s", strerror(errno)); close(m_cmd_sock); m_cmd_sock = -1; return false; @@ -187,7 +187,7 @@ bool WiimoteLinux::ConnectInternal() if ((m_int_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1 || connect(m_int_sock, (sockaddr*)&addr, sizeof(addr)) < 0) { - DEBUG_LOG(WIIMOTE, "Unable to open input socket from wiimote."); + DEBUG_LOG(WIIMOTE, "Unable to open input socket from wiimote: %s", strerror(errno)); close(m_int_sock); close(m_cmd_sock); m_int_sock = m_cmd_sock = -1;