diff --git a/configure.ac b/configure.ac index bcbf91975..a88b141a8 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,7 @@ AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-xz tar-ustar foreign]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_LIBTOOL +AC_PROG_CC_STDC m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [GOBJECT_INTROSPECTION_CHECK([0.9.8])]) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = xyes) diff --git a/src/fu-main.c b/src/fu-main.c index b13e9f644..0576c4f78 100644 --- a/src/fu-main.c +++ b/src/fu-main.c @@ -205,7 +205,6 @@ static GVariant * fu_main_device_array_to_variant (GPtrArray *devices, GError **error) { GVariantBuilder builder; - guint i; /* no devices */ if (devices->len == 0) { @@ -217,7 +216,7 @@ fu_main_device_array_to_variant (GPtrArray *devices, GError **error) } g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); - for (i = 0; i < devices->len; i++) { + for (guint i = 0; i < devices->len; i++) { GVariant *tmp; FuDeviceItem *item; item = g_ptr_array_index (devices, i); @@ -232,7 +231,6 @@ fu_main_load_plugins (GHashTable *plugins, GError **error) { FuPlugin *plugin; GModule *module; - GList *l; const gchar *fn; g_autofree gchar *plugin_dir = NULL; g_autoptr(GDir) dir = NULL; @@ -272,7 +270,7 @@ fu_main_load_plugins (GHashTable *plugins, GError **error) /* start them all up */ values = g_hash_table_get_values (plugins); - for (l = values; l != NULL; l = l->next) { + for (GList *l = values; l != NULL; l = l->next) { plugin = FU_PLUGIN (l->data); if (!fu_plugin_run_startup (plugin, error)) return FALSE; @@ -304,11 +302,8 @@ fu_main_item_free (FuDeviceItem *item) static FuDeviceItem * fu_main_get_item_by_id (FuMainPrivate *priv, const gchar *id) { - FuDeviceItem *item; - guint i; - - for (i = 0; i < priv->devices->len; i++) { - item = g_ptr_array_index (priv->devices, i); + for (guint i = 0; i < priv->devices->len; i++) { + FuDeviceItem *item = g_ptr_array_index (priv->devices, i); if (g_strcmp0 (fu_device_get_id (item->device), id) == 0) return item; if (g_strcmp0 (fu_device_get_equivalent_id (item->device), id) == 0) @@ -320,11 +315,8 @@ fu_main_get_item_by_id (FuMainPrivate *priv, const gchar *id) static FuDeviceItem * fu_main_get_item_by_guid (FuMainPrivate *priv, const gchar *guid) { - FuDeviceItem *item; - guint i; - - for (i = 0; i < priv->devices->len; i++) { - item = g_ptr_array_index (priv->devices, i); + for (guint i = 0; i < priv->devices->len; i++) { + FuDeviceItem *item = g_ptr_array_index (priv->devices, i); if (fu_device_has_guid (item->device, guid)) return item; } @@ -334,11 +326,8 @@ fu_main_get_item_by_guid (FuMainPrivate *priv, const gchar *guid) static FuProvider * fu_main_get_provider_by_name (FuMainPrivate *priv, const gchar *name) { - FuProvider *provider; - guint i; - - for (i = 0; i < priv->providers->len; i++) { - provider = g_ptr_array_index (priv->providers, i); + for (guint i = 0; i < priv->providers->len; i++) { + FuProvider *provider = g_ptr_array_index (priv->providers, i); if (g_strcmp0 (fu_provider_get_name (provider), name) == 0) return provider; } @@ -469,10 +458,8 @@ fu_main_on_battery (FuMainPrivate *priv) static gboolean fu_main_provider_unlock_authenticated (FuMainAuthHelper *helper, GError **error) { - guint i; - /* check the devices still exists */ - for (i = 0; i < helper->devices->len; i ++) { + for (guint i = 0; i < helper->devices->len; i ++) { FuDeviceItem *item; FuDevice *device = g_ptr_array_index (helper->devices, i); @@ -508,10 +495,9 @@ fu_main_provider_update_authenticated (FuMainAuthHelper *helper, GError **error) { FuDeviceItem *item; FuPlugin *plugin; - guint i; /* check the devices still exists */ - for (i = 0; i < helper->devices->len; i ++) { + for (guint i = 0; i < helper->devices->len; i ++) { FuDevice *device = g_ptr_array_index (helper->devices, i); item = fu_main_get_item_by_id (helper->priv, fu_device_get_id (device)); @@ -549,7 +535,7 @@ fu_main_provider_update_authenticated (FuMainAuthHelper *helper, GError **error) } /* run the correct providers for each device */ - for (i = 0; i < helper->devices->len; i ++) { + for (guint i = 0; i < helper->devices->len; i ++) { FuDevice *device = g_ptr_array_index (helper->devices, i); GBytes *blob_fw = g_ptr_array_index (helper->blob_fws, i); item = fu_main_get_item_by_id (helper->priv, @@ -630,20 +616,17 @@ fu_main_check_authorization_cb (GObject *source, GAsyncResult *res, gpointer use static gchar * fu_main_get_guids_from_store (AsStore *store) { - AsApp *app; AsProvide *prov; GPtrArray *provides; GPtrArray *apps; GString *str = g_string_new (""); - guint i; - guint j; /* return a string with all the firmware apps in the store */ apps = as_store_get_apps (store); - for (i = 0; i < apps->len; i++) { - app = AS_APP (g_ptr_array_index (apps, i)); + for (guint i = 0; i < apps->len; i++) { + AsApp *app = AS_APP (g_ptr_array_index (apps, i)); provides = as_app_get_provides (app); - for (j = 0; j < provides->len; j++) { + for (guint j = 0; j < provides->len; j++) { prov = AS_PROVIDE (g_ptr_array_index (provides, j)); if (as_provide_get_kind (prov) != AS_PROVIDE_KIND_FIRMWARE_FLASHED) continue; @@ -661,19 +644,19 @@ fu_main_vendor_quirk_release_version (AsApp *app) { AsVersionParseFlag flags = AS_VERSION_PARSE_FLAG_USE_TRIPLET; GPtrArray *releases; - guint i; /* no quirk required */ if (as_app_get_kind (app) != AS_APP_KIND_FIRMWARE) return; - for (i = 0; quirk_table[i].identifier != NULL; i++) + for (guint i = 0; quirk_table[i].identifier != NULL; i++) { if (g_str_has_prefix (as_app_get_id(app), quirk_table[i].identifier)) flags = quirk_table[i].flags; + } /* fix each release */ releases = as_app_get_releases (app); - for (i = 0; i < releases->len; i++) { + for (guint i = 0; i < releases->len; i++) { AsRelease *rel; const gchar *version; guint64 ver_uint32; @@ -704,11 +687,8 @@ fu_main_vendor_quirk_release_version (AsApp *app) static AsApp * fu_main_store_get_app_by_guids (AsStore *store, FuDevice *device) { - GPtrArray *guids; - guint i; - - guids = fu_device_get_guids (device); - for (i = 0; i < guids->len; i++) { + GPtrArray *guids = fu_device_get_guids (device); + for (guint i = 0; i < guids->len; i++) { AsApp *app = NULL; app = as_store_get_app_by_provide (store, AS_PROVIDE_KIND_FIRMWARE_FLASHED, @@ -849,7 +829,6 @@ fu_main_update_helper_for_device (FuMainAuthHelper *helper, static gboolean fu_main_update_helper (FuMainAuthHelper *helper, GError **error) { - guint i; g_autoptr(GError) error_first = NULL; /* load store file which also decompresses firmware */ @@ -859,7 +838,7 @@ fu_main_update_helper (FuMainAuthHelper *helper, GError **error) /* we've specified a specific device; failure is critical */ if (helper->devices->len > 0) { - for (i = 0; i < helper->devices->len; i ++) { + for (guint i = 0; i < helper->devices->len; i ++) { FuDevice *device = g_ptr_array_index (helper->devices, i); if (!fu_main_update_helper_for_device (helper, device, error)) return FALSE; @@ -869,7 +848,7 @@ fu_main_update_helper (FuMainAuthHelper *helper, GError **error) /* if we've not chosen a device, try and find anything in the * cabinet 'store' that matches any installed device and is updatable */ - for (i = 0; i < helper->priv->devices->len; i++) { + for (guint i = 0; i < helper->priv->devices->len; i++) { AsApp *app; FuDeviceItem *item; g_autoptr(GError) error_local = NULL; @@ -963,7 +942,6 @@ fu_main_get_item_by_id_fallback_pending (FuMainPrivate *priv, const gchar *id, G FuDeviceItem *item = NULL; FwupdUpdateState update_state; const gchar *tmp; - guint i; g_autoptr(GPtrArray) devices = NULL; /* not a wildcard */ @@ -982,7 +960,7 @@ fu_main_get_item_by_id_fallback_pending (FuMainPrivate *priv, const gchar *id, G devices = fu_pending_get_devices (priv->pending, error); if (devices == NULL) return NULL; - for (i = 0; i < devices->len; i++) { + for (guint i = 0; i < devices->len; i++) { dev = g_ptr_array_index (devices, i); update_state = fu_device_get_update_state (dev); if (update_state == FWUPD_UPDATE_STATE_UNKNOWN) @@ -1027,13 +1005,12 @@ fu_main_get_action_id_for_device (FuMainAuthHelper *helper) { gboolean all_removable = TRUE; gboolean is_trusted; - guint i; /* only test the payload */ is_trusted = (helper->trust_flags & FWUPD_TRUST_FLAG_PAYLOAD) > 0; /* any non-removable means false */ - for (i = 0; i < helper->devices->len; i ++) { + for (guint i = 0; i < helper->devices->len; i ++) { FuDevice *device = g_ptr_array_index (helper->devices, i); if (fu_device_has_flag (device, FU_DEVICE_FLAG_INTERNAL)) { all_removable = FALSE; @@ -1062,7 +1039,6 @@ static gboolean fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GError **error) { const guint8 *data; - guint i; gsize size; GPtrArray *apps; g_autofree gchar *xml = NULL; @@ -1137,7 +1113,7 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro /* add the new application from the store */ as_store_remove_all (priv->store); apps = as_store_get_apps (store); - for (i = 0; i < apps->len; i++) { + for (guint i = 0; i < apps->len; i++) { AsApp *app = g_ptr_array_index (apps, i); as_store_add_app (priv->store, app); } @@ -1159,11 +1135,8 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro static gboolean fu_main_store_delay_cb (gpointer user_data) { - AsApp *app; - GPtrArray *apps; - guint i; - FuDeviceItem *item; FuMainPrivate *priv = (FuMainPrivate *) user_data; + GPtrArray *apps; /* print what we've got */ apps = as_store_get_apps (priv->store); @@ -1171,8 +1144,8 @@ fu_main_store_delay_cb (gpointer user_data) g_debug ("no devices in store"); } else { g_debug ("devices now in store:"); - for (i = 0; i < apps->len; i++) { - app = g_ptr_array_index (apps, i); + for (guint i = 0; i < apps->len; i++) { + AsApp *app = g_ptr_array_index (apps, i); g_debug ("%i\t%s\t%s", i + 1, as_app_get_id (app), as_app_get_name (app, NULL)); @@ -1180,8 +1153,8 @@ fu_main_store_delay_cb (gpointer user_data) } /* are any devices now supported? */ - for (i = 0; i < priv->devices->len; i++) { - item = g_ptr_array_index (priv->devices, i); + for (guint i = 0; i < priv->devices->len; i++) { + FuDeviceItem *item = g_ptr_array_index (priv->devices, i); if (fu_main_get_updates_item_update (priv, item)) fu_main_emit_device_changed (priv, item->device); } @@ -1207,7 +1180,6 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item) GPtrArray *releases; const gchar *tmp; const gchar *version; - guint i; g_autoptr(GPtrArray) updates_list = NULL; /* get device version */ @@ -1295,7 +1267,7 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item) /* get the list of releases newer than the one installed */ updates_list = g_ptr_array_new (); releases = as_app_get_releases (app); - for (i = 0; i < releases->len; i++) { + for (guint i = 0; i < releases->len; i++) { rel = g_ptr_array_index (releases, i); if (as_utils_vercmp (as_release_get_version (rel), version) < 0) continue; @@ -1315,7 +1287,7 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item) update_desc = g_string_new (""); /* get the descriptions with a version prefix */ - for (i = 0; i < updates_list->len; i++) { + for (guint i = 0; i < updates_list->len; i++) { rel = g_ptr_array_index (updates_list, i); g_string_append_printf (update_desc, "

%s:

%s", @@ -1330,17 +1302,13 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item) return TRUE; } +/* find any updates using the AppStream metadata */ static GPtrArray * fu_main_get_updates (FuMainPrivate *priv, GError **error) { - GPtrArray *updates; - FuDeviceItem *item; - guint i; - - /* find any updates using the AppStream metadata */ - updates = g_ptr_array_new (); - for (i = 0; i < priv->devices->len; i++) { - item = g_ptr_array_index (priv->devices, i); + GPtrArray *updates = g_ptr_array_new (); + for (guint i = 0; i < priv->devices->len; i++) { + FuDeviceItem *item = g_ptr_array_index (priv->devices, i); if (fu_main_get_updates_item_update (priv, item)) g_ptr_array_add (updates, item); } @@ -1388,12 +1356,11 @@ fu_main_get_result_from_app (FuMainPrivate *priv, AsApp *app, GError **error) AsChecksum * csum_tmp; const gchar *fn; GPtrArray *provides; - guint i; g_autoptr(FwupdResult) res = NULL; res = fwupd_result_new (); provides = as_app_get_provides (app); - for (i = 0; i < provides->len; i++) { + for (guint i = 0; i < provides->len; i++) { AsProvide *prov = AS_PROVIDE (g_ptr_array_index (provides, i)); FuDeviceItem *item; const gchar *guid; @@ -1456,7 +1423,6 @@ fu_main_get_details_from_fd (FuMainPrivate *priv, gint fd, GError **error) { AsApp *app = NULL; GPtrArray *apps; - guint i; g_autoptr(AsStore) store = NULL; g_autoptr(FwupdResult) res = NULL; @@ -1476,7 +1442,7 @@ fu_main_get_details_from_fd (FuMainPrivate *priv, gint fd, GError **error) if (apps->len > 1) { /* we've got a .cab file with multiple components, * so try to find the first thing that's installed */ - for (i = 0; i < priv->devices->len; i++) { + for (guint i = 0; i < priv->devices->len; i++) { FuDeviceItem *item = g_ptr_array_index (priv->devices, i); app = fu_main_store_get_app_by_guids (store, item->device); if (app != NULL) @@ -1500,7 +1466,6 @@ fu_main_get_details_local_from_fd (FuMainPrivate *priv, gint fd, GError **error) { GPtrArray *apps; GVariantBuilder builder; - guint i; g_autoptr(AsStore) store = NULL; store = fu_main_get_store_from_fd (priv, fd, error); @@ -1519,7 +1484,7 @@ fu_main_get_details_local_from_fd (FuMainPrivate *priv, gint fd, GError **error) /* create results with all the metadata in */ g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); - for (i = 0; i < apps->len; i++) { + for (guint i = 0; i < apps->len; i++) { g_autoptr(FwupdResult) res = NULL; AsApp *app = g_ptr_array_index (apps, i); GVariant *tmp; @@ -2049,15 +2014,13 @@ fu_main_daemon_get_property (GDBusConnection *connection_, const gchar *sender, static void fu_main_providers_coldplug (FuMainPrivate *priv) { - FuProvider *provider; - guint i; g_autoptr(AsProfileTask) ptask = NULL; ptask = as_profile_start_literal (priv->profile, "FuMain:coldplug"); - for (i = 0; i < priv->providers->len; i++) { + for (guint i = 0; i < priv->providers->len; i++) { g_autoptr(GError) error = NULL; g_autoptr(AsProfileTask) ptask2 = NULL; - provider = g_ptr_array_index (priv->providers, i); + FuProvider *provider = g_ptr_array_index (priv->providers, i); ptask2 = as_profile_start (priv->profile, "FuMain:coldplug{%s}", fu_provider_get_name (provider)); diff --git a/src/fu-pending.c b/src/fu-pending.c index e6b0115c4..6391681f2 100644 --- a/src/fu-pending.c +++ b/src/fu-pending.c @@ -230,14 +230,13 @@ fu_pending_device_sqlite_cb (void *data, { GPtrArray *array = (GPtrArray *) data; FwupdResult *res; - gint i; /* create new result */ res = fwupd_result_new (); g_ptr_array_add (array, res); g_debug ("FuPending: got sql result %s", argv[0]); - for (i = 0; i < argc; i++) { + for (gint i = 0; i < argc; i++) { if (g_strcmp0 (col_name[i], "device_id") == 0) { fwupd_result_set_device_id (res, argv[i]); continue; diff --git a/src/fu-provider-dell.c b/src/fu-provider-dell.c index a5182768a..4ef45a6ca 100644 --- a/src/fu-provider-dell.c +++ b/src/fu-provider-dell.c @@ -186,7 +186,6 @@ fu_provider_dell_match_dock_component(const gchar *query_str, const efi_guid_t **guid_out, const gchar **name_out) { - guint i; const DOCK_DESCRIPTION list[] = { {WD15_EC_GUID, WD15_EC_STR, EC_DESC}, {TB15_EC_GUID, TB15_EC_STR, EC_DESC}, @@ -198,7 +197,7 @@ fu_provider_dell_match_dock_component(const gchar *query_str, {LEGACY_CBL_GUID, LEGACY_CBL_STR, LEGACY_CBL_DESC}, }; - for (i = 0; i < G_N_ELEMENTS(list); i++) { + for (guint i = 0; i < G_N_ELEMENTS(list); i++) { if (g_strcmp0 (query_str, list[i].query) == 0) { *guid_out = &list[i].guid; @@ -215,11 +214,10 @@ fu_provider_dell_inject_fake_data (FuProviderDell *provider_dell, guint8 *buf) { FuProviderDellPrivate *priv = GET_PRIVATE (provider_dell); - guint i; if (!priv->fake_smbios) return; - for (i = 0; i < 4; i++) + for (guint i = 0; i < 4; i++) priv->fake_output[i] = output[i]; priv->fake_vid = vid; priv->fake_pid = pid; @@ -249,10 +247,9 @@ fu_provider_dell_execute_simple_smi (FuProviderDell *provider_dell, guint32 *args, guint32 *out) { FuProviderDellPrivate *priv = GET_PRIVATE (provider_dell); - guint i; if (priv->fake_smbios) { - for (i = 0; i < 4; i++) + for (guint i = 0; i < 4; i++) out[i] = priv->fake_output[i]; return TRUE; } @@ -317,7 +314,6 @@ fu_provider_dell_device_free (FuProviderDellDockItem *item) static AsVersionParseFlag fu_provider_dell_get_version_format (void) { - guint i; g_autofree gchar *content = NULL; /* any vendors match */ @@ -325,7 +321,7 @@ fu_provider_dell_get_version_format (void) &content, NULL, NULL)) return AS_VERSION_PARSE_FLAG_USE_TRIPLET; g_strchomp (content); - for (i = 0; quirk_table[i].sys_vendor != NULL; i++) { + for (guint i = 0; quirk_table[i].sys_vendor != NULL; i++) { if (g_strcmp0 (content, quirk_table[i].sys_vendor) == 0) return quirk_table[i].flags; } @@ -425,7 +421,6 @@ fu_provider_dell_device_added_cb (GUsbContext *ctx, guint buf_size; g_autoptr(fu_dell_smi_obj) smi = NULL; gint result; - gint i; guint32 location; const efi_guid_t *guid_raw = NULL; efi_guid_t tmpguid; @@ -501,7 +496,7 @@ fu_provider_dell_device_added_cb (GUsbContext *ctx, g_debug ("Dell: dock component count: %d", dock_info->component_count); parse_flags = fu_provider_dell_get_version_format (); - for (i = 0; i < dock_info->component_count; i++) { + for (guint i = 0; i < dock_info->component_count; i++) { if (i > MAX_COMPONENTS) { g_debug ("Dell: Too many components. Invalid: #%d", i); break; @@ -640,7 +635,7 @@ fu_provider_dell_device_removed_cb (GUsbContext *ctx, return; /* remove any components already in database? */ - for (i = 0; i < G_N_ELEMENTS(guids); i++) { + for (guint i = 0; i < G_N_ELEMENTS(guids); i++) { guid_raw = &guids[i]; guid_str = g_strdup ("00000000-0000-0000-0000-000000000000"); efi_guid_to_str (guid_raw, &guid_str); @@ -731,7 +726,6 @@ fu_provider_dell_detect_tpm (FuProvider *provider, GError **error) const gchar *tpm_mode; const gchar *tpm_mode_alt; guint16 system_id = 0; - guint i; gboolean can_switch_modes = TRUE; g_autofree gchar *pretty_tpm_name_alt = NULL; g_autofree gchar *pretty_tpm_name = NULL; @@ -792,7 +786,7 @@ fu_provider_dell_detect_tpm (FuProvider *provider, GError **error) if (!priv->fake_smbios) system_id = sysinfo_get_dell_system_id (); - for (i = 0; i < G_N_ELEMENTS(tpm_switch_blacklist); i++) { + for (guint i = 0; i < G_N_ELEMENTS(tpm_switch_blacklist); i++) { if (tpm_switch_blacklist[i] == system_id) { can_switch_modes = FALSE; } diff --git a/src/fu-provider-rpi.c b/src/fu-provider-rpi.c index db7b720f9..ee0adf346 100644 --- a/src/fu-provider-rpi.c +++ b/src/fu-provider-rpi.c @@ -55,7 +55,6 @@ fu_provider_rpi_strstr (const guint8 *haystack, const gchar *needle, guint *offset) { - guint i; guint needle_len; if (needle == NULL || needle[0] == '\0') @@ -65,7 +64,7 @@ fu_provider_rpi_strstr (const guint8 *haystack, needle_len = strlen (needle); if (needle_len > haystack_len) return NULL; - for (i = 0; i < haystack_len - needle_len; i++) { + for (guint i = 0; i < haystack_len - needle_len; i++) { if (memcmp (haystack + i, needle, needle_len) == 0) { if (offset != NULL) *offset = i + needle_len; diff --git a/src/fu-provider-udev.c b/src/fu-provider-udev.c index 9c5ffbc4b..e6da1fee5 100644 --- a/src/fu-provider-udev.c +++ b/src/fu-provider-udev.c @@ -240,19 +240,17 @@ fu_provider_udev_coldplug (FuProvider *provider, GError **error) FuProviderUdev *provider_udev = FU_PROVIDER_UDEV (provider); FuProviderUdevPrivate *priv = GET_PRIVATE (provider_udev); GList *devices; - GList *l; GUdevDevice *udev_device; const gchar *devclass[] = { "usb", "pci", NULL }; - guint i; g_autoptr(AsProfile) profile = as_profile_new (); /* get all devices of class */ - for (i = 0; devclass[i] != NULL; i++) { + for (guint i = 0; devclass[i] != NULL; i++) { g_autoptr(AsProfileTask) ptask = NULL; ptask = as_profile_start (profile, "FuProviderUdev:coldplug{%s}", devclass[i]); devices = g_udev_client_query_by_subsystem (priv->gudev_client, devclass[i]); - for (l = devices; l != NULL; l = l->next) { + for (GList *l = devices; l != NULL; l = l->next) { udev_device = l->data; fu_provider_udev_client_add (provider_udev, udev_device); } diff --git a/src/fu-provider-uefi.c b/src/fu-provider-uefi.c index 08b0a7c42..f4c860605 100644 --- a/src/fu-provider-uefi.c +++ b/src/fu-provider-uefi.c @@ -222,14 +222,13 @@ fu_provider_uefi_update (FuProvider *provider, static AsVersionParseFlag fu_provider_uefi_get_version_format (void) { - guint i; g_autofree gchar *content = NULL; /* any vendors match */ if (!g_file_get_contents ("/sys/class/dmi/id/sys_vendor", &content, NULL, NULL)) return AS_VERSION_PARSE_FLAG_USE_TRIPLET; g_strchomp (content); - for (i = 0; quirk_table[i].sys_vendor != NULL; i++) { + for (guint i = 0; quirk_table[i].sys_vendor != NULL; i++) { if (g_strcmp0 (content, quirk_table[i].sys_vendor) == 0) return quirk_table[i].flags; } diff --git a/src/fu-provider.c b/src/fu-provider.c index 9981c8a73..73af336f1 100644 --- a/src/fu-provider.c +++ b/src/fu-provider.c @@ -107,7 +107,6 @@ fu_provider_schedule_update (FuProvider *provider, GError **error) { gchar tmpname[] = {"XXXXXX.cap"}; - guint i; g_autofree gchar *dirname = NULL; g_autofree gchar *filename = NULL; g_autoptr(FwupdResult) res_tmp = NULL; @@ -135,7 +134,7 @@ fu_provider_schedule_update (FuProvider *provider, } /* get a random filename */ - for (i = 0; i < 6; i++) + for (guint i = 0; i < 6; i++) tmpname[i] = g_random_int_range ('A', 'Z'); filename = g_build_filename (dirname, tmpname, NULL); diff --git a/src/fu-rom.c b/src/fu-rom.c index e5ade0ad3..aab7753af 100644 --- a/src/fu-rom.c +++ b/src/fu-rom.c @@ -96,7 +96,6 @@ fu_rom_kind_to_string (FuRomKind kind) static guint8 * fu_rom_pci_strstr (FuRomPciHeader *hdr, const gchar *needle) { - guint i; guint needle_len; guint8 *haystack; gsize haystack_len; @@ -112,7 +111,7 @@ fu_rom_pci_strstr (FuRomPciHeader *hdr, const gchar *needle) needle_len = strlen (needle); if (needle_len > haystack_len) return NULL; - for (i = 0; i < haystack_len - needle_len; i++) { + for (guint i = 0; i < haystack_len - needle_len; i++) { if (memcmp (haystack + i, needle, needle_len) == 0) return &haystack[i]; } @@ -138,14 +137,13 @@ static gchar * fu_rom_get_hex_dump (guint8 *buffer, gssize sz) { GString *str = NULL; - guint i; str = g_string_new (""); if (sz <= 0) return NULL; - for (i = 0; i < (guint) sz; i++) + for (guint i = 0; i < (guint) sz; i++) g_string_append_printf (str, "%02x ", buffer[i]); g_string_append (str, " "); - for (i = 0; i < (guint) sz; i++) { + for (guint i = 0; i < (guint) sz; i++) { gchar tmp = '?'; if (g_ascii_isprint (buffer[i])) tmp = buffer[i]; @@ -229,8 +227,7 @@ static guint8 fu_rom_pci_header_get_checksum (FuRomPciHeader *hdr) { guint8 chksum_check = 0x00; - guint i; - for (i = 0; i < hdr->rom_len; i++) + for (guint i = 0; i < hdr->rom_len; i++) chksum_check += hdr->rom_data[i]; return chksum_check; } @@ -304,9 +301,8 @@ fu_rom_extract_all (FuRom *rom, const gchar *path, GError **error) { FuRomPrivate *priv = GET_PRIVATE (rom); FuRomPciHeader *hdr; - guint i; - for (i = 0; i < priv->hdrs->len; i++) { + for (guint i = 0; i < priv->hdrs->len; i++) { g_autofree gchar *fn = NULL; hdr = g_ptr_array_index (priv->hdrs, i); fn = g_strdup_printf ("%s/%02i.bin", path, i); @@ -327,7 +323,6 @@ fu_rom_find_and_blank_serial_numbers (FuRom *rom) { FuRomPrivate *priv = GET_PRIVATE (rom); FuRomPciHeader *hdr; - guint i; guint8 *tmp; /* bail if not likely */ @@ -337,7 +332,7 @@ fu_rom_find_and_blank_serial_numbers (FuRom *rom) return; } - for (i = 0; i < priv->hdrs->len; i++) { + for (guint i = 0; i < priv->hdrs->len; i++) { hdr = g_ptr_array_index (priv->hdrs, i); g_debug ("looking for PPID at 0x%04x", hdr->rom_offset); tmp = fu_rom_pci_strstr (hdr, "PPID"); @@ -508,10 +503,9 @@ fu_rom_find_version_intel (FuRomPciHeader *hdr) /* 2175_RYan PC 14.34 06/06/2013 21:27:53 */ str = (gchar *) fu_rom_pci_strstr (hdr, "Build Number:"); if (str != NULL) { - guint i; g_auto(GStrv) split = NULL; split = g_strsplit (str + 14, " ", -1); - for (i = 0; split[i] != NULL; i++) { + for (guint i = 0; split[i] != NULL; i++) { if (g_strstr_len (split[i], -1, ".") == NULL) continue; return g_strdup (split[i]); @@ -565,7 +559,6 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags, gssize sz; guint32 jump = 0; guint hdr_sz = 0; - guint i; guint number_reads = 0; g_autoptr(GError) error_local = NULL; g_autofree gchar *fn = NULL; @@ -655,7 +648,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags, gboolean found_data = FALSE; /* check it's not just NUL padding */ - for (i = 0; i < hdr_sz + jump; i++) { + for (guint i = 0; i < hdr_sz + jump; i++) { if (buffer[hdr_sz + jump + i] != 0x00) { found_data = TRUE; break; @@ -706,7 +699,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags, } /* print all headers */ - for (i = 0; i < priv->hdrs->len; i++) { + for (guint i = 0; i < priv->hdrs->len; i++) { hdr = g_ptr_array_index (priv->hdrs, i); fu_rom_pci_print_header (hdr); } @@ -755,7 +748,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags, /* update checksum */ if (flags & FU_ROM_LOAD_FLAG_BLANK_PPID) fu_rom_find_and_blank_serial_numbers (rom); - for (i = 0; i < priv->hdrs->len; i++) { + for (guint i = 0; i < priv->hdrs->len; i++) { hdr = g_ptr_array_index (priv->hdrs, i); g_checksum_update (priv->checksum_wip, hdr->rom_data, hdr->rom_len); } diff --git a/src/fu-self-test.c b/src/fu-self-test.c index 3e8557ab2..9b7d0fcd5 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -53,7 +53,6 @@ fu_test_get_filename (const gchar *filename) static void fu_rom_func (void) { - guint i; struct { FuRomKind kind; const gchar *fn; @@ -95,7 +94,7 @@ fu_rom_func (void) { FU_ROM_KIND_UNKNOWN, NULL, NULL, NULL, 0x0000, 0x0000 } }; - for (i = 0; data[i].fn != NULL; i++) { + for (guint i = 0; data[i].fn != NULL; i++) { gboolean ret; g_autoptr(GError) error = NULL; g_autofree gchar *filename = NULL; diff --git a/src/fu-util.c b/src/fu-util.c index 5a338b2c5..b39a4c42d 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -92,8 +92,6 @@ fu_util_add (GPtrArray *array, const gchar *description, FuUtilPrivateCb callback) { - guint i; - FuUtilItem *item; g_auto(GStrv) names = NULL; g_return_if_fail (name != NULL); @@ -102,8 +100,8 @@ fu_util_add (GPtrArray *array, /* add each one */ names = g_strsplit (name, ",", -1); - for (i = 0; names[i] != NULL; i++) { - item = g_new0 (FuUtilItem, 1); + for (guint i = 0; names[i] != NULL; i++) { + FuUtilItem *item = g_new0 (FuUtilItem, 1); item->name = g_strdup (names[i]); if (i == 0) { item->description = g_strdup (description); @@ -121,17 +119,14 @@ fu_util_add (GPtrArray *array, static gchar * fu_util_get_descriptions (GPtrArray *array) { - guint i; - guint j; guint len; const guint max_len = 35; - FuUtilItem *item; GString *string; /* print each command */ string = g_string_new (""); - for (i = 0; i < array->len; i++) { - item = g_ptr_array_index (array, i); + for (guint i = 0; i < array->len; i++) { + FuUtilItem *item = g_ptr_array_index (array, i); g_string_append (string, " "); g_string_append (string, item->name); len = strlen (item->name) + 2; @@ -141,13 +136,13 @@ fu_util_get_descriptions (GPtrArray *array) len += strlen (item->arguments) + 1; } if (len < max_len) { - for (j = len; j < max_len + 1; j++) + for (guint j = len; j < max_len + 1; j++) g_string_append_c (string, ' '); g_string_append (string, item->description); g_string_append_c (string, '\n'); } else { g_string_append_c (string, '\n'); - for (j = 0; j < max_len + 1; j++) + for (guint j = 0; j < max_len + 1; j++) g_string_append_c (string, ' '); g_string_append (string, item->description); g_string_append_c (string, '\n'); @@ -164,12 +159,9 @@ fu_util_get_descriptions (GPtrArray *array) static gboolean fu_util_run (FuUtilPrivate *priv, const gchar *command, gchar **values, GError **error) { - guint i; - FuUtilItem *item; - /* find command */ - for (i = 0; i < priv->cmd_array->len; i++) { - item = g_ptr_array_index (priv->cmd_array, i); + for (guint i = 0; i < priv->cmd_array->len; i++) { + FuUtilItem *item = g_ptr_array_index (priv->cmd_array, i); if (g_strcmp0 (item->name, command) == 0) return item->callback (priv, values, error); } @@ -225,8 +217,6 @@ fu_util_status_changed_cb (FwupdClient *client, static gboolean fu_util_get_devices (FuUtilPrivate *priv, gchar **values, GError **error) { - FwupdResult *res; - guint i; g_autoptr(GPtrArray) results = NULL; /* get results from daemon */ @@ -241,9 +231,9 @@ fu_util_get_devices (FuUtilPrivate *priv, gchar **values, GError **error) return TRUE; } - for (i = 0; i < results->len; i++) { + for (guint i = 0; i < results->len; i++) { g_autofree gchar *tmp = NULL; - res = g_ptr_array_index (results, i); + FwupdResult *res = g_ptr_array_index (results, i); tmp = fwupd_result_to_string (res); g_print ("%s\n", tmp); } @@ -302,7 +292,6 @@ fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error) static gboolean fu_util_get_details (FuUtilPrivate *priv, gchar **values, GError **error) { - guint i; g_autoptr(GPtrArray) array = NULL; /* check args */ @@ -316,7 +305,7 @@ fu_util_get_details (FuUtilPrivate *priv, gchar **values, GError **error) array = fwupd_client_get_details_local (priv->client, values[0], NULL, error); if (array == NULL) return FALSE; - for (i = 0; i < array->len; i++) { + for (guint i = 0; i < array->len; i++) { FwupdResult *res = g_ptr_array_index (array, i); g_autofree gchar *tmp = NULL; tmp = fwupd_result_to_string (res); @@ -356,7 +345,6 @@ fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error) { gint vercmp; guint cnt = 0; - guint i; g_autofree gchar *link = NULL; g_autoptr(GPtrArray) results = NULL; g_autoptr(FuPending) pending = NULL; @@ -399,9 +387,8 @@ fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error) return FALSE; /* apply each update */ - for (i = 0; i < results->len; i++) { - FwupdResult *res; - res = g_ptr_array_index (results, i); + for (guint i = 0; i < results->len; i++) { + FwupdResult *res = g_ptr_array_index (results, i); /* check not already done */ if (fwupd_result_get_update_state (res) != FWUPD_UPDATE_STATE_PENDING) @@ -476,8 +463,6 @@ fu_util_clear_results (FuUtilPrivate *priv, gchar **values, GError **error) static gboolean fu_util_dump_rom (FuUtilPrivate *priv, gchar **values, GError **error) { - guint i; - if (g_strv_length (values) == 0) { g_set_error_literal (error, FWUPD_ERROR, @@ -485,7 +470,7 @@ fu_util_dump_rom (FuUtilPrivate *priv, gchar **values, GError **error) "Invalid arguments: expected 'filename.rom'"); return FALSE; } - for (i = 0; values[i] != NULL; i++) { + for (guint i = 0; values[i] != NULL; i++) { g_autoptr(FuRom) rom = NULL; g_autoptr(GFile) file = NULL; g_autoptr(GError) error_local = NULL; @@ -513,7 +498,6 @@ fu_util_verify_update_internal (FuUtilPrivate *priv, gchar **values, GError **error) { - guint i; g_autoptr(AsStore) store = NULL; g_autoptr(GFile) xml_file = NULL; @@ -528,7 +512,7 @@ fu_util_verify_update_internal (FuUtilPrivate *priv, /* add new values */ as_store_set_api_version (store, 0.9); - for (i = 0; values[i] != NULL; i++) { + for (guint i = 0; values[i] != NULL; i++) { g_autofree gchar *id = NULL; g_autoptr(AsApp) app = NULL; g_autoptr(AsChecksum) csum = NULL; @@ -581,22 +565,19 @@ fu_util_verify_update_internal (FuUtilPrivate *priv, static gboolean fu_util_verify_update_all (FuUtilPrivate *priv, const gchar *fn, GError **error) { - GList *devices; - GList *l; GUdevDevice *dev; const gchar *devclass[] = { "pci", NULL }; const gchar *subsystems[] = { NULL }; - guint i; g_autoptr(GUdevClient) gudev_client = NULL; g_autoptr(GPtrArray) roms = NULL; /* get all devices of class */ gudev_client = g_udev_client_new (subsystems); roms = g_ptr_array_new_with_free_func (g_free); - for (i = 0; devclass[i] != NULL; i++) { - devices = g_udev_client_query_by_subsystem (gudev_client, + for (guint i = 0; devclass[i] != NULL; i++) { + GList *devices = g_udev_client_query_by_subsystem (gudev_client, devclass[i]); - for (l = devices; l != NULL; l = l->next) { + for (GList *l = devices; l != NULL; l = l->next) { g_autofree gchar *rom_fn = NULL; dev = l->data; rom_fn = g_build_filename (g_udev_device_get_sysfs_path (dev), "rom", NULL); @@ -805,8 +786,6 @@ fu_util_get_results (FuUtilPrivate *priv, gchar **values, GError **error) static gboolean fu_util_verify_all (FuUtilPrivate *priv, GError **error) { - FwupdResult *res; - guint i; g_autoptr(GPtrArray) results = NULL; /* get devices from daemon */ @@ -815,9 +794,9 @@ fu_util_verify_all (FuUtilPrivate *priv, GError **error) return FALSE; /* get results */ - for (i = 0; i < results->len; i++) { + for (guint i = 0; i < results->len; i++) { g_autoptr(GError) error_local = NULL; - res = g_ptr_array_index (results, i); + FwupdResult *res = g_ptr_array_index (results, i); if (!fwupd_client_verify (priv->client, fwupd_result_get_device_id (res), NULL, @@ -865,8 +844,6 @@ fu_util_unlock (FuUtilPrivate *priv, gchar **values, GError **error) static void fu_util_print_data (const gchar *title, const gchar *msg) { - guint i; - guint j; guint title_len; g_auto(GStrv) lines = NULL; @@ -877,8 +854,8 @@ fu_util_print_data (const gchar *title, const gchar *msg) /* pad */ title_len = strlen (title) + 1; lines = g_strsplit (msg, "\n", -1); - for (j = 0; lines[j] != NULL; j++) { - for (i = title_len; i < 25; i++) + for (guint j = 0; lines[j] != NULL; j++) { + for (guint i = title_len; i < 25; i++) g_print (" "); g_print ("%s\n", lines[j]); title_len = 0; @@ -902,19 +879,17 @@ _g_checksum_type_to_string (GChecksumType checksum_type) static gboolean fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error) { - FwupdResult *res; GPtrArray *results = NULL; GPtrArray *guids; GChecksumType checksum_type; const gchar *tmp; - guint i, j; /* print any updates */ results = fwupd_client_get_updates (priv->client, NULL, error); if (results == NULL) return FALSE; - for (i = 0; i < results->len; i++) { - res = g_ptr_array_index (results, i); + for (guint i = 0; i < results->len; i++) { + FwupdResult *res = g_ptr_array_index (results, i); /* TRANSLATORS: first replacement is device name */ g_print (_("%s has firmware updates:"), fwupd_result_get_device_name (res)); @@ -925,7 +900,7 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error) /* TRANSLATORS: a GUID for the hardware */ guids = fwupd_result_get_guids (res); - for (j = 0; j < guids->len; j++) { + for (guint j = 0; j < guids->len; j++) { tmp = g_ptr_array_index (guids, j); fu_util_print_data (_("GUID"), tmp); } @@ -1039,22 +1014,20 @@ fu_util_monitor (FuUtilPrivate *priv, gchar **values, GError **error) static gboolean fu_util_update (FuUtilPrivate *priv, gchar **values, GError **error) { - FwupdResult *res; GPtrArray *results = NULL; - guint i; /* apply any updates */ results = fwupd_client_get_updates (priv->client, NULL, error); if (results == NULL) return FALSE; - for (i = 0; i < results->len; i++) { + for (guint i = 0; i < results->len; i++) { GChecksumType checksum_type; const gchar *checksum; const gchar *uri; g_autofree gchar *basename = NULL; g_autofree gchar *fn = NULL; - res = g_ptr_array_index (results, i); + FwupdResult *res = g_ptr_array_index (results, i); /* download file */ checksum = fwupd_result_get_update_checksum (res);