Print the instance IDs if the GUIDs are unconverted

This caused some head scratching about the 'missing' values when doing
fu_device_to_string() before fu_device_convert_instance_ids() had been called.
This commit is contained in:
Richard Hughes 2019-09-18 11:30:54 +01:00
parent 38245ff194
commit 33cb526248

View File

@ -1789,7 +1789,6 @@ fwupd_device_to_string (FwupdDevice *device)
{ {
FwupdDevicePrivate *priv = GET_PRIVATE (device); FwupdDevicePrivate *priv = GET_PRIVATE (device);
GString *str; GString *str;
g_autoptr(GHashTable) ids = NULL;
g_return_val_if_fail (FWUPD_IS_DEVICE (device), NULL); g_return_val_if_fail (FWUPD_IS_DEVICE (device), NULL);
@ -1800,22 +1799,30 @@ fwupd_device_to_string (FwupdDevice *device)
str = g_string_append (str, "Unknown Device\n"); str = g_string_append (str, "Unknown Device\n");
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_ID, priv->id); fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_ID, priv->id);
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_PARENT_DEVICE_ID, priv->parent_id); fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_PARENT_DEVICE_ID, priv->parent_id);
ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); if (priv->guids->len > 0) {
for (guint i = 0; i < priv->instance_ids->len; i++) { g_autoptr(GHashTable) ids = NULL;
const gchar *instance_id = g_ptr_array_index (priv->instance_ids, i); ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_hash_table_insert (ids, for (guint i = 0; i < priv->instance_ids->len; i++) {
fwupd_guid_hash_string (instance_id), const gchar *instance_id = g_ptr_array_index (priv->instance_ids, i);
g_strdup (instance_id)); g_hash_table_insert (ids,
} fwupd_guid_hash_string (instance_id),
for (guint i = 0; i < priv->guids->len; i++) { g_strdup (instance_id));
const gchar *guid = g_ptr_array_index (priv->guids, i); }
const gchar *instance_id = g_hash_table_lookup (ids, guid); for (guint i = 0; i < priv->guids->len; i++) {
if (instance_id == NULL) { const gchar *guid = g_ptr_array_index (priv->guids, i);
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_GUID, guid); const gchar *instance_id = g_hash_table_lookup (ids, guid);
} else { if (instance_id == NULL) {
g_autofree gchar *tmp = NULL; fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_GUID, guid);
tmp = g_strdup_printf ("%s <- %s", guid, instance_id); } else {
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_GUID, tmp); g_autofree gchar *tmp = NULL;
tmp = g_strdup_printf ("%s <- %s", guid, instance_id);
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_GUID, tmp);
}
}
} else {
for (guint i = 0; i < priv->instance_ids->len; i++) {
const gchar *instance_id = g_ptr_array_index (priv->instance_ids, i);
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_INSTANCE_IDS, instance_id);
} }
} }
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_SERIAL, priv->serial); fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_SERIAL, priv->serial);