Bug 1127701 - Fix warning: NS_ENSURE_TRUE(value.isNumber()) failed, r=joliu
authorBen Tian <btian@mozilla.com>
Wed, 29 Jul 2015 16:40:39 +0800
changeset 286836 434bd4c4a8f2c7e632d76a5ef2b4c03654122589
parent 286835 ac42019fb61328e80058d9067daf4fe89892c306
child 286837 ff3b8452b322894438c05eada48a121c0bba059a
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoliu
bugs1127701
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1127701 - Fix warning: NS_ENSURE_TRUE(value.isNumber()) failed, r=joliu
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothHfpManager.cpp
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -695,25 +695,29 @@ BluetoothHfpManager::HandleVoiceConnecti
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   mService = service;
 
   // Signal
   JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   voiceInfo->GetRelSignalStrength(&value);
-  NS_ENSURE_TRUE_VOID(value.isNumber());
-  mSignal = (int)ceil(value.toNumber() / 20.0);
+  if (value.isNumber()) {
+    mSignal = (int)ceil(value.toNumber() / 20.0);
+  }
 
   UpdateDeviceCIND();
 
   // Operator name
   nsCOMPtr<nsIMobileNetworkInfo> network;
   voiceInfo->GetNetwork(getter_AddRefs(network));
-  NS_ENSURE_TRUE_VOID(network);
+  if (!network) {
+    BT_LOGD("Unable to get network information");
+    return;
+  }
   network->GetLongName(mOperatorName);
 
   // According to GSM 07.07, "<format> indicates if the format is alphanumeric
   // or numeric; long alphanumeric format can be upto 16 characters long and
   // short format up to 8 characters (refer GSM MoU SE.13 [9])..."
   // However, we found that the operator name may sometimes be longer than 16
   // characters. After discussion, we decided to fix this here but not in RIL
   // or modem.
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -646,33 +646,37 @@ BluetoothHfpManager::HandleVoiceConnecti
   if (service != sCINDItems[CINDType::SERVICE].value) {
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   UpdateCIND(CINDType::SERVICE, service);
 
   JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   voiceInfo->GetRelSignalStrength(&value);
-  NS_ENSURE_TRUE_VOID(value.isNumber());
-  uint8_t signal = ceil(value.toNumber() / 20.0);
-  UpdateCIND(CINDType::SIGNAL, signal);
+  if (value.isNumber()) {
+    uint8_t signal = ceil(value.toNumber() / 20.0);
+    UpdateCIND(CINDType::SIGNAL, signal);
+  }
 
   /**
    * Possible return values for mode are:
    * - -1 (unknown): set mNetworkSelectionMode to 0 (auto)
    * - 0 (automatic): set mNetworkSelectionMode to 0 (auto)
    * - 1 (manual): set mNetworkSelectionMode to 1 (manual)
    */
   int32_t mode;
   connection->GetNetworkSelectionMode(&mode);
   mNetworkSelectionMode = (mode == 1) ? 1 : 0;
 
   nsCOMPtr<nsIMobileNetworkInfo> network;
   voiceInfo->GetNetwork(getter_AddRefs(network));
-  NS_ENSURE_TRUE_VOID(network);
+  if (!network) {
+    BT_LOGD("Unable to get network information");
+    return;
+  }
   network->GetLongName(mOperatorName);
 
   // According to GSM 07.07, "<format> indicates if the format is alphanumeric
   // or numeric; long alphanumeric format can be upto 16 characters long and
   // short format up to 8 characters (refer GSM MoU SE.13 [9])..."
   // However, we found that the operator name may sometimes be longer than 16
   // characters. After discussion, we decided to fix this here but not in RIL
   // or modem.