mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 08:47:39 +00:00
trivial: Fix warning: do not use 'else' after 'return'
This commit is contained in:
parent
d1b99ed5fc
commit
2336f6a345
@ -92,14 +92,10 @@ fu_device_locker_close(FuDeviceLocker *self, GError **error)
|
||||
G_USB_DEVICE_ERROR_NO_DEVICE)) {
|
||||
g_debug("ignoring: %s", error_local->message);
|
||||
return TRUE;
|
||||
} else {
|
||||
g_propagate_error(error, g_steal_pointer(&error_local));
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
g_propagate_error(error, g_steal_pointer(&error_local));
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
self->device_open = FALSE;
|
||||
return TRUE;
|
||||
|
@ -409,9 +409,8 @@ fu_corsair_bp_attach(FuDevice *device, FuProgress *progress, GError **error)
|
||||
if (self->is_legacy_attach) {
|
||||
guint8 cmd[FU_CORSAIR_MAX_CMD_SIZE] = {0x08, 0x10, 0x01, 0x00, 0x03, 0x00, 0x01};
|
||||
return fu_corsair_bp_command(self, cmd, CORSAIR_TRANSACTION_TIMEOUT, FALSE, error);
|
||||
} else {
|
||||
return fu_corsair_bp_set_mode(self, FU_CORSAIR_DEVICE_MODE_APPLICATION, error);
|
||||
}
|
||||
return fu_corsair_bp_set_mode(self, FU_CORSAIR_DEVICE_MODE_APPLICATION, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -455,7 +455,8 @@ fu_corsair_set_quirk_kv(FuDevice *device, const gchar *key, const gchar *value,
|
||||
G_IO_ERROR_INVALID_DATA,
|
||||
"unsupported device in quirk");
|
||||
return FALSE;
|
||||
} else if (g_strcmp0(key, "CorsairVendorInterfaceId") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "CorsairVendorInterfaceId") == 0) {
|
||||
/* clapped to uint8 because bNumInterfaces is 8 bits long */
|
||||
if (!fu_strtoull(value, &vendor_interface, 0, 255, error)) {
|
||||
g_prefix_error(error, "cannot parse CorsairVendorInterface: ");
|
||||
@ -463,7 +464,8 @@ fu_corsair_set_quirk_kv(FuDevice *device, const gchar *key, const gchar *value,
|
||||
}
|
||||
self->vendor_interface = vendor_interface;
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(key, "CorsairSubdeviceId") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "CorsairSubdeviceId") == 0) {
|
||||
self->subdevice_id = g_strdup(value);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -975,7 +975,9 @@ fu_cros_ec_usb_device_detach(FuDevice *device, FuProgress *progress, GError **er
|
||||
g_debug("skipping immediate reboot in case of already in bootloader");
|
||||
/* in RO so skip reboot */
|
||||
return TRUE;
|
||||
} else if (self->targ.common.flash_protection != 0x0) {
|
||||
}
|
||||
|
||||
if (self->targ.common.flash_protection != 0x0) {
|
||||
/* in RW, and RO region is write protected, so jump to RO */
|
||||
fu_device_add_private_flag(device, FU_CROS_EC_USB_DEVICE_FLAG_RO_WRITTEN);
|
||||
fu_device_set_remove_delay(device, CROS_EC_REMOVE_DELAY_RE_ENUMERATE);
|
||||
|
@ -377,7 +377,7 @@ fu_dell_dock_hid_tbt_map_error(guint32 code)
|
||||
{
|
||||
if (code == 1)
|
||||
return g_strerror(EINVAL);
|
||||
else if (code == 2)
|
||||
if (code == 2)
|
||||
return g_strerror(EPERM);
|
||||
|
||||
return g_strerror(EIO);
|
||||
|
@ -350,7 +350,8 @@ fu_dell_dock_is_valid_dock(FuDevice *device, GError **error)
|
||||
if (self->base_type == DOCK_BASE_TYPE_SALOMON) {
|
||||
fu_device_add_instance_id(device, DELL_DOCK_EC_INSTANCE_ID);
|
||||
return TRUE;
|
||||
} else if (self->base_type == DOCK_BASE_TYPE_ATOMIC) {
|
||||
}
|
||||
if (self->base_type == DOCK_BASE_TYPE_ATOMIC) {
|
||||
fu_device_add_instance_id(device, DELL_DOCK_ATOMIC_EC_INSTANCE_ID);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ fu_dell_dock_mst_check_type(FuDevice *device)
|
||||
tmp = g_ptr_array_index(instance_ids, i);
|
||||
if (g_strcmp0(tmp, DELL_DOCK_VMM6210_INSTANCE_ID) == 0)
|
||||
return Cayenne_mst;
|
||||
else if (g_strcmp0(tmp, DELL_DOCK_VM5331_INSTANCE_ID) == 0)
|
||||
if (g_strcmp0(tmp, DELL_DOCK_VM5331_INSTANCE_ID) == 0)
|
||||
return Panamera_mst;
|
||||
}
|
||||
return Unknown;
|
||||
@ -1121,7 +1121,8 @@ fu_dell_dock_mst_set_quirk_kv(FuDevice *device,
|
||||
return FALSE;
|
||||
self->blob_build_offset = tmp;
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(key, "DellDockInstallDurationI2C") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "DellDockInstallDurationI2C") == 0) {
|
||||
if (!fu_strtoull(value, &tmp, 0, 60 * 60 * 24, error))
|
||||
return FALSE;
|
||||
fu_device_set_install_duration(device, tmp);
|
||||
|
@ -156,25 +156,30 @@ fu_dell_dock_tbt_set_quirk_kv(FuDevice *device,
|
||||
return FALSE;
|
||||
self->unlock_target = tmp;
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(key, "DellDockInstallDurationI2C") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "DellDockInstallDurationI2C") == 0) {
|
||||
if (!fu_strtoull(value, &tmp, 0, 60 * 60 * 24, error))
|
||||
return FALSE;
|
||||
fu_device_set_install_duration(device, tmp);
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(key, "DellDockHubVersionLowest") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "DellDockHubVersionLowest") == 0) {
|
||||
self->hub_minimum_version = g_strdup(value);
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(key, "DellDockBlobMajorOffset") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "DellDockBlobMajorOffset") == 0) {
|
||||
if (!fu_strtoull(value, &tmp, 0, G_MAXUINT32, error))
|
||||
return FALSE;
|
||||
self->blob_major_offset = tmp;
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(key, "DellDockBlobMinorOffset") == 0) {
|
||||
}
|
||||
if (g_strcmp0(key, "DellDockBlobMinorOffset") == 0) {
|
||||
if (!fu_strtoull(value, &tmp, 0, G_MAXUINT32, error))
|
||||
return FALSE;
|
||||
self->blob_minor_offset = tmp;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* failed */
|
||||
g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "quirk key not supported");
|
||||
return FALSE;
|
||||
|
@ -427,9 +427,10 @@ fu_dell_plugin_backend_device_added(FuPlugin *plugin, FuDevice *device, GError *
|
||||
dock_info->flash_pkg_version = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if invalid version, don't mark device for updates */
|
||||
else if (dock_info->components[i].fw_version == 0 ||
|
||||
dock_info->components[i].fw_version == 0xffffffff) {
|
||||
if (dock_info->components[i].fw_version == 0 ||
|
||||
dock_info->components[i].fw_version == 0xffffffff) {
|
||||
old_ec = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
@ -563,27 +563,25 @@ fu_logitech_hidpp_device_fetch_battery_level(FuLogitechHidPpDevice *self, GError
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
/* fall back to the legacy Battery Level feature */
|
||||
idx = fu_logitech_hidpp_device_feature_get_idx(
|
||||
self,
|
||||
HIDPP_FEATURE_BATTERY_LEVEL_STATUS);
|
||||
if (idx != 0x00) {
|
||||
g_autoptr(FuLogitechHidPpHidppMsg) msg =
|
||||
fu_logitech_hidpp_msg_new();
|
||||
msg->report_id = HIDPP_REPORT_ID_SHORT;
|
||||
msg->device_id = priv->device_idx;
|
||||
msg->sub_id = idx;
|
||||
msg->function_id = 0x00 << 4; /* GetBatteryLevelStatus */
|
||||
msg->hidpp_version = priv->hidpp_version;
|
||||
if (!fu_logitech_hidpp_transfer(priv->io_channel, msg, error)) {
|
||||
g_prefix_error(error, "failed to get battery info: ");
|
||||
return FALSE;
|
||||
}
|
||||
if (msg->data[0] != 0x00)
|
||||
fu_device_set_battery_level(FU_DEVICE(self), msg->data[0]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* fall back to the legacy Battery Level feature */
|
||||
idx = fu_logitech_hidpp_device_feature_get_idx(self,
|
||||
HIDPP_FEATURE_BATTERY_LEVEL_STATUS);
|
||||
if (idx != 0x00) {
|
||||
g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new();
|
||||
msg->report_id = HIDPP_REPORT_ID_SHORT;
|
||||
msg->device_id = priv->device_idx;
|
||||
msg->sub_id = idx;
|
||||
msg->function_id = 0x00 << 4; /* GetBatteryLevelStatus */
|
||||
msg->hidpp_version = priv->hidpp_version;
|
||||
if (!fu_logitech_hidpp_transfer(priv->io_channel, msg, error)) {
|
||||
g_prefix_error(error, "failed to get battery info: ");
|
||||
return FALSE;
|
||||
}
|
||||
if (msg->data[0] != 0x00)
|
||||
fu_device_set_battery_level(FU_DEVICE(self), msg->data[0]);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1147,9 +1145,8 @@ fu_logitech_hidpp_device_write_firmware_pkt(FuLogitechHidPpDevice *self,
|
||||
continue;
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
g_debug("got wrong packet, continue to wait...");
|
||||
}
|
||||
g_debug("got wrong packet, continue to wait...");
|
||||
}
|
||||
|
||||
/* nothing in the queue */
|
||||
|
@ -561,11 +561,9 @@ fu_mm_device_probe(FuDevice *device, GError **error)
|
||||
{
|
||||
FuMmDevice *self = FU_MM_DEVICE(device);
|
||||
|
||||
if (self->omodem) {
|
||||
if (self->omodem)
|
||||
return fu_mm_device_probe_default(device, error);
|
||||
} else {
|
||||
return fu_mm_device_probe_udev(device, error);
|
||||
}
|
||||
return fu_mm_device_probe_udev(device, error);
|
||||
}
|
||||
|
||||
#if MM_CHECK_VERSION(1, 17, 2)
|
||||
@ -1253,9 +1251,8 @@ fu_mm_device_write_firmware_mbim_qdu(FuDevice *device,
|
||||
"[%s] MD5 not matched",
|
||||
filename);
|
||||
return FALSE;
|
||||
} else {
|
||||
g_debug("[%s] MD5 matched", filename);
|
||||
}
|
||||
g_debug("[%s] MD5 matched", filename);
|
||||
|
||||
/* autosuspend delay updated for a proper firmware update */
|
||||
fu_mm_utils_get_port_info(self->port_mbim, NULL, &device_sysfs_path, NULL, NULL);
|
||||
|
@ -138,7 +138,9 @@ fu_qsi_dock_mcu_device_enumerate_children(FuQsiDockMcuDevice *self, GError **err
|
||||
g_debug("ignoring %s --> %s", components[i].name, version);
|
||||
|
||||
continue;
|
||||
} else if (g_strcmp0(components[i].name, "MCU") == 0) {
|
||||
}
|
||||
|
||||
if (g_strcmp0(components[i].name, "MCU") == 0) {
|
||||
if ((val[0] == 0x00 && val[1] == 0x00) ||
|
||||
(val[0] == 0xFF && val[1] == 0xFF)) {
|
||||
g_debug("ignoring %s", components[i].name);
|
||||
|
@ -242,7 +242,8 @@ fu_test_plugin_write_firmware(FuPlugin *plugin,
|
||||
if (g_strcmp0(fu_device_get_logical_id(device), "child1") == 0) {
|
||||
fu_device_set_version(device, "2");
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(fu_device_get_logical_id(device), "child2") == 0) {
|
||||
}
|
||||
if (g_strcmp0(fu_device_get_logical_id(device), "child2") == 0) {
|
||||
fu_device_set_version(device, "11");
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -488,7 +488,8 @@ sync_device_removed(FuPlugin *plugin, FuDevice *device, gpointer user_data)
|
||||
if (target == NULL) {
|
||||
g_warning("Got device that could not be matched: %s", uuid);
|
||||
return;
|
||||
} else if (target->fu_device == NULL) {
|
||||
}
|
||||
if (target->fu_device == NULL) {
|
||||
g_warning("Got remove event for out-of-tree device %s", uuid);
|
||||
return;
|
||||
}
|
||||
|
@ -55,14 +55,12 @@ fu_thunderbolt_controller_kind_to_string(FuThunderboltController *self)
|
||||
if (self->controller_kind == FU_THUNDERBOLT_CONTROLLER_KIND_HOST) {
|
||||
if (self->gen >= 4)
|
||||
return "USB4 host controller";
|
||||
else
|
||||
return "Thunderbolt host controller";
|
||||
return "Thunderbolt host controller";
|
||||
}
|
||||
if (self->controller_kind == FU_THUNDERBOLT_CONTROLLER_KIND_DEVICE) {
|
||||
if (self->gen >= 4)
|
||||
return "USB4 device controller";
|
||||
else
|
||||
return "Thunderbolt device controller";
|
||||
return "Thunderbolt device controller";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -397,9 +397,13 @@ GBytes *
|
||||
fu_uefi_device_fixup_firmware(FuUefiDevice *self, GBytes *fw, GError **error)
|
||||
{
|
||||
FuUefiDevicePrivate *priv = GET_PRIVATE(self);
|
||||
efi_capsule_header_t header = {0x0};
|
||||
fwupd_guid_t esrt_guid = {0x0};
|
||||
guint hdrsize = getpagesize();
|
||||
gsize bufsz;
|
||||
const guint8 *buf = g_bytes_get_data(fw, &bufsz);
|
||||
g_autofree gchar *guid_new = NULL;
|
||||
g_autoptr(GByteArray) buf_hdr = g_byte_array_new();
|
||||
|
||||
priv->missing_header = FALSE;
|
||||
|
||||
@ -417,38 +421,33 @@ fu_uefi_device_fixup_firmware(FuUefiDevice *self, GBytes *fw, GError **error)
|
||||
if (g_strcmp0(fu_uefi_device_get_guid(self), guid_new) == 0) {
|
||||
g_debug("ESRT matches payload GUID");
|
||||
return g_bytes_ref(fw);
|
||||
} else if (g_strcmp0(guid_new, FU_EFI_FMP_CAPSULE_GUID) == 0 ||
|
||||
fu_device_has_private_flag(FU_DEVICE(self),
|
||||
FU_UEFI_DEVICE_FLAG_NO_CAPSULE_HEADER_FIXUP)) {
|
||||
return g_bytes_ref(fw);
|
||||
} else {
|
||||
guint hdrsize = getpagesize();
|
||||
fwupd_guid_t esrt_guid = {0x0};
|
||||
efi_capsule_header_t header = {0x0};
|
||||
g_autoptr(GByteArray) buf_hdr = g_byte_array_new();
|
||||
|
||||
g_debug("missing or invalid embedded capsule header");
|
||||
priv->missing_header = TRUE;
|
||||
|
||||
/* create a fake header with plausible contents */
|
||||
header.flags = priv->capsule_flags;
|
||||
header.header_size = hdrsize;
|
||||
header.capsule_image_size = bufsz + hdrsize;
|
||||
if (!fwupd_guid_from_string(fu_uefi_device_get_guid(self),
|
||||
&esrt_guid,
|
||||
FWUPD_GUID_FLAG_MIXED_ENDIAN,
|
||||
error)) {
|
||||
g_prefix_error(error, "Invalid ESRT GUID: ");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(&header.guid, &esrt_guid, sizeof(fwupd_guid_t));
|
||||
|
||||
/* prepend the header to the payload */
|
||||
g_byte_array_append(buf_hdr, (const guint8 *)&header, sizeof(header));
|
||||
fu_byte_array_set_size(buf_hdr, hdrsize, 0x00);
|
||||
g_byte_array_append(buf_hdr, buf, bufsz);
|
||||
return g_byte_array_free_to_bytes(g_steal_pointer(&buf_hdr));
|
||||
}
|
||||
if (g_strcmp0(guid_new, FU_EFI_FMP_CAPSULE_GUID) == 0 ||
|
||||
fu_device_has_private_flag(FU_DEVICE(self),
|
||||
FU_UEFI_DEVICE_FLAG_NO_CAPSULE_HEADER_FIXUP)) {
|
||||
return g_bytes_ref(fw);
|
||||
}
|
||||
|
||||
/* create a fake header with plausible contents */
|
||||
g_debug("missing or invalid embedded capsule header");
|
||||
priv->missing_header = TRUE;
|
||||
header.flags = priv->capsule_flags;
|
||||
header.header_size = hdrsize;
|
||||
header.capsule_image_size = bufsz + hdrsize;
|
||||
if (!fwupd_guid_from_string(fu_uefi_device_get_guid(self),
|
||||
&esrt_guid,
|
||||
FWUPD_GUID_FLAG_MIXED_ENDIAN,
|
||||
error)) {
|
||||
g_prefix_error(error, "Invalid ESRT GUID: ");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(&header.guid, &esrt_guid, sizeof(fwupd_guid_t));
|
||||
|
||||
/* prepend the header to the payload */
|
||||
g_byte_array_append(buf_hdr, (const guint8 *)&header, sizeof(header));
|
||||
fu_byte_array_set_size(buf_hdr, hdrsize, 0x00);
|
||||
g_byte_array_append(buf_hdr, buf, bufsz);
|
||||
return g_byte_array_free_to_bytes(g_steal_pointer(&buf_hdr));
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -819,11 +819,10 @@ fu_device_list_add(FuDeviceList *self, FuDevice *device)
|
||||
fu_device_list_replace(self, item, device);
|
||||
fu_device_uninhibit(device, "unconnected");
|
||||
return;
|
||||
} else {
|
||||
g_debug("not adding matching %s for device add, use "
|
||||
"FU_DEVICE_INTERNAL_FLAG_REPLUG_MATCH_GUID if required",
|
||||
fu_device_get_id(item->device));
|
||||
}
|
||||
g_debug("not adding matching %s for device add, use "
|
||||
"FU_DEVICE_INTERNAL_FLAG_REPLUG_MATCH_GUID if required",
|
||||
fu_device_get_id(item->device));
|
||||
}
|
||||
|
||||
/* add helper */
|
||||
|
@ -915,7 +915,8 @@ fu_engine_validate_bios_setting_input(FwupdBiosSetting *attr, const gchar **valu
|
||||
"%s is read only",
|
||||
fwupd_bios_setting_get_name(attr));
|
||||
return FALSE;
|
||||
} else if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_INTEGER) {
|
||||
}
|
||||
if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_INTEGER) {
|
||||
if (!fu_strtoull(*value, &tmp, 0, G_MAXUINT64, error))
|
||||
return FALSE;
|
||||
if (tmp < fwupd_bios_setting_get_lower_bound(attr)) {
|
||||
|
Loading…
Reference in New Issue
Block a user