diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2009-06-30 15:02:48 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2009-06-30 15:04:53 +0300 |
commit | 4d0426730e110b82b1e2d94d62ce57e4fa1b8382 (patch) | |
tree | a2df3037deb2a4b3441d8f704e231e5e12189cc1 /src | |
parent | 894019b3243116cc0331d7a5c58f6f502fb2f6ed (diff) | |
download | bluez-4d0426730e110b82b1e2d94d62ce57e4fa1b8382.tar.gz |
Fix device->name checks
btd_device->name is defined as "char name[248];" so checking for
device->name will always be true. Instead check for the string length
where it makes sense.
This patch maintains the previous behavior in that the Name property is
included in the GetProperties reply even if it's empty.
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/device.c b/src/device.c index a35bb7d29..f4746a286 100644 --- a/src/device.c +++ b/src/device.c @@ -302,22 +302,19 @@ static DBusMessage *get_properties(DBusConnection *conn, adapter_get_address(adapter, &src); ba2str(&src, srcaddr); - if (device->name) { - ptr = device->name; - dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &ptr); - } + ptr = device->name; + dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &ptr); /* Alias (fallback to name or address) */ if (read_device_alias(srcaddr, dstaddr, name, sizeof(name)) < 1) { - if (!ptr) { + if (strlen(ptr) == 0) { g_strdelimit(dstaddr, ":", '-'); ptr = dstaddr; } } else ptr = name; - if (ptr) - dict_append_entry(&dict, "Alias", DBUS_TYPE_STRING, &ptr); + dict_append_entry(&dict, "Alias", DBUS_TYPE_STRING, &ptr); /* Class */ if (read_remote_class(&src, &device->bdaddr, &class) == 0) { |