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 <sjoerd.simons@collabora.co.uk>
This commit is contained in:
Sjoerd Simons 2018-04-12 22:05:09 +02:00 committed by Mario Limonciello
parent 0a4409f231
commit 2bc6d0a38a
2 changed files with 10 additions and 8 deletions

View File

@ -259,7 +259,7 @@ fu_plugin_synapticsmst_enumerate (FuPlugin *plugin,
/* If we open succesfully a device exists here */ /* If we open succesfully a device exists here */
device = synapticsmst_device_new (SYNAPTICSMST_DEVICE_KIND_DIRECT, aux_node, 0, 0); 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 */ /* No device exists here, but was there - remove from DB */
if (fu_dev != NULL) { if (fu_dev != NULL) {
g_debug ("Removing devices on %s", aux_node); g_debug ("Removing devices on %s", aux_node);
@ -269,7 +269,8 @@ fu_plugin_synapticsmst_enumerate (FuPlugin *plugin,
aux_node); aux_node);
} else { } else {
/* Nothing to see here - move on*/ /* 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; continue;
} }

View File

@ -23,6 +23,7 @@
#include "config.h" #include "config.h"
#include <string.h> #include <string.h>
#include <errno.h>
#include <glib-object.h> #include <glib-object.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
@ -174,9 +175,9 @@ synapticsmst_device_enable_remote_control (SynapticsMSTDevice *device, GError **
if (priv->fd == -1) { if (priv->fd == -1) {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_PERMISSION_DENIED, g_io_error_from_errno (errno),
"cannot open device %s", "cannot open device %s: %s",
filename); filename, g_strerror (errno));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -786,9 +787,9 @@ synapticsmst_device_open (SynapticsMSTDevice *device, GError **error)
if (priv->fd == -1) { if (priv->fd == -1) {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_PERMISSION_DENIED, g_io_error_from_errno (errno),
"cannot open device %s", "cannot open device %s: %s",
filename); filename, g_strerror (errno));
return FALSE; return FALSE;
} }