trivial: uefi: don't prefix efivar errors

Although they can be useful for debugging the codepath leading to
a problem, they are also confusing when it comes to the end user
messages:

```
{error #0} linux.c:406 device_get(): readlink of /sys/block/nvme0n1/device/driver failed: No such file or directory
{error #1} linux.c:406 device_get(): readlink of /sys/block/nvme0n1/device/driver failed: No such file or directory
{error #2} linux.c:406 device_get(): readlink of /sys/block/nvme0n1/device/driver failed: No such file or directory
{error #3} linux.c:406 device_get(): readlink of /sys/block/nvme0n1/device/driver failed: No such file or directory:
Error writing to file descriptor: No space left on device
```

Whereas if they weren't shown, that last message would have been plenty.
This commit is contained in:
Mario Limonciello 2019-10-06 13:52:55 -05:00 committed by Mario Limonciello
parent 42f33df3dc
commit 01c2f651da
3 changed files with 8 additions and 13 deletions

View File

@ -419,10 +419,9 @@ fu_uefi_guess_esp_path (GError **error)
return fu_uefi_probe_for_esp (error);
}
gboolean
fu_uefi_prefix_efi_errors (GError **error)
void
fu_uefi_print_efivar_errors (void)
{
g_autoptr(GString) str = g_string_new (NULL);
for (gint i = 0; ; i++) {
gchar *filename = NULL;
gchar *function = NULL;
@ -432,12 +431,8 @@ fu_uefi_prefix_efi_errors (GError **error)
if (efi_error_get (i, &filename, &function, &line,
&message, &err) <= 0)
break;
g_string_append_printf (str, "{error #%d} %s:%d %s(): %s: %s\t",
i, filename, line, function,
message, strerror (err));
g_debug ("{efivar error #%d} %s:%d %s(): %s: %s\t",
i, filename, line, function,
message, strerror (err));
}
if (str->len > 1)
g_string_truncate (str, str->len - 1);
g_prefix_error (error, "%s: ", str->str);
return FALSE;
}

View File

@ -83,6 +83,6 @@ GPtrArray *fu_uefi_get_esrt_entry_paths (const gchar *esrt_path,
GError **error);
guint64 fu_uefi_read_file_as_uint64 (const gchar *path,
const gchar *attr_name);
gboolean fu_uefi_prefix_efi_errors (GError **error);
void fu_uefi_print_efivar_errors (void);
G_END_DECLS

View File

@ -371,7 +371,7 @@ fu_uefi_device_write_update_info (FuUefiDevice *self,
/* convert to EFI device path */
dp_buf = fu_uefi_device_build_dp_buf (filename, &dp_bufsz, error);
if (dp_buf == NULL) {
fu_uefi_prefix_efi_errors (error);
fu_uefi_print_efivar_errors ();
return FALSE;
}
@ -387,7 +387,7 @@ fu_uefi_device_write_update_info (FuUefiDevice *self,
FU_UEFI_VARS_ATTR_BOOTSERVICE_ACCESS |
FU_UEFI_VARS_ATTR_RUNTIME_ACCESS,
error)) {
fu_uefi_prefix_efi_errors (error);
fu_uefi_print_efivar_errors ();
return FALSE;
}
return TRUE;