[haiku-commits] haiku: hrev50088 - headers/os/bluetooth src/kits/bluetooth/UI headers/private/bluetooth

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 14 Feb 2016 14:06:28 +0100 (CET)

hrev50088 adds 1 changeset to branch 'master'
old head: fb94ed118abf29d1880b9fbdbe353fa17cd3b36c
new head: a5a3b2d9a3d95cbae71eaf371708c73a1780ac0d
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=a5a3b2d9a3d9+%5Efb94ed118abf

----------------------------------------------------------------------------

a5a3b2d9a3d9: Bluetooth: fix thread safety issue.
  
  Fixes #11428.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50088
Commit:      a5a3b2d9a3d95cbae71eaf371708c73a1780ac0d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a5a3b2d9a3d9
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Feb 14 13:07:21 2016 UTC

Ticket:      https://dev.haiku-os.org/ticket/11428

----------------------------------------------------------------------------

4 files changed, 10 insertions(+), 10 deletions(-)
headers/os/bluetooth/LinkKeyUtils.h       | 7 +++----
headers/os/bluetooth/bdaddrUtils.h        | 9 +++++----
headers/private/bluetooth/PincodeWindow.h | 2 +-
src/kits/bluetooth/UI/PincodeWindow.cpp   | 2 +-

----------------------------------------------------------------------------

diff --git a/headers/os/bluetooth/LinkKeyUtils.h 
b/headers/os/bluetooth/LinkKeyUtils.h
index 3abbb31..56b7d91 100644
--- a/headers/os/bluetooth/LinkKeyUtils.h
+++ b/headers/os/bluetooth/LinkKeyUtils.h
@@ -24,12 +24,11 @@ public:
                return (linkkey_t){{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0}};
        }
        
-       static char* ToString(const linkkey_t lk) 
+       static BString ToString(const linkkey_t lk) 
        {
-               // TODO: not safe
-               static char str[50];
+               BString str;
 
-               sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:"
+               
str.SetToFormat("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:"
                                
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", 
                                lk.l[0], lk.l[1], lk.l[2], lk.l[3], lk.l[4], 
lk.l[5],
                                lk.l[6], lk.l[7], lk.l[8], lk.l[9], lk.l[10], 
lk.l[11],
diff --git a/headers/os/bluetooth/bdaddrUtils.h 
b/headers/os/bluetooth/bdaddrUtils.h
index 9b86c32..0b1a2bf 100644
--- a/headers/os/bluetooth/bdaddrUtils.h
+++ b/headers/os/bluetooth/bdaddrUtils.h
@@ -9,6 +9,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <String.h>
+
 #include <bluetooth/bluetooth.h>
 
 namespace Bluetooth {
@@ -45,12 +47,11 @@ public:
                memcpy(&dst, &src, sizeof(bdaddr_t));
        }
 
-       static char* ToString(const bdaddr_t bdaddr)
+       static BString ToString(const bdaddr_t bdaddr)
        {
-               // TODO: not safe
-               static char str[18];
+               BString str;
 
-               sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[5],
+               
str.SetToFormat("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[5],
                                bdaddr.b[4], bdaddr.b[3], bdaddr.b[2], 
bdaddr.b[1],
                                bdaddr.b[0]);
                return str;
diff --git a/headers/private/bluetooth/PincodeWindow.h 
b/headers/private/bluetooth/PincodeWindow.h
index c7bb86b..d39ad7b 100644
--- a/headers/private/bluetooth/PincodeWindow.h
+++ b/headers/private/bluetooth/PincodeWindow.h
@@ -27,7 +27,7 @@ public:
                                                        
PincodeWindow(RemoteDevice* rDevice);
        virtual void                    MessageReceived(BMessage *msg);
        virtual bool                    QuitRequested();
-                       void                    SetBDaddr(const char* address);
+                       void                    SetBDaddr(BString address);
 
 private:
                        void                    InitUI();
diff --git a/src/kits/bluetooth/UI/PincodeWindow.cpp 
b/src/kits/bluetooth/UI/PincodeWindow.cpp
index 65b1ae5..e2757df 100644
--- a/src/kits/bluetooth/UI/PincodeWindow.cpp
+++ b/src/kits/bluetooth/UI/PincodeWindow.cpp
@@ -187,7 +187,7 @@ bool PincodeWindow::QuitRequested()
 }
 
 
-void PincodeWindow::SetBDaddr(const char* address)
+void PincodeWindow::SetBDaddr(BString address)
 {
        BString label;
 


Other related posts:

  • » [haiku-commits] haiku: hrev50088 - headers/os/bluetooth src/kits/bluetooth/UI headers/private/bluetooth - pulkomandy