device: Support device listing of devices without name

Some devices doesn't have a configured "name", don't print "(null)" in
this case.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2020-06-29 00:10:27 -07:00
parent afc61c7f6a
commit 507f5b8bf3

View File

@@ -223,7 +223,10 @@ void device_list_devices(void)
char buf[80];
list_for_each_entry(device, &devices, node) {
len = snprintf(buf, sizeof(buf), "%-20s %s", device->board, device->name);
if (device->name)
len = snprintf(buf, sizeof(buf), "%-20s %s", device->board, device->name);
else
len = snprintf(buf, sizeof(buf), "%s", device->board);
hdr.type = MSG_LIST_DEVICES;
hdr.len = len;