diff --git a/plugins/dell/fu-plugin-dell.c b/plugins/dell/fu-plugin-dell.c index 88c278c24..a4f8aaeeb 100644 --- a/plugins/dell/fu-plugin-dell.c +++ b/plugins/dell/fu-plugin-dell.c @@ -113,13 +113,13 @@ static guint16 fu_dell_get_system_id(FuPlugin *plugin) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *system_id_str = NULL; guint16 system_id = 0; gchar *endptr = NULL; /* don't care for test suite */ - if (data->smi_obj->fake_smbios) + if (priv->smi_obj->fake_smbios) return 0; system_id_str = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_SKU); @@ -214,24 +214,24 @@ fu_plugin_dell_inject_fake_data(FuPlugin *plugin, guint8 *buf, gboolean can_switch_modes) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); - if (!data->smi_obj->fake_smbios) + if (!priv->smi_obj->fake_smbios) return; for (guint i = 0; i < 4; i++) - data->smi_obj->output[i] = output[i]; - data->fake_vid = vid; - data->fake_pid = pid; - data->smi_obj->fake_buffer = buf; - data->can_switch_modes = TRUE; + priv->smi_obj->output[i] = output[i]; + priv->fake_vid = vid; + priv->fake_pid = pid; + priv->smi_obj->fake_buffer = buf; + priv->can_switch_modes = TRUE; } static gboolean fu_plugin_dell_capsule_supported(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); - return data->smi_obj->fake_smbios || data->capsule_supported; + return priv->smi_obj->fake_smbios || priv->capsule_supported; } static gboolean @@ -291,7 +291,7 @@ fu_plugin_dock_node(FuPlugin *plugin, gboolean fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); FwupdVersionFormat version_format = FWUPD_VERSION_FORMAT_DELL_BIOS; guint16 pid; guint16 vid; @@ -315,13 +315,13 @@ fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError * /* don't look up immediately if a dock is connected as that would mean a SMI on every USB device that showed up on the system */ - if (!data->smi_obj->fake_smbios) { + if (!priv->smi_obj->fake_smbios) { vid = fu_usb_device_get_vid(FU_USB_DEVICE(device)); pid = fu_usb_device_get_pid(FU_USB_DEVICE(device)); platform = fu_device_get_physical_id(FU_DEVICE(device)); } else { - vid = data->fake_vid; - pid = data->fake_pid; + vid = priv->fake_vid; + pid = priv->fake_pid; platform = "fake"; } @@ -337,7 +337,7 @@ fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError * } buf.buf = NULL; - if (!fu_dell_query_dock(data->smi_obj, &buf)) { + if (!fu_dell_query_dock(priv->smi_obj, &buf)) { g_debug("no dock detected"); return TRUE; } @@ -670,7 +670,7 @@ gboolean fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *tpm_mode; const gchar *tpm_mode_alt; guint16 system_id = 0; @@ -688,12 +688,12 @@ fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error) g_autoptr(FuDevice) dev = NULL; g_autoptr(GError) error_tss = NULL; - fu_dell_clear_smi(data->smi_obj); - out = (struct tpm_status *)data->smi_obj->output; + fu_dell_clear_smi(priv->smi_obj); + out = (struct tpm_status *)priv->smi_obj->output; /* execute TPM Status Query */ - data->smi_obj->input[0] = DACI_FLASH_ARG_TPM; - if (!fu_dell_execute_simple_smi(data->smi_obj, + priv->smi_obj->input[0] = DACI_FLASH_ARG_TPM; + if (!fu_dell_execute_simple_smi(priv->smi_obj, DACI_FLASH_INTERFACE_CLASS, DACI_FLASH_INTERFACE_SELECT)) return FALSE; @@ -707,7 +707,7 @@ fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error) /* HW version is output in second /input/ arg * it may be relevant as next gen TPM is enabled */ - g_debug("TPM HW version: 0x%x", data->smi_obj->input[1]); + g_debug("TPM HW version: 0x%x", priv->smi_obj->input[1]); g_debug("TPM Status: 0x%x", out->status); /* test TPM enabled (Bit 0) */ @@ -729,8 +729,8 @@ fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error) } system_id = fu_dell_get_system_id(plugin); - if (data->smi_obj->fake_smbios) - can_switch_modes = data->can_switch_modes; + if (priv->smi_obj->fake_smbios) + can_switch_modes = priv->can_switch_modes; else if (system_id == 0) return FALSE; @@ -871,18 +871,18 @@ fu_plugin_dell_load(FuContext *ctx) static void fu_plugin_dell_init(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); + FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); - data->smi_obj = g_malloc0(sizeof(FuDellSmiObj)); + priv->smi_obj = g_malloc0(sizeof(FuDellSmiObj)); if (g_getenv("FWUPD_DELL_VERBOSE") != NULL) (void)g_setenv("LIBSMBIOS_C_DEBUG_OUTPUT_ALL", "1", TRUE); else (void)g_setenv("TSS2_LOG", "esys+none,tcti+none", FALSE); if (fu_dell_supported(plugin)) - data->smi_obj->smi = dell_smi_factory(DELL_SMI_DEFAULTS); - data->smi_obj->fake_smbios = FALSE; + priv->smi_obj->smi = dell_smi_factory(DELL_SMI_DEFAULTS); + priv->smi_obj->fake_smbios = FALSE; if (g_getenv("FWUPD_DELL_FAKE_SMBIOS") != NULL) - data->smi_obj->fake_smbios = TRUE; + priv->smi_obj->fake_smbios = TRUE; /* make sure that UEFI plugin is ready to receive devices */ fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_RUN_AFTER, "uefi_capsule"); @@ -894,20 +894,20 @@ fu_plugin_dell_init(FuPlugin *plugin) static void fu_plugin_dell_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->smi_obj->smi) - dell_smi_obj_free(data->smi_obj->smi); - g_free(data->smi_obj); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->smi_obj->smi) + dell_smi_obj_free(priv->smi_obj->smi); + g_free(priv->smi_obj); } static gboolean fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *sysfsfwdir = NULL; g_autofree gchar *esrtdir = NULL; - if (data->smi_obj->fake_smbios) { + if (priv->smi_obj->fake_smbios) { g_debug("Called with fake SMBIOS implementation. " "We're ignoring test for SBMIOS table and ESRT. " "Individual calls will need to be properly staged."); @@ -922,7 +922,7 @@ fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error) return FALSE; } - if (data->smi_obj->smi == NULL) { + if (priv->smi_obj->smi == NULL) { g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL, @@ -938,7 +938,7 @@ fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error) sysfsfwdir = fu_path_from_kind(FU_PATH_KIND_SYSFSDIR_FW); esrtdir = g_build_filename(sysfsfwdir, "efi", "esrt", NULL); if (g_file_test(esrtdir, G_FILE_TEST_EXISTS)) - data->capsule_supported = TRUE; + priv->capsule_supported = TRUE; /* capsules not supported */ if (!fu_plugin_dell_capsule_supported(plugin)) { diff --git a/plugins/flashrom/fu-plugin-flashrom.c b/plugins/flashrom/fu-plugin-flashrom.c index 517c4bc76..7cc5f8611 100644 --- a/plugins/flashrom/fu-plugin-flashrom.c +++ b/plugins/flashrom/fu-plugin-flashrom.c @@ -35,12 +35,12 @@ fu_plugin_flashrom_init(FuPlugin *plugin) static void fu_plugin_flashrom_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->flashctx != NULL) - flashrom_flash_release(data->flashctx); - if (data->flashprog != NULL) - flashrom_programmer_shutdown(data->flashprog); - g_free(data->guid); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->flashctx != NULL) + flashrom_flash_release(priv->flashctx); + if (priv->flashprog != NULL) + flashrom_programmer_shutdown(priv->flashprog); + g_free(priv->guid); } static int @@ -169,13 +169,13 @@ fu_plugin_flashrom_add_device(FuPlugin *plugin, GError **error) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *dmi_vendor; const gchar *product = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_NAME); const gchar *vendor = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_MANUFACTURER); const gchar *region_str = fu_ifd_region_to_string(region); g_autofree gchar *name = g_strdup_printf("%s (%s)", product, region_str); - g_autoptr(FuDevice) device = fu_flashrom_device_new(ctx, data->flashctx, region); + g_autoptr(FuDevice) device = fu_flashrom_device_new(ctx, priv->flashctx, region); fu_device_set_name(device, name); fu_device_set_vendor(device, vendor); @@ -218,7 +218,7 @@ static void fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device) { g_autoptr(FuDevice) me_device = NULL; - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *me_region_str = fu_ifd_region_to_string(FU_IFD_REGION_ME); /* we're only interested in a device from intel-spi plugin that corresponds to ME @@ -228,7 +228,7 @@ fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device) if (g_strcmp0(fu_device_get_logical_id(device), me_region_str) != 0) return; - me_device = fu_plugin_flashrom_add_device(plugin, data->guid, FU_IFD_REGION_ME, NULL); + me_device = fu_plugin_flashrom_add_device(plugin, priv->guid, FU_IFD_REGION_ME, NULL); if (me_device == NULL) return; @@ -240,9 +240,9 @@ fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device) static gboolean fu_plugin_flashrom_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FuDevice) device = - fu_plugin_flashrom_add_device(plugin, data->guid, FU_IFD_REGION_BIOS, error); + fu_plugin_flashrom_add_device(plugin, priv->guid, FU_IFD_REGION_BIOS, error); return (device != NULL); } @@ -270,7 +270,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro { gint rc; const gchar *guid; - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); /* progress */ fu_progress_set_id(progress, G_STRLOC); @@ -283,7 +283,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro return FALSE; fu_progress_step_done(progress); - data->guid = g_strdup(guid); + priv->guid = g_strdup(guid); if (flashrom_init(SELFCHECK_TRUE)) { g_set_error_literal(error, @@ -295,7 +295,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro flashrom_set_log_callback(fu_plugin_flashrom_debug_cb); fu_progress_step_done(progress); - if (flashrom_programmer_init(&data->flashprog, "internal", NULL)) { + if (flashrom_programmer_init(&priv->flashprog, "internal", NULL)) { g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, @@ -303,7 +303,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro return FALSE; } - rc = flashrom_flash_probe(&data->flashctx, data->flashprog, NULL); + rc = flashrom_flash_probe(&priv->flashctx, priv->flashprog, NULL); if (rc == 3) { g_set_error_literal(error, FWUPD_ERROR, diff --git a/plugins/gpio/fu-plugin-gpio.c b/plugins/gpio/fu-plugin-gpio.c index 398764a3e..b48306e36 100644 --- a/plugins/gpio/fu-plugin-gpio.c +++ b/plugins/gpio/fu-plugin-gpio.c @@ -23,8 +23,8 @@ fu_plugin_gpio_load(FuContext *ctx) static void fu_plugin_gpio_init(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); - data->current_logical_ids = g_ptr_array_new_with_free_func(g_free); + FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); + priv->current_logical_ids = g_ptr_array_new_with_free_func(g_free); fu_plugin_add_udev_subsystem(plugin, "gpio"); fu_plugin_add_device_gtype(plugin, FU_TYPE_GPIO_DEVICE); } @@ -32,8 +32,8 @@ fu_plugin_gpio_init(FuPlugin *plugin) static void fu_plugin_gpio_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - g_ptr_array_unref(data->current_logical_ids); + FuPluginData *priv = fu_plugin_get_data(plugin); + g_ptr_array_unref(priv->current_logical_ids); } static gboolean @@ -58,7 +58,7 @@ fu_plugin_gpio_parse_level(const gchar *str, gboolean *ret, GError **error) static gboolean fu_plugin_gpio_process_quirk(FuPlugin *self, const gchar *str, GError **error) { - FuPluginData *data = fu_plugin_get_data(self); + FuPluginData *priv = fu_plugin_get_data(self); gboolean value = FALSE; FuDevice *device_tmp; g_auto(GStrv) split = g_strsplit(str, ",", -1); @@ -93,7 +93,7 @@ fu_plugin_gpio_process_quirk(FuPlugin *self, const gchar *str, GError **error) } /* success */ - g_ptr_array_add(data->current_logical_ids, g_strdup(fu_device_get_logical_id(device_tmp))); + g_ptr_array_add(priv->current_logical_ids, g_strdup(fu_device_get_logical_id(device_tmp))); return TRUE; } @@ -126,13 +126,13 @@ fu_plugin_gpio_cleanup(FuPlugin *self, FwupdInstallFlags flags, GError **error) { - FuPluginData *data = fu_plugin_get_data(self); + FuPluginData *priv = fu_plugin_get_data(self); g_autoptr(GPtrArray) current_logical_ids = NULL; /* deep copy to local to clear transaction array */ current_logical_ids = - g_ptr_array_copy(data->current_logical_ids, (GCopyFunc)g_strdup, NULL); - g_ptr_array_set_size(data->current_logical_ids, 0); + g_ptr_array_copy(priv->current_logical_ids, (GCopyFunc)g_strdup, NULL); + g_ptr_array_set_size(priv->current_logical_ids, 0); /* close the fds we opened during ->prepare */ for (guint i = 0; i < current_logical_ids->len; i++) { diff --git a/plugins/iommu/fu-plugin-iommu.c b/plugins/iommu/fu-plugin-iommu.c index eaaab94ef..d85d186fb 100644 --- a/plugins/iommu/fu-plugin-iommu.c +++ b/plugins/iommu/fu-plugin-iommu.c @@ -37,7 +37,7 @@ fu_plugin_iommu_backend_device_added(FuPlugin *plugin, FuDevice *device, GError static void fu_plugin_iommu_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FwupdSecurityAttr) attr = NULL; /* create attr */ @@ -46,7 +46,7 @@ fu_plugin_iommu_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin)); fu_security_attrs_append(attrs, attr); - if (!data->has_iommu) { + if (!priv->has_iommu) { fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND); return; } diff --git a/plugins/linux-lockdown/fu-plugin-linux-lockdown.c b/plugins/linux-lockdown/fu-plugin-linux-lockdown.c index 9b1f0328b..ddbafe41c 100644 --- a/plugins/linux-lockdown/fu-plugin-linux-lockdown.c +++ b/plugins/linux-lockdown/fu-plugin-linux-lockdown.c @@ -31,12 +31,12 @@ fu_plugin_linux_lockdown_init(FuPlugin *plugin) static void fu_plugin_linux_lockdown_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->file != NULL) - g_object_unref(data->file); - if (data->monitor != NULL) { - g_file_monitor_cancel(data->monitor); - g_object_unref(data->monitor); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->file != NULL) + g_object_unref(priv->file); + if (priv->monitor != NULL) { + g_file_monitor_cancel(priv->monitor); + g_object_unref(priv->monitor); } } @@ -57,27 +57,27 @@ fu_plugin_linux_lockdown_to_string(FuPluginLinuxLockdown lockdown) static void fu_plugin_linux_lockdown_rescan(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); gsize bufsz = 0; g_autofree gchar *buf = NULL; /* load file */ - if (!g_file_load_contents(data->file, NULL, &buf, &bufsz, NULL, NULL)) { - data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INVALID; + if (!g_file_load_contents(priv->file, NULL, &buf, &bufsz, NULL, NULL)) { + priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INVALID; } else if (g_strstr_len(buf, bufsz, "[none]") != NULL) { - data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_NONE; + priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_NONE; } else if (g_strstr_len(buf, bufsz, "[integrity]") != NULL) { - data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INTEGRITY; + priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INTEGRITY; } else if (g_strstr_len(buf, bufsz, "[confidentiality]") != NULL) { - data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_CONFIDENTIALITY; + priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_CONFIDENTIALITY; } else { - data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN; + priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN; } /* update metadata */ fu_plugin_add_report_metadata(plugin, "LinuxLockdown", - fu_plugin_linux_lockdown_to_string(data->lockdown)); + fu_plugin_linux_lockdown_to_string(priv->lockdown)); } static void @@ -96,7 +96,7 @@ fu_plugin_linux_lockdown_changed_cb(GFileMonitor *monitor, static gboolean fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *path = NULL; g_autofree gchar *fn = NULL; @@ -109,11 +109,11 @@ fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError "Kernel doesn't offer lockdown support."); return FALSE; } - data->file = g_file_new_for_path(fn); - data->monitor = g_file_monitor(data->file, G_FILE_MONITOR_NONE, NULL, error); - if (data->monitor == NULL) + priv->file = g_file_new_for_path(fn); + priv->monitor = g_file_monitor(priv->file, G_FILE_MONITOR_NONE, NULL, error); + if (priv->monitor == NULL) return FALSE; - g_signal_connect(G_FILE_MONITOR(data->monitor), + g_signal_connect(G_FILE_MONITOR(priv->monitor), "changed", G_CALLBACK(fu_plugin_linux_lockdown_changed_cb), plugin); @@ -124,7 +124,7 @@ fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError static void fu_plugin_linux_lockdown_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FwupdSecurityAttr) attr = NULL; /* create attr */ @@ -133,17 +133,17 @@ fu_plugin_linux_lockdown_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *a fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE); fu_security_attrs_append(attrs, attr); - if (data->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN) { + if (priv->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN) { fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA); return; } /* load file */ - if (data->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_INVALID) { + if (priv->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_INVALID) { fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); return; } - if (data->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_NONE) { + if (priv->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_NONE) { fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED); return; } diff --git a/plugins/linux-swap/fu-plugin-linux-swap.c b/plugins/linux-swap/fu-plugin-linux-swap.c index 59f86d2a5..8e7fdcc6a 100644 --- a/plugins/linux-swap/fu-plugin-linux-swap.c +++ b/plugins/linux-swap/fu-plugin-linux-swap.c @@ -24,12 +24,12 @@ fu_plugin_linux_swap_init(FuPlugin *plugin) static void fu_plugin_linux_swap_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->file != NULL) - g_object_unref(data->file); - if (data->monitor != NULL) { - g_file_monitor_cancel(data->monitor); - g_object_unref(data->monitor); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->file != NULL) + g_object_unref(priv->file); + if (priv->monitor != NULL) { + g_file_monitor_cancel(priv->monitor); + g_object_unref(priv->monitor); } } @@ -48,7 +48,7 @@ fu_plugin_linux_swap_changed_cb(GFileMonitor *monitor, static gboolean fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *fn = NULL; g_autofree gchar *procfs = NULL; @@ -61,11 +61,11 @@ fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **er "Kernel doesn't offer swap support."); return FALSE; } - data->file = g_file_new_for_path(fn); - data->monitor = g_file_monitor(data->file, G_FILE_MONITOR_NONE, NULL, error); - if (data->monitor == NULL) + priv->file = g_file_new_for_path(fn); + priv->monitor = g_file_monitor(priv->file, G_FILE_MONITOR_NONE, NULL, error); + if (priv->monitor == NULL) return FALSE; - g_signal_connect(G_FILE_MONITOR(data->monitor), + g_signal_connect(G_FILE_MONITOR(priv->monitor), "changed", G_CALLBACK(fu_plugin_linux_swap_changed_cb), plugin); @@ -75,14 +75,14 @@ fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **er static void fu_plugin_linux_swap_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); gsize bufsz = 0; g_autofree gchar *buf = NULL; g_autoptr(FuLinuxSwap) swap = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(GError) error_local = NULL; - if (data->file == NULL) + if (priv->file == NULL) return; /* create attr */ @@ -92,15 +92,15 @@ fu_plugin_linux_swap_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs fu_security_attrs_append(attrs, attr); /* load list of swaps */ - if (!g_file_load_contents(data->file, NULL, &buf, &bufsz, NULL, &error_local)) { - g_autofree gchar *fn = g_file_get_path(data->file); + if (!g_file_load_contents(priv->file, NULL, &buf, &bufsz, NULL, &error_local)) { + g_autofree gchar *fn = g_file_get_path(priv->file); g_warning("could not open %s: %s", fn, error_local->message); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); return; } swap = fu_linux_swap_new(buf, bufsz, &error_local); if (swap == NULL) { - g_autofree gchar *fn = g_file_get_path(data->file); + g_autofree gchar *fn = g_file_get_path(priv->file); g_warning("could not parse %s: %s", fn, error_local->message); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); return; diff --git a/plugins/linux-tainted/fu-plugin-linux-tainted.c b/plugins/linux-tainted/fu-plugin-linux-tainted.c index 313b2263e..2199817c3 100644 --- a/plugins/linux-tainted/fu-plugin-linux-tainted.c +++ b/plugins/linux-tainted/fu-plugin-linux-tainted.c @@ -22,12 +22,12 @@ fu_plugin_linux_tainted_init(FuPlugin *plugin) static void fu_plugin_linux_tainted_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->file != NULL) - g_object_unref(data->file); - if (data->monitor != NULL) { - g_file_monitor_cancel(data->monitor); - g_object_unref(data->monitor); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->file != NULL) + g_object_unref(priv->file); + if (priv->monitor != NULL) { + g_file_monitor_cancel(priv->monitor); + g_object_unref(priv->monitor); } } @@ -46,17 +46,17 @@ fu_plugin_linux_tainted_changed_cb(GFileMonitor *monitor, static gboolean fu_plugin_linux_tainted_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *fn = NULL; g_autofree gchar *procfs = NULL; procfs = fu_path_from_kind(FU_PATH_KIND_PROCFS); fn = g_build_filename(procfs, "sys", "kernel", "tainted", NULL); - data->file = g_file_new_for_path(fn); - data->monitor = g_file_monitor(data->file, G_FILE_MONITOR_NONE, NULL, error); - if (data->monitor == NULL) + priv->file = g_file_new_for_path(fn); + priv->monitor = g_file_monitor(priv->file, G_FILE_MONITOR_NONE, NULL, error); + if (priv->monitor == NULL) return FALSE; - g_signal_connect(G_FILE_MONITOR(data->monitor), + g_signal_connect(G_FILE_MONITOR(priv->monitor), "changed", G_CALLBACK(fu_plugin_linux_tainted_changed_cb), plugin); @@ -66,7 +66,7 @@ fu_plugin_linux_tainted_startup(FuPlugin *plugin, FuProgress *progress, GError * static void fu_plugin_linux_tainted_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); gsize bufsz = 0; g_autofree gchar *buf = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL; @@ -79,8 +79,8 @@ fu_plugin_linux_tainted_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *at fu_security_attrs_append(attrs, attr); /* load file */ - if (!g_file_load_contents(data->file, NULL, &buf, &bufsz, NULL, &error_local)) { - g_autofree gchar *fn = g_file_get_path(data->file); + if (!g_file_load_contents(priv->file, NULL, &buf, &bufsz, NULL, &error_local)) { + g_autofree gchar *fn = g_file_get_path(priv->file); g_warning("could not open %s: %s", fn, error_local->message); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); return; diff --git a/plugins/logind/fu-plugin-logind.c b/plugins/logind/fu-plugin-logind.c index d123fe4d1..c8336a89a 100644 --- a/plugins/logind/fu-plugin-logind.c +++ b/plugins/logind/fu-plugin-logind.c @@ -25,20 +25,20 @@ fu_plugin_logind_init(FuPlugin *plugin) static void fu_plugin_logind_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->logind_fd != 0) - g_close(data->logind_fd, NULL); - if (data->logind_proxy != NULL) - g_object_unref(data->logind_proxy); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->logind_fd != 0) + g_close(priv->logind_fd, NULL); + if (priv->logind_proxy != NULL) + g_object_unref(priv->logind_proxy); } static gboolean fu_plugin_logind_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *name_owner = NULL; - data->logind_proxy = g_dbus_proxy_new_for_bus_sync( + priv->logind_proxy = g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, @@ -47,17 +47,17 @@ fu_plugin_logind_startup(FuPlugin *plugin, FuProgress *progress, GError **error) "org.freedesktop.login1.Manager", NULL, error); - if (data->logind_proxy == NULL) { + if (priv->logind_proxy == NULL) { g_prefix_error(error, "failed to connect to logind: "); return FALSE; } - name_owner = g_dbus_proxy_get_name_owner(data->logind_proxy); + name_owner = g_dbus_proxy_get_name_owner(priv->logind_proxy); if (name_owner == NULL) { g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "no owner for %s", - g_dbus_proxy_get_name(data->logind_proxy)); + g_dbus_proxy_get_name(priv->logind_proxy)); return FALSE; } return TRUE; @@ -70,7 +70,7 @@ fu_plugin_logind_prepare(FuPlugin *plugin, FwupdInstallFlags flags, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(GError) error_local = NULL; g_autoptr(GUnixFDList) out_fd_list = NULL; g_autoptr(GVariant) res = NULL; @@ -78,18 +78,18 @@ fu_plugin_logind_prepare(FuPlugin *plugin, "handle-hibernate-key:handle-lid-switch"; /* already inhibited */ - if (data->logind_fd != 0) + if (priv->logind_fd != 0) return TRUE; /* not yet connected */ - if (data->logind_proxy == NULL) { + if (priv->logind_proxy == NULL) { g_warning("no logind connection to use"); return TRUE; } /* block shutdown and idle */ res = g_dbus_proxy_call_with_unix_fd_list_sync( - data->logind_proxy, + priv->logind_proxy, "Inhibit", g_variant_new("(ssss)", what, PACKAGE_NAME, "Firmware Update in Progress", "block"), G_DBUS_CALL_FLAGS_NONE, @@ -108,8 +108,8 @@ fu_plugin_logind_prepare(FuPlugin *plugin, g_warning("invalid response from logind"); return TRUE; } - data->logind_fd = g_unix_fd_list_get(out_fd_list, 0, NULL); - g_debug("opened logind fd %i", data->logind_fd); + priv->logind_fd = g_unix_fd_list_get(out_fd_list, 0, NULL); + g_debug("opened logind fd %i", priv->logind_fd); return TRUE; } @@ -120,13 +120,13 @@ fu_plugin_logind_cleanup(FuPlugin *plugin, FwupdInstallFlags flags, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->logind_fd == 0) + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->logind_fd == 0) return TRUE; - g_debug("closed logind fd %i", data->logind_fd); - if (!g_close(data->logind_fd, error)) + g_debug("closed logind fd %i", priv->logind_fd); + if (!g_close(priv->logind_fd, error)) return FALSE; - data->logind_fd = 0; + priv->logind_fd = 0; return TRUE; } diff --git a/plugins/pci-mei/fu-plugin-pci-mei.c b/plugins/pci-mei/fu-plugin-pci-mei.c index 3b5ac2524..f4efeb543 100644 --- a/plugins/pci-mei/fu-plugin-pci-mei.c +++ b/plugins/pci-mei/fu-plugin-pci-mei.c @@ -58,9 +58,9 @@ fu_plugin_pci_mei_init(FuPlugin *plugin) static void fu_plugin_pci_mei_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->pci_device != NULL) - g_object_unref(data->pci_device); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->pci_device != NULL) + g_object_unref(priv->pci_device); } static FuMeiFamily diff --git a/plugins/powerd/fu-plugin-powerd.c b/plugins/powerd/fu-plugin-powerd.c index e6b63f1ec..92df52507 100644 --- a/plugins/powerd/fu-plugin-powerd.c +++ b/plugins/powerd/fu-plugin-powerd.c @@ -59,9 +59,9 @@ fu_plugin_powerd_delete_suspend_file(GError **error) static void fu_plugin_powerd_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->proxy != NULL) - g_object_unref(data->proxy); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->proxy != NULL) + g_object_unref(priv->proxy); } static void @@ -97,14 +97,14 @@ fu_plugin_powerd_proxy_changed_cb(GDBusProxy *proxy, static gboolean fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *name_owner = NULL; if (!fu_plugin_powerd_delete_suspend_file(error)) return FALSE; /* establish proxy for method call to powerd */ - data->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, + priv->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.chromium.PowerManager", @@ -113,22 +113,22 @@ fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error) NULL, error); - if (data->proxy == NULL) { + if (priv->proxy == NULL) { g_prefix_error(error, "failed to connect to powerd: "); return FALSE; } - name_owner = g_dbus_proxy_get_name_owner(data->proxy); + name_owner = g_dbus_proxy_get_name_owner(priv->proxy); if (name_owner == NULL) { g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "no service that owns the name for %s", - g_dbus_proxy_get_name(data->proxy)); + g_dbus_proxy_get_name(priv->proxy)); return FALSE; } fu_plugin_powerd_rescan(plugin, - g_dbus_proxy_call_sync(data->proxy, + g_dbus_proxy_call_sync(priv->proxy, "GetBatteryState", NULL, G_DBUS_CALL_FLAGS_NONE, @@ -136,7 +136,7 @@ fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error) NULL, G_SOURCE_REMOVE)); - g_signal_connect(G_DBUS_PROXY(data->proxy), + g_signal_connect(G_DBUS_PROXY(priv->proxy), "g-signal", G_CALLBACK(fu_plugin_powerd_proxy_changed_cb), plugin); diff --git a/plugins/redfish/fu-plugin-redfish.c b/plugins/redfish/fu-plugin-redfish.c index e1fff3889..c1db308a7 100644 --- a/plugins/redfish/fu-plugin-redfish.c +++ b/plugins/redfish/fu-plugin-redfish.c @@ -42,7 +42,7 @@ fu_common_generate_password(guint length) static gboolean fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *password_new = fu_common_generate_password(15); g_autofree gchar *uri = NULL; g_autoptr(FuRedfishRequest) request = NULL; @@ -57,7 +57,7 @@ fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error) } /* now use Redfish to change the temporary password to the actual password */ - request = fu_redfish_backend_request_new(data->backend); + request = fu_redfish_backend_request_new(priv->backend); json_builder_begin_object(builder); json_builder_set_member_name(builder, "Password"); json_builder_add_string_value(builder, password_new); @@ -69,7 +69,7 @@ fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error) FU_REDFISH_REQUEST_PERFORM_FLAG_LOAD_JSON, error)) return FALSE; - fu_redfish_backend_set_password(data->backend, password_new); + fu_redfish_backend_set_password(priv->backend, password_new); /* success */ return fu_plugin_set_secure_config_value(plugin, "Password", password_new, error); @@ -78,17 +78,17 @@ fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error) static gboolean fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(GPtrArray) devices = NULL; g_autoptr(GError) error_local = NULL; /* get the list of devices */ - if (!fu_backend_coldplug(FU_BACKEND(data->backend), progress, &error_local)) { + if (!fu_backend_coldplug(FU_BACKEND(priv->backend), progress, &error_local)) { /* did the user password expire? */ if (g_error_matches(error_local, FWUPD_ERROR, FWUPD_ERROR_AUTH_EXPIRED)) { if (!fu_plugin_redfish_change_expired(plugin, error)) return FALSE; - if (!fu_backend_coldplug(FU_BACKEND(data->backend), progress, error)) { + if (!fu_backend_coldplug(FU_BACKEND(priv->backend), progress, error)) { fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_AUTH_REQUIRED); return FALSE; } @@ -97,7 +97,7 @@ fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **erro return FALSE; } } - devices = fu_backend_get_devices(FU_BACKEND(data->backend)); + devices = fu_backend_get_devices(FU_BACKEND(priv->backend)); for (guint i = 0; i < devices->len; i++) { FuDevice *device = g_ptr_array_index(devices, i); if (fu_context_has_hwid_flag(fu_plugin_get_context(plugin), "reset-required")) @@ -116,7 +116,7 @@ fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **erro static gboolean fu_redfish_plugin_discover_uefi_credentials(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); gsize bufsz = 0; guint32 indications = 0x0; g_autofree gchar *userpass_safe = NULL; @@ -161,15 +161,15 @@ fu_redfish_plugin_discover_uefi_credentials(FuPlugin *plugin, GError **error) userpass_safe); return FALSE; } - fu_redfish_backend_set_username(data->backend, split[0]); - fu_redfish_backend_set_password(data->backend, split[1]); + fu_redfish_backend_set_username(priv->backend, split[0]); + fu_redfish_backend_set_password(priv->backend, split[1]); return TRUE; } static gboolean fu_redfish_plugin_discover_smbios_table(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); FuContext *ctx = fu_plugin_get_context(plugin); const gchar *smbios_data_fn; g_autoptr(FuRedfishSmbios) smbios = fu_redfish_smbios_new(); @@ -192,27 +192,27 @@ fu_redfish_plugin_discover_smbios_table(FuPlugin *plugin, GError **error) } /* success */ - g_set_object(&data->smbios, smbios); + g_set_object(&priv->smbios, smbios); return TRUE; } static gboolean fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *hostname = NULL; g_autoptr(FuRedfishNetworkDevice) device = NULL; /* we have no data */ - if (data->smbios == NULL) + if (priv->smbios == NULL) return TRUE; /* get IP, falling back to hostname, then MAC, then VID:PID */ - hostname = g_strdup(fu_redfish_smbios_get_ip_addr(data->smbios)); + hostname = g_strdup(fu_redfish_smbios_get_ip_addr(priv->smbios)); if (hostname == NULL) - hostname = g_strdup(fu_redfish_smbios_get_hostname(data->smbios)); + hostname = g_strdup(fu_redfish_smbios_get_hostname(priv->smbios)); if (device == NULL) { - const gchar *mac_addr = fu_redfish_smbios_get_mac_addr(data->smbios); + const gchar *mac_addr = fu_redfish_smbios_get_mac_addr(priv->smbios); if (mac_addr != NULL) { g_autoptr(GError) error_network = NULL; device = fu_redfish_network_device_for_mac_addr(mac_addr, &error_network); @@ -221,8 +221,8 @@ fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error) } } if (device == NULL) { - guint16 vid = fu_redfish_smbios_get_vid(data->smbios); - guint16 pid = fu_redfish_smbios_get_pid(data->smbios); + guint16 vid = fu_redfish_smbios_get_vid(priv->smbios); + guint16 pid = fu_redfish_smbios_get_pid(priv->smbios); if (vid != 0x0 && pid != 0x0) { g_autoptr(GError) error_network = NULL; device = fu_redfish_network_device_for_vid_pid(vid, pid, &error_network); @@ -255,8 +255,8 @@ fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error) g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE, "no hostname"); return FALSE; } - fu_redfish_backend_set_hostname(data->backend, hostname); - fu_redfish_backend_set_port(data->backend, fu_redfish_smbios_get_port(data->smbios)); + fu_redfish_backend_set_hostname(priv->backend, hostname); + fu_redfish_backend_set_port(priv->backend, fu_redfish_smbios_get_port(priv->smbios)); return TRUE; } @@ -265,7 +265,7 @@ fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error) static gboolean fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *username_fwupd = "fwupd"; guint8 user_id = G_MAXUINT8; g_autofree gchar *password_new = fu_common_generate_password(15); @@ -315,14 +315,14 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error) return FALSE; if (!fu_ipmi_device_set_user_password(device, user_id, password_tmp, error)) return FALSE; - fu_redfish_backend_set_username(data->backend, username_fwupd); - fu_redfish_backend_set_password(data->backend, password_tmp); + fu_redfish_backend_set_username(priv->backend, username_fwupd); + fu_redfish_backend_set_password(priv->backend, password_tmp); /* wait for Redfish to sync */ g_usleep(2 * G_USEC_PER_SEC); /* now use Redfish to change the temporary password to the actual password */ - request = fu_redfish_backend_request_new(data->backend); + request = fu_redfish_backend_request_new(priv->backend); uri = g_strdup_printf("/redfish/v1/AccountService/Accounts/%u", (guint)user_id - 1); json_builder_begin_object(builder); json_builder_set_member_name(builder, "Password"); @@ -335,7 +335,7 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error) FU_REDFISH_REQUEST_PERFORM_FLAG_LOAD_JSON, error)) return FALSE; - fu_redfish_backend_set_password(data->backend, password_new); + fu_redfish_backend_set_password(priv->backend, password_new); /* success */ if (!fu_plugin_set_secure_config_value(plugin, "UserUri", uri, error)) @@ -352,7 +352,7 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error) static gboolean fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *ca_check_str = NULL; g_autofree gchar *password = NULL; g_autofree gchar *redfish_uri = NULL; @@ -377,11 +377,11 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error guint64 port = 0; if (g_str_has_prefix(redfish_uri, "https://")) { - fu_redfish_backend_set_https(data->backend, TRUE); + fu_redfish_backend_set_https(priv->backend, TRUE); ip_str = redfish_uri + strlen("https://"); port = 443; } else if (g_str_has_prefix(redfish_uri, "http://")) { - fu_redfish_backend_set_https(data->backend, FALSE); + fu_redfish_backend_set_https(priv->backend, FALSE); ip_str = redfish_uri + strlen("http://"); port = 80; } else { @@ -393,7 +393,7 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error } split = g_strsplit(ip_str, ":", 2); - fu_redfish_backend_set_hostname(data->backend, split[0]); + fu_redfish_backend_set_hostname(priv->backend, split[0]); if (g_strv_length(split) > 1) port = g_ascii_strtoull(split[1], NULL, 10); if (port == 0 || port == G_MAXUINT64) { @@ -403,25 +403,25 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error "no valid port specified"); return FALSE; } - fu_redfish_backend_set_port(data->backend, port); + fu_redfish_backend_set_port(priv->backend, port); } username = fu_plugin_get_config_value(plugin, "Username"); if (username != NULL) - fu_redfish_backend_set_username(data->backend, username); + fu_redfish_backend_set_username(priv->backend, username); password = fu_plugin_get_config_value(plugin, "Password"); if (password != NULL) - fu_redfish_backend_set_password(data->backend, password); + fu_redfish_backend_set_password(priv->backend, password); ca_check_str = fu_plugin_get_config_value(plugin, "CACheck"); if (ca_check_str != NULL) { gboolean ca_check = fu_plugin_get_config_value_boolean(plugin, "CACheck"); - fu_redfish_backend_set_cacheck(data->backend, ca_check); + fu_redfish_backend_set_cacheck(priv->backend, ca_check); } if (fu_context_has_hwid_flag(fu_plugin_get_context(plugin), "wildcard-targets")) - fu_redfish_backend_set_wildcard_targets(data->backend, TRUE); + fu_redfish_backend_set_wildcard_targets(priv->backend, TRUE); #ifdef HAVE_LINUX_IPMI_H /* we got neither a type 42 entry or config value, lets try IPMI */ - if (fu_redfish_backend_get_username(data->backend) == NULL) { + if (fu_redfish_backend_get_username(priv->backend) == NULL) { if (!fu_plugin_get_config_value_boolean(plugin, "IpmiDisableCreateUser")) { g_debug("attempting to create user using IPMI"); if (!fu_redfish_plugin_ipmi_create_user(plugin, error)) @@ -430,20 +430,20 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error } #endif - return fu_backend_setup(FU_BACKEND(data->backend), progress, error); + return fu_backend_setup(FU_BACKEND(priv->backend), progress, error); } static gboolean fu_plugin_redfish_cleanup_setup_cb(FuDevice *device, gpointer user_data, GError **error) { FuPlugin *self = FU_PLUGIN(user_data); - FuPluginData *data = fu_plugin_get_data(self); + FuPluginData *priv = fu_plugin_get_data(self); FuProgress *progress = fu_progress_new(G_STRLOC); /* the network adaptor might not autoconnect when coming back */ if (!fu_redfish_plugin_autoconnect_network_device(self, error)) return FALSE; - return fu_backend_setup(FU_BACKEND(data->backend), progress, error); + return fu_backend_setup(FU_BACKEND(priv->backend), progress, error); } static gboolean @@ -463,10 +463,10 @@ fu_plugin_redfish_cleanup(FuPlugin *self, FwupdInstallFlags flags, GError **error) { - FuPluginData *data = fu_plugin_get_data(self); + FuPluginData *priv = fu_plugin_get_data(self); guint64 reset_timeout = 0; g_autofree gchar *restart_timeout_str = NULL; - g_autoptr(FuRedfishRequest) request = fu_redfish_backend_request_new(data->backend); + g_autoptr(FuRedfishRequest) request = fu_redfish_backend_request_new(priv->backend); g_autoptr(JsonBuilder) builder = json_builder_new(); g_autoptr(GPtrArray) devices = NULL; @@ -499,14 +499,14 @@ fu_plugin_redfish_cleanup(FuPlugin *self, fu_progress_step_done(progress); /* remove all the devices */ - devices = fu_backend_get_devices(FU_BACKEND(data->backend)); + devices = fu_backend_get_devices(FU_BACKEND(priv->backend)); for (guint i = 0; i < devices->len; i++) { FuDevice *device_tmp = g_ptr_array_index(devices, i); - fu_backend_device_removed(FU_BACKEND(data->backend), device_tmp); + fu_backend_device_removed(FU_BACKEND(priv->backend), device_tmp); } /* work around manager bugs... */ - fu_backend_invalidate(FU_BACKEND(data->backend)); + fu_backend_invalidate(FU_BACKEND(priv->backend)); if (fu_redfish_device_get_reset_pre_delay(FU_REDFISH_DEVICE(device)) > 0) { fu_progress_sleep(fu_progress_get_child(progress), fu_redfish_device_get_reset_pre_delay(FU_REDFISH_DEVICE(device))); @@ -569,18 +569,18 @@ static void fu_plugin_redfish_init(FuPlugin *plugin) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); - data->backend = fu_redfish_backend_new(ctx); + FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); + priv->backend = fu_redfish_backend_new(ctx); fu_plugin_add_firmware_gtype(plugin, NULL, FU_TYPE_REDFISH_SMBIOS); } static void fu_plugin_redfish_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->smbios != NULL) - g_object_unref(data->smbios); - g_object_unref(data->backend); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->smbios != NULL) + g_object_unref(priv->smbios); + g_object_unref(priv->backend); } void diff --git a/plugins/test/fu-plugin-test.c b/plugins/test/fu-plugin-test.c index 83b873d25..c653c96a1 100644 --- a/plugins/test/fu-plugin-test.c +++ b/plugins/test/fu-plugin-test.c @@ -24,14 +24,14 @@ fu_plugin_test_init(FuPlugin *plugin) static void fu_plugin_test_destroy(FuPlugin *plugin) { - // FuPluginData *data = fu_plugin_get_data (plugin); + // FuPluginData *priv = fu_plugin_get_data (plugin); g_debug("destroy"); } static gboolean fu_plugin_test_load_xml(FuPlugin *plugin, const gchar *xml, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(XbBuilder) builder = xb_builder_new(); g_autoptr(XbBuilderSource) source = xb_builder_source_new(); g_autoptr(XbNode) delay_decompress_ms = NULL; @@ -50,13 +50,13 @@ fu_plugin_test_load_xml(FuPlugin *plugin, const gchar *xml, GError **error) /* parse markup */ delay_decompress_ms = xb_silo_query_first(silo, "config/delay_decompress_ms", NULL); if (delay_decompress_ms != NULL) - data->delay_decompress_ms = xb_node_get_text_as_uint(delay_decompress_ms); + priv->delay_decompress_ms = xb_node_get_text_as_uint(delay_decompress_ms); delay_write_ms = xb_silo_query_first(silo, "config/delay_write_ms", NULL); if (delay_write_ms != NULL) - data->delay_write_ms = xb_node_get_text_as_uint(delay_write_ms); + priv->delay_write_ms = xb_node_get_text_as_uint(delay_write_ms); delay_verify_ms = xb_silo_query_first(silo, "config/delay_verify_ms", NULL); if (delay_verify_ms != NULL) - data->delay_verify_ms = xb_node_get_text_as_uint(delay_verify_ms); + priv->delay_verify_ms = xb_node_get_text_as_uint(delay_verify_ms); /* success */ return TRUE; @@ -211,7 +211,7 @@ fu_plugin_test_write_firmware(FuPlugin *plugin, FwupdInstallFlags flags, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *test = g_getenv("FWUPD_PLUGIN_TEST"); gboolean requires_activation = g_strcmp0(test, "requires-activation") == 0; gboolean requires_reboot = g_strcmp0(test, "requires-reboot") == 0; @@ -223,19 +223,19 @@ fu_plugin_test_write_firmware(FuPlugin *plugin, return FALSE; } fu_progress_set_status(progress, FWUPD_STATUS_DECOMPRESSING); - for (guint i = 0; i <= data->delay_decompress_ms; i++) { + for (guint i = 0; i <= priv->delay_decompress_ms; i++) { g_usleep(1000); - fu_progress_set_percentage_full(progress, i, data->delay_decompress_ms); + fu_progress_set_percentage_full(progress, i, priv->delay_decompress_ms); } fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_WRITE); - for (guint i = 0; i <= data->delay_write_ms; i++) { + for (guint i = 0; i <= priv->delay_write_ms; i++) { g_usleep(1000); - fu_progress_set_percentage_full(progress, i, data->delay_write_ms); + fu_progress_set_percentage_full(progress, i, priv->delay_write_ms); } fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_VERIFY); - for (guint i = 0; i <= data->delay_verify_ms; i++) { + for (guint i = 0; i <= priv->delay_verify_ms; i++) { g_usleep(1000); - fu_progress_set_percentage_full(progress, i, data->delay_verify_ms); + fu_progress_set_percentage_full(progress, i, priv->delay_verify_ms); } /* composite test, upgrade composite devices */ diff --git a/plugins/tpm/fu-plugin-tpm.c b/plugins/tpm/fu-plugin-tpm.c index e8b38ee42..299055cd3 100644 --- a/plugins/tpm/fu-plugin-tpm.c +++ b/plugins/tpm/fu-plugin-tpm.c @@ -30,44 +30,44 @@ fu_plugin_tpm_init(FuPlugin *plugin) static void fu_plugin_tpm_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->tpm_device != NULL) - g_object_unref(data->tpm_device); - if (data->bios_device != NULL) - g_object_unref(data->bios_device); - if (data->ev_items != NULL) - g_ptr_array_unref(data->ev_items); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->tpm_device != NULL) + g_object_unref(priv->tpm_device); + if (priv->bios_device != NULL) + g_object_unref(priv->bios_device); + if (priv->ev_items != NULL) + g_ptr_array_unref(priv->ev_items); } static void fu_plugin_tpm_set_bios_pcr0s(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(GPtrArray) pcr0s = NULL; - if (data->tpm_device == NULL) + if (priv->tpm_device == NULL) return; - if (data->bios_device == NULL) + if (priv->bios_device == NULL) return; /* add all the PCR0s */ - pcr0s = fu_tpm_device_get_checksums(data->tpm_device, 0); + pcr0s = fu_tpm_device_get_checksums(priv->tpm_device, 0); if (pcr0s->len == 0) return; for (guint i = 0; i < pcr0s->len; i++) { const gchar *checksum = g_ptr_array_index(pcr0s, i); - fu_device_add_checksum(data->bios_device, checksum); + fu_device_add_checksum(priv->bios_device, checksum); } - fu_device_add_flag(data->bios_device, FWUPD_DEVICE_FLAG_CAN_VERIFY); + fu_device_add_flag(priv->bios_device, FWUPD_DEVICE_FLAG_CAN_VERIFY); } /* set the PCR0 as the device checksum */ static void fu_plugin_tpm_device_registered(FuPlugin *plugin, FuDevice *device) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); if (fu_device_has_instance_id(device, "main-system-firmware")) { - g_set_object(&data->bios_device, device); + g_set_object(&priv->bios_device, device); fu_plugin_tpm_set_bios_pcr0s(plugin); } } @@ -75,10 +75,10 @@ fu_plugin_tpm_device_registered(FuPlugin *plugin, FuDevice *device) static void fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(GPtrArray) pcr0s = NULL; - g_set_object(&data->tpm_device, FU_TPM_DEVICE(dev)); + g_set_object(&priv->tpm_device, FU_TPM_DEVICE(dev)); fu_plugin_add_report_metadata(plugin, "TpmFamily", fu_tpm_device_get_family(FU_TPM_DEVICE(dev))); @@ -87,7 +87,7 @@ fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev) fu_plugin_tpm_set_bios_pcr0s(plugin); /* add extra plugin metadata */ - pcr0s = fu_tpm_device_get_checksums(data->tpm_device, 0); + pcr0s = fu_tpm_device_get_checksums(priv->tpm_device, 0); for (guint i = 0; i < pcr0s->len; i++) { const gchar *csum = g_ptr_array_index(pcr0s, i); GChecksumType csum_type = fwupd_checksum_guess_kind(csum); @@ -105,7 +105,7 @@ fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev) static void fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FwupdSecurityAttr) attr = NULL; /* create attr */ @@ -115,17 +115,17 @@ fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs fu_security_attrs_append(attrs, attr); /* check exists, and in v2.0 mode */ - if (data->tpm_device == NULL) { + if (priv->tpm_device == NULL) { fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND); return; } - if (g_strcmp0(fu_tpm_device_get_family(data->tpm_device), "2.0") != 0) { + if (g_strcmp0(fu_tpm_device_get_family(priv->tpm_device), "2.0") != 0) { fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED); return; } /* success */ - fwupd_security_attr_add_guids(attr, fu_device_get_guids(FU_DEVICE(data->tpm_device))); + fwupd_security_attr_add_guids(attr, fu_device_get_guids(FU_DEVICE(priv->tpm_device))); fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_FOUND); } @@ -133,7 +133,7 @@ fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs static void fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); gboolean reconstructed = TRUE; g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(GError) error = NULL; @@ -141,24 +141,24 @@ fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attr g_autoptr(GPtrArray) pcr0s_real = NULL; /* no TPM device */ - if (data->tpm_device == NULL) + if (priv->tpm_device == NULL) return; /* create attr */ attr = fwupd_security_attr_new(FWUPD_SECURITY_ATTR_ID_TPM_RECONSTRUCTION_PCR0); fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin)); fwupd_security_attr_set_level(attr, FWUPD_SECURITY_ATTR_LEVEL_IMPORTANT); - fwupd_security_attr_add_guids(attr, fu_device_get_guids(data->tpm_device)); + fwupd_security_attr_add_guids(attr, fu_device_get_guids(priv->tpm_device)); fu_security_attrs_append(attrs, attr); /* check reconstructed to PCR0 */ - if (data->ev_items == NULL || data->bios_device == NULL) { + if (priv->ev_items == NULL || priv->bios_device == NULL) { fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND); return; } /* calculate from the eventlog */ - pcr0s_calc = fu_tpm_eventlog_calc_checksums(data->ev_items, 0, &error); + pcr0s_calc = fu_tpm_eventlog_calc_checksums(priv->ev_items, 0, &error); if (pcr0s_calc == NULL) { g_warning("failed to get eventlog reconstruction: %s", error->message); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); @@ -166,7 +166,7 @@ fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attr } /* compare against the real PCR0s */ - pcr0s_real = fu_tpm_device_get_checksums(data->tpm_device, 0); + pcr0s_real = fu_tpm_device_get_checksums(priv->tpm_device, 0); for (guint i = 0; i < pcr0s_real->len; i++) { const gchar *checksum = g_ptr_array_index(pcr0s_real, i); reconstructed = FALSE; @@ -198,23 +198,23 @@ fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attr static void fu_plugin_tpm_add_security_attr_empty(FuPlugin *plugin, FuSecurityAttrs *attrs) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FwupdSecurityAttr) attr = NULL; /* no TPM device */ - if (data->tpm_device == NULL) + if (priv->tpm_device == NULL) return; /* add attributes */ attr = fwupd_security_attr_new(FWUPD_SECURITY_ATTR_ID_TPM_EMPTY_PCR); fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin)); fwupd_security_attr_set_level(attr, FWUPD_SECURITY_ATTR_LEVEL_CRITICAL); - fwupd_security_attr_add_guids(attr, fu_device_get_guids(data->tpm_device)); + fwupd_security_attr_add_guids(attr, fu_device_get_guids(priv->tpm_device)); fu_security_attrs_append(attrs, attr); /* check PCRs 0 through 7 for empty checksums */ for (guint pcr = 0; pcr <= 7; pcr++) { - g_autoptr(GPtrArray) checksums = fu_tpm_device_get_checksums(data->tpm_device, pcr); + g_autoptr(GPtrArray) checksums = fu_tpm_device_get_checksums(priv->tpm_device, pcr); for (guint i = 0; i < checksums->len; i++) { const gchar *checksum = g_ptr_array_index(checksums, i); gboolean empty = TRUE; @@ -253,12 +253,12 @@ fu_plugin_tpm_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) static gchar * fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); GString *str = g_string_new(""); g_autoptr(GPtrArray) pcrs = NULL; - for (guint i = 0; i < data->ev_items->len; i++) { - FuTpmEventlogItem *item = g_ptr_array_index(data->ev_items, i); + for (guint i = 0; i < priv->ev_items->len; i++) { + FuTpmEventlogItem *item = g_ptr_array_index(priv->ev_items, i); g_autofree gchar *blobstr = NULL; g_autofree gchar *checksum = NULL; @@ -276,7 +276,7 @@ fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin) g_string_append_printf(str, " [%s]", blobstr); g_string_append(str, "\n"); } - pcrs = fu_tpm_eventlog_calc_checksums(data->ev_items, 0, NULL); + pcrs = fu_tpm_eventlog_calc_checksums(priv->ev_items, 0, NULL); if (pcrs != NULL) { for (guint j = 0; j < pcrs->len; j++) { const gchar *csum = g_ptr_array_index(pcrs, j); @@ -291,7 +291,7 @@ fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin) static gboolean fu_plugin_tpm_coldplug_eventlog(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); gsize bufsz = 0; const gchar *fn = "/sys/kernel/security/tpm0/binary_bios_measurements"; g_autofree gchar *str = NULL; @@ -312,9 +312,9 @@ fu_plugin_tpm_coldplug_eventlog(FuPlugin *plugin, GError **error) fn); return FALSE; } - data->ev_items = + priv->ev_items = fu_tpm_eventlog_parser_new(buf, bufsz, FU_TPM_EVENTLOG_PARSER_FLAG_NONE, error); - if (data->ev_items == NULL) + if (priv->ev_items == NULL) return FALSE; /* add optional report metadata */ @@ -339,7 +339,7 @@ fu_plugin_tpm_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) static gboolean fu_plugin_tpm_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *sysfstpmdir = NULL; g_autofree gchar *fn_pcrs = NULL; @@ -347,12 +347,12 @@ fu_plugin_tpm_startup(FuPlugin *plugin, FuProgress *progress, GError **error) sysfstpmdir = fu_path_from_kind(FU_PATH_KIND_SYSFSDIR_TPM); fn_pcrs = g_build_filename(sysfstpmdir, "tpm0", "pcrs", NULL); if (g_file_test(fn_pcrs, G_FILE_TEST_EXISTS) && g_getenv("FWUPD_FORCE_TPM2") == NULL) { - data->tpm_device = fu_tpm_v1_device_new(fu_plugin_get_context(plugin)); - g_object_set(data->tpm_device, "device-file", fn_pcrs, NULL); - fu_device_set_physical_id(FU_DEVICE(data->tpm_device), "tpm"); - if (!fu_device_probe(FU_DEVICE(data->tpm_device), error)) + priv->tpm_device = fu_tpm_v1_device_new(fu_plugin_get_context(plugin)); + g_object_set(priv->tpm_device, "device-file", fn_pcrs, NULL); + fu_device_set_physical_id(FU_DEVICE(priv->tpm_device), "tpm"); + if (!fu_device_probe(FU_DEVICE(priv->tpm_device), error)) return FALSE; - fu_plugin_device_add(plugin, FU_DEVICE(data->tpm_device)); + fu_plugin_device_add(plugin, FU_DEVICE(priv->tpm_device)); } /* success */ diff --git a/plugins/uefi-capsule/fu-plugin-uefi-capsule.c b/plugins/uefi-capsule/fu-plugin-uefi-capsule.c index 01f7011ce..fc9856f5e 100644 --- a/plugins/uefi-capsule/fu-plugin-uefi-capsule.c +++ b/plugins/uefi-capsule/fu-plugin-uefi-capsule.c @@ -30,7 +30,7 @@ struct FuPluginData { static gboolean fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); FuContext *ctx = fu_plugin_get_context(plugin); const guint8 needle[] = "f\0w\0u\0p\0d\0-\0e\0f\0i\0 \0v\0e\0r\0s\0i\0o\0n\0 "; gsize bufsz = 0; @@ -40,10 +40,10 @@ fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error) g_autofree gchar *version = NULL; /* find the UTF-16 version string */ - if (!g_file_load_contents(data->fwupd_efi_file, NULL, &buf, &bufsz, NULL, error)) + if (!g_file_load_contents(priv->fwupd_efi_file, NULL, &buf, &bufsz, NULL, error)) return FALSE; if (!fu_memmem_safe((const guint8 *)buf, bufsz, needle, sizeof(needle), &offset, error)) { - g_autofree gchar *fn = g_file_get_path(data->fwupd_efi_file); + g_autofree gchar *fn = g_file_get_path(priv->fwupd_efi_file); g_prefix_error(error, "searching %s: ", fn); return FALSE; } @@ -62,7 +62,7 @@ fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error) /* convert to UTF-8 */ version = g_utf16_to_utf8(version_tmp, -1, NULL, NULL, error); if (version == NULL) { - g_autofree gchar *fn = g_file_get_path(data->fwupd_efi_file); + g_autofree gchar *fn = g_file_get_path(priv->fwupd_efi_file); g_prefix_error(error, "converting %s: ", fn); return FALSE; } @@ -93,7 +93,7 @@ fu_plugin_uefi_capsule_fwupd_efi_changed_cb(GFileMonitor *monitor, static gboolean fu_plugin_uefi_capsule_fwupd_efi_probe(FuPlugin *plugin, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); FuContext *ctx = fu_plugin_get_context(plugin); g_autofree gchar *fn = NULL; @@ -101,12 +101,12 @@ fu_plugin_uefi_capsule_fwupd_efi_probe(FuPlugin *plugin, GError **error) fn = fu_uefi_get_built_app_path(error); if (fn == NULL) return FALSE; - data->fwupd_efi_file = g_file_new_for_path(fn); - data->fwupd_efi_monitor = - g_file_monitor_file(data->fwupd_efi_file, G_FILE_MONITOR_NONE, NULL, error); - if (data->fwupd_efi_monitor == NULL) + priv->fwupd_efi_file = g_file_new_for_path(fn); + priv->fwupd_efi_monitor = + g_file_monitor_file(priv->fwupd_efi_file, G_FILE_MONITOR_NONE, NULL, error); + if (priv->fwupd_efi_monitor == NULL) return FALSE; - g_signal_connect(G_FILE_MONITOR(data->fwupd_efi_monitor), + g_signal_connect(G_FILE_MONITOR(priv->fwupd_efi_monitor), "changed", G_CALLBACK(fu_plugin_uefi_capsule_fwupd_efi_changed_cb), plugin); @@ -121,11 +121,11 @@ static void fu_plugin_uefi_capsule_init(FuPlugin *plugin) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); + FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); g_autoptr(GError) error_local = NULL; - data->backend = fu_uefi_backend_new(ctx); - data->bgrt = fu_uefi_bgrt_new(); + priv->backend = fu_uefi_backend_new(ctx); + priv->bgrt = fu_uefi_bgrt_new(); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower"); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "tpm"); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "dell"); @@ -141,17 +141,17 @@ fu_plugin_uefi_capsule_init(FuPlugin *plugin) static void fu_plugin_uefi_capsule_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->esp != NULL) - g_object_unref(data->esp); - if (data->fwupd_efi_file != NULL) - g_object_unref(data->fwupd_efi_file); - if (data->fwupd_efi_monitor != NULL) { - g_file_monitor_cancel(data->fwupd_efi_monitor); - g_object_unref(data->fwupd_efi_monitor); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->esp != NULL) + g_object_unref(priv->esp); + if (priv->fwupd_efi_file != NULL) + g_object_unref(priv->fwupd_efi_file); + if (priv->fwupd_efi_monitor != NULL) { + g_file_monitor_cancel(priv->fwupd_efi_monitor); + g_object_unref(priv->fwupd_efi_monitor); } - g_object_unref(data->backend); - g_object_unref(data->bgrt); + g_object_unref(priv->backend); + g_object_unref(priv->bgrt); } static gboolean @@ -240,7 +240,7 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin, GBytes *blob, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); guint32 screen_x, screen_y; gsize buf_size = g_bytes_get_size(blob); gssize size; @@ -272,7 +272,7 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin, } /* save to a predicatable filename */ - esp_path = fu_volume_get_mount_point(data->esp); + esp_path = fu_volume_get_mount_point(priv->esp); directory = fu_uefi_get_esp_path_for_os(device, esp_path); basename = g_strdup_printf("fwupd-%s.cap", FU_EFIVAR_GUID_UX_CAPSULE); fn = g_build_filename(directory, "fw", basename, NULL); @@ -296,11 +296,11 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin, header.image_type = 0; header.reserved = 0; header.x_offset = (screen_x / 2) - (width / 2); - if (screen_y == fu_uefi_bgrt_get_height(data->bgrt)) { + if (screen_y == fu_uefi_bgrt_get_height(priv->bgrt)) { header.y_offset = (gdouble)screen_y * 0.8f; } else { header.y_offset = - fu_uefi_bgrt_get_yoffset(data->bgrt) + fu_uefi_bgrt_get_height(data->bgrt); + fu_uefi_bgrt_get_yoffset(priv->bgrt) + fu_uefi_bgrt_get_height(priv->bgrt); }; /* header, payload and image has to add to zero */ @@ -335,7 +335,7 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin, static gboolean fu_plugin_uefi_capsule_update_splash(FuPlugin *plugin, FuDevice *device, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); guint best_idx = G_MAXUINT; guint32 lowest_border_pixels = G_MAXUINT; guint32 screen_height = 768; @@ -362,7 +362,7 @@ fu_plugin_uefi_capsule_update_splash(FuPlugin *plugin, FuDevice *device, GError } /* get the boot graphics resource table data */ - if (!fu_uefi_bgrt_get_supported(data->bgrt)) { + if (!fu_uefi_bgrt_get_supported(priv->bgrt)) { g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, @@ -489,19 +489,19 @@ fu_plugin_uefi_capsule_load_config(FuPlugin *plugin, FuDevice *device) static void fu_plugin_uefi_capsule_register_proxy_device(FuPlugin *plugin, FuDevice *device) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FuUefiDevice) dev = NULL; g_autoptr(GError) error_local = NULL; /* load all configuration variables */ - dev = fu_uefi_backend_device_new_from_dev(FU_UEFI_BACKEND(data->backend), device); + dev = fu_uefi_backend_device_new_from_dev(FU_UEFI_BACKEND(priv->backend), device); fu_plugin_uefi_capsule_load_config(plugin, FU_DEVICE(dev)); - if (data->esp == NULL) - data->esp = fu_volume_new_esp_default(&error_local); - if (data->esp == NULL) { + if (priv->esp == NULL) + priv->esp = fu_volume_new_esp_default(&error_local); + if (priv->esp == NULL) { fu_device_inhibit(device, "no-esp", error_local->message); } else { - fu_uefi_device_set_esp(dev, data->esp); + fu_uefi_device_set_esp(dev, priv->esp); fu_device_uninhibit(device, "no-esp"); } fu_plugin_device_add(plugin, FU_DEVICE(dev)); @@ -621,7 +621,7 @@ static gboolean fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); guint64 nvram_total; g_autofree gchar *esp_path = NULL; g_autofree gchar *nvram_total_str = NULL; @@ -641,12 +641,12 @@ fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError ** /* use GRUB to load updates */ if (fu_plugin_get_config_value_boolean(plugin, "EnableGrubChainLoad")) { - fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(data->backend), + fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(priv->backend), FU_TYPE_UEFI_GRUB_DEVICE); } /* check we can use this backend */ - if (!fu_backend_setup(data->backend, progress, &error_local)) { + if (!fu_backend_setup(priv->backend, progress, &error_local)) { if (g_error_matches(error_local, FWUPD_ERROR, FWUPD_ERROR_WRITE)) { fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_EFIVAR_NOT_MOUNTED); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE); @@ -668,8 +668,8 @@ fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError ** /* override the default ESP path */ esp_path = fu_plugin_get_config_value(plugin, "OverrideESPMountPoint"); if (esp_path != NULL) { - data->esp = fu_volume_new_esp_for_path(esp_path, error); - if (data->esp == NULL) { + priv->esp = fu_volume_new_esp_for_path(esp_path, error); + if (priv->esp == NULL) { g_prefix_error(error, "invalid OverrideESPMountPoint=%s " "specified in config: ", @@ -812,7 +812,7 @@ fu_plugin_uefi_capsule_check_cod_support(GError **error) static gboolean fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); const gchar *str; gboolean has_fde = FALSE; g_autoptr(GError) error_udisks2 = NULL; @@ -829,9 +829,9 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError * fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 26, "add-devices"); fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "setup-bgrt"); - if (data->esp == NULL) { - data->esp = fu_volume_new_esp_default(&error_udisks2); - if (data->esp == NULL) { + if (priv->esp == NULL) { + priv->esp = fu_volume_new_esp_default(&error_udisks2); + if (priv->esp == NULL) { fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_ESP_NOT_FOUND); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_USER_WARNING); @@ -846,7 +846,7 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError * if (!fu_plugin_uefi_capsule_check_cod_support(&error_cod)) { g_debug("not using CapsuleOnDisk support: %s", error_cod->message); } else { - fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(data->backend), + fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(priv->backend), FU_TYPE_UEFI_COD_DEVICE); } } @@ -860,16 +860,16 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError * fu_progress_step_done(progress); /* add each device */ - if (!fu_backend_coldplug(data->backend, fu_progress_get_child(progress), error)) + if (!fu_backend_coldplug(priv->backend, fu_progress_get_child(progress), error)) return FALSE; fu_progress_step_done(progress); - devices = fu_backend_get_devices(data->backend); + devices = fu_backend_get_devices(priv->backend); for (guint i = 0; i < devices->len; i++) { FuUefiDevice *dev = g_ptr_array_index(devices, i); g_autoptr(GError) error_device = NULL; - if (data->esp != NULL) - fu_uefi_device_set_esp(dev, data->esp); + if (priv->esp != NULL) + fu_uefi_device_set_esp(dev, priv->esp); if (!fu_plugin_uefi_capsule_coldplug_device(plugin, dev, &error_device)) { if (g_error_matches(error_device, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) { g_warning("skipping device that failed coldplug: %s", @@ -901,9 +901,9 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError * /* for debugging problems later */ fu_plugin_uefi_capsule_test_secure_boot(plugin); - if (!fu_uefi_bgrt_setup(data->bgrt, &error_local)) + if (!fu_uefi_bgrt_setup(priv->bgrt, &error_local)) g_debug("BGRT setup failed: %s", error_local->message); - str = fu_uefi_bgrt_get_supported(data->bgrt) ? "Enabled" : "Disabled"; + str = fu_uefi_bgrt_get_supported(priv->bgrt) ? "Enabled" : "Disabled"; g_debug("UX Capsule support : %s", str); fu_plugin_add_report_metadata(plugin, "UEFIUXCapsule", str); fu_progress_step_done(progress); diff --git a/plugins/upower/fu-plugin-upower.c b/plugins/upower/fu-plugin-upower.c index 997163be7..6a57d8d14 100644 --- a/plugins/upower/fu-plugin-upower.c +++ b/plugins/upower/fu-plugin-upower.c @@ -33,30 +33,30 @@ fu_plugin_upower_init(FuPlugin *plugin) static void fu_plugin_upower_destroy(FuPlugin *plugin) { - FuPluginData *data = fu_plugin_get_data(plugin); - if (data->proxy != NULL) - g_object_unref(data->proxy); - if (data->proxy_manager != NULL) - g_object_unref(data->proxy_manager); + FuPluginData *priv = fu_plugin_get_data(plugin); + if (priv->proxy != NULL) + g_object_unref(priv->proxy); + if (priv->proxy_manager != NULL) + g_object_unref(priv->proxy_manager); } static void fu_plugin_upower_rescan_devices(FuPlugin *plugin) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(GVariant) percentage_val = NULL; g_autoptr(GVariant) type_val = NULL; g_autoptr(GVariant) state_val = NULL; /* check that we "have" a battery */ - type_val = g_dbus_proxy_get_cached_property(data->proxy, "Type"); + type_val = g_dbus_proxy_get_cached_property(priv->proxy, "Type"); if (type_val == NULL || g_variant_get_uint32(type_val) == 0) { fu_context_set_battery_state(ctx, FU_BATTERY_STATE_UNKNOWN); fu_context_set_battery_level(ctx, FWUPD_BATTERY_LEVEL_INVALID); return; } - state_val = g_dbus_proxy_get_cached_property(data->proxy, "State"); + state_val = g_dbus_proxy_get_cached_property(priv->proxy, "State"); if (state_val == NULL || g_variant_get_uint32(state_val) == 0) { g_warning("failed to query power state"); fu_context_set_battery_state(ctx, FU_BATTERY_STATE_UNKNOWN); @@ -86,7 +86,7 @@ fu_plugin_upower_rescan_devices(FuPlugin *plugin) } /* get percentage */ - percentage_val = g_dbus_proxy_get_cached_property(data->proxy, "Percentage"); + percentage_val = g_dbus_proxy_get_cached_property(priv->proxy, "Percentage"); if (percentage_val == NULL) { g_warning("failed to query power percentage level"); fu_context_set_battery_level(ctx, FWUPD_BATTERY_LEVEL_INVALID); @@ -99,13 +99,13 @@ static void fu_plugin_upower_rescan_manager(FuPlugin *plugin) { FuContext *ctx = fu_plugin_get_context(plugin); - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(GVariant) lid_is_closed = NULL; g_autoptr(GVariant) lid_is_present = NULL; /* check that we "have" a lid */ - lid_is_present = g_dbus_proxy_get_cached_property(data->proxy_manager, "LidIsPresent"); - lid_is_closed = g_dbus_proxy_get_cached_property(data->proxy_manager, "LidIsClosed"); + lid_is_present = g_dbus_proxy_get_cached_property(priv->proxy_manager, "LidIsPresent"); + lid_is_closed = g_dbus_proxy_get_cached_property(priv->proxy_manager, "LidIsClosed"); if (lid_is_present == NULL || lid_is_closed == NULL) { g_warning("failed to query lid state"); fu_context_set_lid_state(ctx, FU_LID_STATE_UNKNOWN); @@ -135,10 +135,10 @@ fu_plugin_upower_proxy_changed_cb(GDBusProxy *proxy, static gboolean fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error) { - FuPluginData *data = fu_plugin_get_data(plugin); + FuPluginData *priv = fu_plugin_get_data(plugin); g_autofree gchar *name_owner = NULL; - data->proxy_manager = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, + priv->proxy_manager = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.UPower", @@ -146,11 +146,11 @@ fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error) "org.freedesktop.UPower", NULL, error); - if (data->proxy_manager == NULL) { + if (priv->proxy_manager == NULL) { g_prefix_error(error, "failed to connect to upower: "); return FALSE; } - data->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, + priv->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.UPower", @@ -158,24 +158,24 @@ fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error) "org.freedesktop.UPower.Device", NULL, error); - if (data->proxy == NULL) { + if (priv->proxy == NULL) { g_prefix_error(error, "failed to connect to upower: "); return FALSE; } - name_owner = g_dbus_proxy_get_name_owner(data->proxy); + name_owner = g_dbus_proxy_get_name_owner(priv->proxy); if (name_owner == NULL) { g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "no owner for %s", - g_dbus_proxy_get_name(data->proxy)); + g_dbus_proxy_get_name(priv->proxy)); return FALSE; } - g_signal_connect(G_DBUS_PROXY(data->proxy), + g_signal_connect(G_DBUS_PROXY(priv->proxy), "g-properties-changed", G_CALLBACK(fu_plugin_upower_proxy_changed_cb), plugin); - g_signal_connect(G_DBUS_PROXY(data->proxy_manager), + g_signal_connect(G_DBUS_PROXY(priv->proxy_manager), "g-properties-changed", G_CALLBACK(fu_plugin_upower_proxy_changed_cb), plugin);