From 79536a0265d68f38cb5ac6f021f11b9b0c480bca Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 5 Apr 2021 17:30:19 +0300 Subject: [PATCH] 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. --- plugins/dfu/fu-dfu-tool.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/dfu/fu-dfu-tool.c b/plugins/dfu/fu-dfu-tool.c index d92c3f169..8424cec15 100644 --- a/plugins/dfu/fu-dfu-tool.c +++ b/plugins/dfu/fu-dfu-tool.c @@ -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);