Bug 908490 - UnpackPropertiesMessage() should return false if there is an error, r=gyeh

This commit is contained in:
Eric Chou 2013-08-28 10:27:19 +08:00
Родитель 68afca33fb
Коммит a1b9ee8093
1 изменённых файлов: 13 добавлений и 21 удалений

Просмотреть файл

@ -722,13 +722,16 @@ static bool
UnpackPropertiesMessage(DBusMessage* aMsg, DBusError* aErr,
BluetoothValue& aValue, const char* aIface)
{
MOZ_ASSERT(aMsg);
Properties* propertyTypes;
int propertyTypesLength;
nsAutoString errorStr;
if (IsDBusMessageError(aMsg, aErr, errorStr) ||
dbus_message_get_type(aMsg) != DBUS_MESSAGE_TYPE_METHOD_RETURN) {
return true;
BT_WARNING("dbus message has an error.");
return false;
}
DBusMessageIter iter;
@ -797,19 +800,13 @@ GetPropertiesInternal(const nsAString& aPath,
aIface,
"GetProperties",
DBUS_TYPE_INVALID);
NS_ENSURE_TRUE(msg, false);
bool success = UnpackPropertiesMessage(msg, &err, aValue, aIface);
if (msg) {
dbus_message_unref(msg);
}
dbus_message_unref(msg);
if (!success) {
BT_WARNING("Failed to get device properties");
return false;
}
return true;
return success;
}
class AppendDeviceNameReplyHandler: public DBusReplyHandler
@ -1620,18 +1617,13 @@ GetDefaultAdapterPath(BluetoothValue& aValue, nsString& aError)
DBUS_MANAGER_IFACE,
"DefaultAdapter",
DBUS_TYPE_INVALID);
NS_ENSURE_TRUE(msg, false);
UnpackObjectPathMessage(msg, &err, aValue, aError);
if (msg) {
dbus_message_unref(msg);
}
dbus_message_unref(msg);
if (!aError.IsEmpty()) {
return false;
}
return true;
return aError.IsEmpty();
}
bool
@ -2084,9 +2076,9 @@ public:
GetObjectPathFromAddress(sAdapterPath, mDeviceAddresses[i]);
if (!GetPropertiesInternal(objectPath, DBUS_DEVICE_IFACE, v)) {
errorStr.AssignLiteral("Getting properties failed!");
DispatchBluetoothReply(mRunnable, values, errorStr);
return NS_OK;
// The target device may have been removed, so continue checking the
// next device object.
continue;
}
// We have to manually attach the path to the rest of the elements