diff --git a/plugins/bcm57xx/fu-bcm57xx-device.c b/plugins/bcm57xx/fu-bcm57xx-device.c index 8bee27df3..6b9ded167 100644 --- a/plugins/bcm57xx/fu-bcm57xx-device.c +++ b/plugins/bcm57xx/fu-bcm57xx-device.c @@ -7,6 +7,10 @@ #include "config.h" +#ifdef HAVE_ERRNO_H +#include +#endif +#include #ifdef HAVE_ETHTOOL_H #include #include @@ -564,6 +568,18 @@ fu_bcm57xx_device_open (FuDevice *device, GError **error) #ifdef HAVE_SOCKET_H FuBcm57xxDevice *self = FU_BCM57XX_DEVICE (device); self->ethtool_fd = socket (AF_INET, SOCK_DGRAM, 0); + if (self->ethtool_fd < 0) { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_NOT_SUPPORTED, + "failed to open socket: %s", +#ifdef HAVE_ERRNO_H + strerror (errno)); +#else + "unspecified error"); +#endif + return FALSE; + } return TRUE; #else g_set_error_literal (error, @@ -578,8 +594,7 @@ static gboolean fu_bcm57xx_device_close (FuDevice *device, GError **error) { FuBcm57xxDevice *self = FU_BCM57XX_DEVICE (device); - close (self->ethtool_fd); - return TRUE; + return g_close (self->ethtool_fd, error); } static void diff --git a/plugins/bcm57xx/fu-bcm57xx-recovery-device.c b/plugins/bcm57xx/fu-bcm57xx-recovery-device.c index cede4a319..7616f75d3 100644 --- a/plugins/bcm57xx/fu-bcm57xx-recovery-device.c +++ b/plugins/bcm57xx/fu-bcm57xx-recovery-device.c @@ -611,8 +611,8 @@ fu_bcm57xx_recovery_device_setup (FuDevice *device, GError **error) static gboolean fu_bcm57xx_recovery_device_open (FuDevice *device, GError **error) { - FuBcm57xxRecoveryDevice *self = FU_BCM57XX_RECOVERY_DEVICE (device); #ifdef HAVE_MMAN_H + FuBcm57xxRecoveryDevice *self = FU_BCM57XX_RECOVERY_DEVICE (device); FuUdevDevice *udev_device = FU_UDEV_DEVICE (device); const gchar *sysfs_path = fu_udev_device_get_sysfs_path (udev_device); #endif