From 2bc6d0a38afdcbbab9b8dcf522798d2ce707b1b9 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 12 Apr 2018 22:05:09 +0200 Subject: [PATCH] synapticsmst: Improve error reporting Rather then always assuming open() fails because of permission denied, generate the GError code from the errno and add the related strerror to the message. And ofcourse output the error message in debugging rather then just ignoring it. Signed-off-by: Sjoerd Simons --- plugins/synapticsmst/fu-plugin-synapticsmst.c | 5 +++-- plugins/synapticsmst/synapticsmst-device.c | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/synapticsmst/fu-plugin-synapticsmst.c b/plugins/synapticsmst/fu-plugin-synapticsmst.c index c830472f2..656aa44cc 100644 --- a/plugins/synapticsmst/fu-plugin-synapticsmst.c +++ b/plugins/synapticsmst/fu-plugin-synapticsmst.c @@ -259,7 +259,7 @@ fu_plugin_synapticsmst_enumerate (FuPlugin *plugin, /* If we open succesfully a device exists here */ device = synapticsmst_device_new (SYNAPTICSMST_DEVICE_KIND_DIRECT, aux_node, 0, 0); - if (!synapticsmst_device_open (device, NULL)) { + if (!synapticsmst_device_open (device, &error_local)) { /* No device exists here, but was there - remove from DB */ if (fu_dev != NULL) { g_debug ("Removing devices on %s", aux_node); @@ -269,7 +269,8 @@ fu_plugin_synapticsmst_enumerate (FuPlugin *plugin, aux_node); } else { /* Nothing to see here - move on*/ - g_debug ("No device found on %s", aux_node); + g_debug ("No device found on %s: %s", aux_node, error_local->message); + g_clear_error (&error_local); } continue; } diff --git a/plugins/synapticsmst/synapticsmst-device.c b/plugins/synapticsmst/synapticsmst-device.c index d691ecead..d164325e5 100644 --- a/plugins/synapticsmst/synapticsmst-device.c +++ b/plugins/synapticsmst/synapticsmst-device.c @@ -23,6 +23,7 @@ #include "config.h" #include +#include #include #include #include @@ -174,9 +175,9 @@ synapticsmst_device_enable_remote_control (SynapticsMSTDevice *device, GError ** if (priv->fd == -1) { g_set_error (error, G_IO_ERROR, - G_IO_ERROR_PERMISSION_DENIED, - "cannot open device %s", - filename); + g_io_error_from_errno (errno), + "cannot open device %s: %s", + filename, g_strerror (errno)); return FALSE; } return TRUE; @@ -786,9 +787,9 @@ synapticsmst_device_open (SynapticsMSTDevice *device, GError **error) if (priv->fd == -1) { g_set_error (error, G_IO_ERROR, - G_IO_ERROR_PERMISSION_DENIED, - "cannot open device %s", - filename); + g_io_error_from_errno (errno), + "cannot open device %s: %s", + filename, g_strerror (errno)); return FALSE; }