dfu-tool: Avoid runtime warning (overriding error)

We were seeing:

,----
| (dfu-tool:1139827): GLib-WARNING **: 17:34:42.671: GError set over the top of a previous GError or uninitialized memory.
| This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
| The overwriting error message was: no device matches for 1234:abcd
`----

This is because we were attempting to overwrite libgusb's error with one
for fwupd, and glib rightfully complains. So let's prefix it instead.
This commit is contained in:
Dirk-Jan C. Binnema 2021-04-05 17:30:19 +03:00 committed by Mario Limonciello
parent edcca6d1d7
commit 79536a0265

View File

@ -222,11 +222,9 @@ fu_dfu_tool_get_default_device (FuDfuTool *self, GError **error)
(guint16) pid,
error);
if (usb_device == NULL) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_FOUND,
"no device matches for %04x:%04x",
(guint) vid, (guint) pid);
g_prefix_error (error,
"no device matches for %04x:%04x: ",
(guint) vid, (guint) pid);
return NULL;
}
device = fu_dfu_device_new (usb_device);