Bug 779473 - Fix some nsresult abuses in the Bluetooth implementation
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 13 Oct 2012 10:45:45 -0400
changeset 110286 5c273dc49dee15119fac485ee3040f1bc71f2e05
parent 110285 7c6513e197ad4037bd467b0728861dcbf1a4d3f7
child 110287 169ae9c542e81b315698c8469c845277590450db
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
bugs779473
milestone19.0a1
Bug 779473 - Fix some nsresult abuses in the Bluetooth implementation
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothService.cpp
dom/bluetooth/BluetoothUtils.cpp
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -553,17 +553,17 @@ BluetoothHfpManager::Connect(const nsASt
   if (aIsHandsfree) {
     serviceUuidStr = NS_ConvertUTF8toUTF16(HANDSFREE_UUID);
   } else {
     serviceUuidStr = NS_ConvertUTF8toUTF16(HEADSET_UUID);
   }
 
   nsCOMPtr<nsIRILContentHelper> ril =
     do_GetService("@mozilla.org/ril/content-helper;1");
-  NS_ENSURE_TRUE(ril, NS_ERROR_UNEXPECTED);
+  NS_ENSURE_TRUE(ril, false);
   ril->EnumerateCalls(mListener->GetCallback());
 
   nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
 
   nsresult rv = bs->GetSocketViaService(aDeviceObjectPath,
                                         serviceUuidStr,
                                         BluetoothSocketType::RFCOMM,
                                         true,
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -709,17 +709,17 @@ SetJsObject(JSContext* aContext,
 {
   for (uint32_t i = 0; i < aData.Length(); i++) {
     jsval v;
     if (aData[i].value().type() == BluetoothValue::TnsString) {
       nsString data = aData[i].value().get_nsString();
       JSString* JsData = JS_NewStringCopyN(aContext,
                                            NS_ConvertUTF16toUTF8(data).get(),
                                            data.Length());
-      NS_ENSURE_TRUE(JsData, NS_ERROR_OUT_OF_MEMORY);
+      NS_ENSURE_TRUE(JsData, false);
       v = STRING_TO_JSVAL(JsData);
     } else if (aData[i].value().type() == BluetoothValue::Tuint32_t) {
       int data = aData[i].value().get_uint32_t();
       v = INT_TO_JSVAL(data);
     } else if (aData[i].value().type() == BluetoothValue::Tbool) {
       bool data = aData[i].value().get_bool();
       v = BOOLEAN_TO_JSVAL(data);
     } else {
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -112,17 +112,17 @@ mozilla::dom::bluetooth::SetJsObject(JSC
 {
   for (uint32_t i = 0; i < aData.Length(); i++) {
     jsval v;
     if (aData[i].value().type() == BluetoothValue::TnsString) {
       nsString data = aData[i].value().get_nsString();
       JSString* JsData = JS_NewStringCopyN(aContext,
                                            NS_ConvertUTF16toUTF8(data).get(),
                                            data.Length());
-      NS_ENSURE_TRUE(JsData, NS_ERROR_OUT_OF_MEMORY);
+      NS_ENSURE_TRUE(JsData, false);
       v = STRING_TO_JSVAL(JsData);
     } else if (aData[i].value().type() == BluetoothValue::Tuint32_t) {
       int data = aData[i].value().get_uint32_t();
       v = INT_TO_JSVAL(data);
     } else if (aData[i].value().type() == BluetoothValue::Tbool) {
       bool data = aData[i].value().get_bool();
       v = BOOLEAN_TO_JSVAL(data);
     } else {
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
@@ -170,17 +170,17 @@ BluetoothServiceChildProcess::GetDeviceP
   //         can be reworked.
   nsAutoString path(aAdapterPath);
   path.AppendLiteral("/dev_");
   path.Append(aDeviceAddress);
   path.ReplaceChar(':', '_');
 
   aDevicePath = path;
 
-  return NS_OK;
+  return true;
 }
 
 nsresult
 BluetoothServiceChildProcess::CreatePairedDeviceInternal(
                                               const nsAString& aAdapterPath,
                                               const nsAString& aAddress,
                                               int aTimeout,
                                               BluetoothReplyRunnable* aRunnable)