trivial: Switch to compiling with C99 by default

We're already using non-MSVC features like g_autoptr().
This commit is contained in:
Richard Hughes 2016-07-22 08:26:43 +01:00
parent b44c826bbe
commit f192bf025a
11 changed files with 92 additions and 175 deletions

View File

@ -13,6 +13,7 @@ AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-xz tar-ustar foreign])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_PROG_CC_STDC
m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [GOBJECT_INTROSPECTION_CHECK([0.9.8])]) m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [GOBJECT_INTROSPECTION_CHECK([0.9.8])])
AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = xyes) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = xyes)

View File

@ -205,7 +205,6 @@ static GVariant *
fu_main_device_array_to_variant (GPtrArray *devices, GError **error) fu_main_device_array_to_variant (GPtrArray *devices, GError **error)
{ {
GVariantBuilder builder; GVariantBuilder builder;
guint i;
/* no devices */ /* no devices */
if (devices->len == 0) { 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); 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; GVariant *tmp;
FuDeviceItem *item; FuDeviceItem *item;
item = g_ptr_array_index (devices, i); item = g_ptr_array_index (devices, i);
@ -232,7 +231,6 @@ fu_main_load_plugins (GHashTable *plugins, GError **error)
{ {
FuPlugin *plugin; FuPlugin *plugin;
GModule *module; GModule *module;
GList *l;
const gchar *fn; const gchar *fn;
g_autofree gchar *plugin_dir = NULL; g_autofree gchar *plugin_dir = NULL;
g_autoptr(GDir) dir = NULL; g_autoptr(GDir) dir = NULL;
@ -272,7 +270,7 @@ fu_main_load_plugins (GHashTable *plugins, GError **error)
/* start them all up */ /* start them all up */
values = g_hash_table_get_values (plugins); 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); plugin = FU_PLUGIN (l->data);
if (!fu_plugin_run_startup (plugin, error)) if (!fu_plugin_run_startup (plugin, error))
return FALSE; return FALSE;
@ -304,11 +302,8 @@ fu_main_item_free (FuDeviceItem *item)
static FuDeviceItem * static FuDeviceItem *
fu_main_get_item_by_id (FuMainPrivate *priv, const gchar *id) fu_main_get_item_by_id (FuMainPrivate *priv, const gchar *id)
{ {
FuDeviceItem *item; for (guint i = 0; i < priv->devices->len; i++) {
guint i; FuDeviceItem *item = g_ptr_array_index (priv->devices, i);
for (i = 0; i < priv->devices->len; i++) {
item = g_ptr_array_index (priv->devices, i);
if (g_strcmp0 (fu_device_get_id (item->device), id) == 0) if (g_strcmp0 (fu_device_get_id (item->device), id) == 0)
return item; return item;
if (g_strcmp0 (fu_device_get_equivalent_id (item->device), id) == 0) 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 * static FuDeviceItem *
fu_main_get_item_by_guid (FuMainPrivate *priv, const gchar *guid) fu_main_get_item_by_guid (FuMainPrivate *priv, const gchar *guid)
{ {
FuDeviceItem *item; for (guint i = 0; i < priv->devices->len; i++) {
guint i; FuDeviceItem *item = g_ptr_array_index (priv->devices, i);
for (i = 0; i < priv->devices->len; i++) {
item = g_ptr_array_index (priv->devices, i);
if (fu_device_has_guid (item->device, guid)) if (fu_device_has_guid (item->device, guid))
return item; return item;
} }
@ -334,11 +326,8 @@ fu_main_get_item_by_guid (FuMainPrivate *priv, const gchar *guid)
static FuProvider * static FuProvider *
fu_main_get_provider_by_name (FuMainPrivate *priv, const gchar *name) fu_main_get_provider_by_name (FuMainPrivate *priv, const gchar *name)
{ {
FuProvider *provider; for (guint i = 0; i < priv->providers->len; i++) {
guint i; FuProvider *provider = g_ptr_array_index (priv->providers, i);
for (i = 0; i < priv->providers->len; i++) {
provider = g_ptr_array_index (priv->providers, i);
if (g_strcmp0 (fu_provider_get_name (provider), name) == 0) if (g_strcmp0 (fu_provider_get_name (provider), name) == 0)
return provider; return provider;
} }
@ -469,10 +458,8 @@ fu_main_on_battery (FuMainPrivate *priv)
static gboolean static gboolean
fu_main_provider_unlock_authenticated (FuMainAuthHelper *helper, GError **error) fu_main_provider_unlock_authenticated (FuMainAuthHelper *helper, GError **error)
{ {
guint i;
/* check the devices still exists */ /* check the devices still exists */
for (i = 0; i < helper->devices->len; i ++) { for (guint i = 0; i < helper->devices->len; i ++) {
FuDeviceItem *item; FuDeviceItem *item;
FuDevice *device = g_ptr_array_index (helper->devices, i); FuDevice *device = g_ptr_array_index (helper->devices, i);
@ -508,10 +495,9 @@ fu_main_provider_update_authenticated (FuMainAuthHelper *helper, GError **error)
{ {
FuDeviceItem *item; FuDeviceItem *item;
FuPlugin *plugin; FuPlugin *plugin;
guint i;
/* check the devices still exists */ /* 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); FuDevice *device = g_ptr_array_index (helper->devices, i);
item = fu_main_get_item_by_id (helper->priv, item = fu_main_get_item_by_id (helper->priv,
fu_device_get_id (device)); 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 */ /* 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); FuDevice *device = g_ptr_array_index (helper->devices, i);
GBytes *blob_fw = g_ptr_array_index (helper->blob_fws, i); GBytes *blob_fw = g_ptr_array_index (helper->blob_fws, i);
item = fu_main_get_item_by_id (helper->priv, 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 * static gchar *
fu_main_get_guids_from_store (AsStore *store) fu_main_get_guids_from_store (AsStore *store)
{ {
AsApp *app;
AsProvide *prov; AsProvide *prov;
GPtrArray *provides; GPtrArray *provides;
GPtrArray *apps; GPtrArray *apps;
GString *str = g_string_new (""); GString *str = g_string_new ("");
guint i;
guint j;
/* return a string with all the firmware apps in the store */ /* return a string with all the firmware apps in the store */
apps = as_store_get_apps (store); apps = as_store_get_apps (store);
for (i = 0; i < apps->len; i++) { for (guint i = 0; i < apps->len; i++) {
app = AS_APP (g_ptr_array_index (apps, i)); AsApp *app = AS_APP (g_ptr_array_index (apps, i));
provides = as_app_get_provides (app); 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)); prov = AS_PROVIDE (g_ptr_array_index (provides, j));
if (as_provide_get_kind (prov) != AS_PROVIDE_KIND_FIRMWARE_FLASHED) if (as_provide_get_kind (prov) != AS_PROVIDE_KIND_FIRMWARE_FLASHED)
continue; continue;
@ -661,19 +644,19 @@ fu_main_vendor_quirk_release_version (AsApp *app)
{ {
AsVersionParseFlag flags = AS_VERSION_PARSE_FLAG_USE_TRIPLET; AsVersionParseFlag flags = AS_VERSION_PARSE_FLAG_USE_TRIPLET;
GPtrArray *releases; GPtrArray *releases;
guint i;
/* no quirk required */ /* no quirk required */
if (as_app_get_kind (app) != AS_APP_KIND_FIRMWARE) if (as_app_get_kind (app) != AS_APP_KIND_FIRMWARE)
return; 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)) if (g_str_has_prefix (as_app_get_id(app), quirk_table[i].identifier))
flags = quirk_table[i].flags; flags = quirk_table[i].flags;
}
/* fix each release */ /* fix each release */
releases = as_app_get_releases (app); releases = as_app_get_releases (app);
for (i = 0; i < releases->len; i++) { for (guint i = 0; i < releases->len; i++) {
AsRelease *rel; AsRelease *rel;
const gchar *version; const gchar *version;
guint64 ver_uint32; guint64 ver_uint32;
@ -704,11 +687,8 @@ fu_main_vendor_quirk_release_version (AsApp *app)
static AsApp * static AsApp *
fu_main_store_get_app_by_guids (AsStore *store, FuDevice *device) fu_main_store_get_app_by_guids (AsStore *store, FuDevice *device)
{ {
GPtrArray *guids; GPtrArray *guids = fu_device_get_guids (device);
guint i; for (guint i = 0; i < guids->len; i++) {
guids = fu_device_get_guids (device);
for (i = 0; i < guids->len; i++) {
AsApp *app = NULL; AsApp *app = NULL;
app = as_store_get_app_by_provide (store, app = as_store_get_app_by_provide (store,
AS_PROVIDE_KIND_FIRMWARE_FLASHED, AS_PROVIDE_KIND_FIRMWARE_FLASHED,
@ -849,7 +829,6 @@ fu_main_update_helper_for_device (FuMainAuthHelper *helper,
static gboolean static gboolean
fu_main_update_helper (FuMainAuthHelper *helper, GError **error) fu_main_update_helper (FuMainAuthHelper *helper, GError **error)
{ {
guint i;
g_autoptr(GError) error_first = NULL; g_autoptr(GError) error_first = NULL;
/* load store file which also decompresses firmware */ /* 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 */ /* we've specified a specific device; failure is critical */
if (helper->devices->len > 0) { 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); FuDevice *device = g_ptr_array_index (helper->devices, i);
if (!fu_main_update_helper_for_device (helper, device, error)) if (!fu_main_update_helper_for_device (helper, device, error))
return FALSE; 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 /* if we've not chosen a device, try and find anything in the
* cabinet 'store' that matches any installed device and is updatable */ * 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; AsApp *app;
FuDeviceItem *item; FuDeviceItem *item;
g_autoptr(GError) error_local = NULL; 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; FuDeviceItem *item = NULL;
FwupdUpdateState update_state; FwupdUpdateState update_state;
const gchar *tmp; const gchar *tmp;
guint i;
g_autoptr(GPtrArray) devices = NULL; g_autoptr(GPtrArray) devices = NULL;
/* not a wildcard */ /* 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); devices = fu_pending_get_devices (priv->pending, error);
if (devices == NULL) if (devices == NULL)
return 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); dev = g_ptr_array_index (devices, i);
update_state = fu_device_get_update_state (dev); update_state = fu_device_get_update_state (dev);
if (update_state == FWUPD_UPDATE_STATE_UNKNOWN) 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 all_removable = TRUE;
gboolean is_trusted; gboolean is_trusted;
guint i;
/* only test the payload */ /* only test the payload */
is_trusted = (helper->trust_flags & FWUPD_TRUST_FLAG_PAYLOAD) > 0; is_trusted = (helper->trust_flags & FWUPD_TRUST_FLAG_PAYLOAD) > 0;
/* any non-removable means false */ /* 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); FuDevice *device = g_ptr_array_index (helper->devices, i);
if (fu_device_has_flag (device, FU_DEVICE_FLAG_INTERNAL)) { if (fu_device_has_flag (device, FU_DEVICE_FLAG_INTERNAL)) {
all_removable = FALSE; all_removable = FALSE;
@ -1062,7 +1039,6 @@ static gboolean
fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GError **error) fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GError **error)
{ {
const guint8 *data; const guint8 *data;
guint i;
gsize size; gsize size;
GPtrArray *apps; GPtrArray *apps;
g_autofree gchar *xml = NULL; 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 */ /* add the new application from the store */
as_store_remove_all (priv->store); as_store_remove_all (priv->store);
apps = as_store_get_apps (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); AsApp *app = g_ptr_array_index (apps, i);
as_store_add_app (priv->store, app); 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 static gboolean
fu_main_store_delay_cb (gpointer user_data) fu_main_store_delay_cb (gpointer user_data)
{ {
AsApp *app;
GPtrArray *apps;
guint i;
FuDeviceItem *item;
FuMainPrivate *priv = (FuMainPrivate *) user_data; FuMainPrivate *priv = (FuMainPrivate *) user_data;
GPtrArray *apps;
/* print what we've got */ /* print what we've got */
apps = as_store_get_apps (priv->store); 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"); g_debug ("no devices in store");
} else { } else {
g_debug ("devices now in store:"); g_debug ("devices now in store:");
for (i = 0; i < apps->len; i++) { for (guint i = 0; i < apps->len; i++) {
app = g_ptr_array_index (apps, i); AsApp *app = g_ptr_array_index (apps, i);
g_debug ("%i\t%s\t%s", i + 1, g_debug ("%i\t%s\t%s", i + 1,
as_app_get_id (app), as_app_get_id (app),
as_app_get_name (app, NULL)); as_app_get_name (app, NULL));
@ -1180,8 +1153,8 @@ fu_main_store_delay_cb (gpointer user_data)
} }
/* are any devices now supported? */ /* are any devices now supported? */
for (i = 0; i < priv->devices->len; i++) { for (guint i = 0; i < priv->devices->len; i++) {
item = g_ptr_array_index (priv->devices, i); FuDeviceItem *item = g_ptr_array_index (priv->devices, i);
if (fu_main_get_updates_item_update (priv, item)) if (fu_main_get_updates_item_update (priv, item))
fu_main_emit_device_changed (priv, item->device); fu_main_emit_device_changed (priv, item->device);
} }
@ -1207,7 +1180,6 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item)
GPtrArray *releases; GPtrArray *releases;
const gchar *tmp; const gchar *tmp;
const gchar *version; const gchar *version;
guint i;
g_autoptr(GPtrArray) updates_list = NULL; g_autoptr(GPtrArray) updates_list = NULL;
/* get device version */ /* 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 */ /* get the list of releases newer than the one installed */
updates_list = g_ptr_array_new (); updates_list = g_ptr_array_new ();
releases = as_app_get_releases (app); 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); rel = g_ptr_array_index (releases, i);
if (as_utils_vercmp (as_release_get_version (rel), version) < 0) if (as_utils_vercmp (as_release_get_version (rel), version) < 0)
continue; continue;
@ -1315,7 +1287,7 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item)
update_desc = g_string_new (""); update_desc = g_string_new ("");
/* get the descriptions with a version prefix */ /* 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); rel = g_ptr_array_index (updates_list, i);
g_string_append_printf (update_desc, g_string_append_printf (update_desc,
"<p>%s:</p>%s", "<p>%s:</p>%s",
@ -1330,17 +1302,13 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item)
return TRUE; return TRUE;
} }
/* find any updates using the AppStream metadata */
static GPtrArray * static GPtrArray *
fu_main_get_updates (FuMainPrivate *priv, GError **error) fu_main_get_updates (FuMainPrivate *priv, GError **error)
{ {
GPtrArray *updates; GPtrArray *updates = g_ptr_array_new ();
FuDeviceItem *item; for (guint i = 0; i < priv->devices->len; i++) {
guint i; FuDeviceItem *item = g_ptr_array_index (priv->devices, 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);
if (fu_main_get_updates_item_update (priv, item)) if (fu_main_get_updates_item_update (priv, item))
g_ptr_array_add (updates, 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; AsChecksum * csum_tmp;
const gchar *fn; const gchar *fn;
GPtrArray *provides; GPtrArray *provides;
guint i;
g_autoptr(FwupdResult) res = NULL; g_autoptr(FwupdResult) res = NULL;
res = fwupd_result_new (); res = fwupd_result_new ();
provides = as_app_get_provides (app); 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)); AsProvide *prov = AS_PROVIDE (g_ptr_array_index (provides, i));
FuDeviceItem *item; FuDeviceItem *item;
const gchar *guid; const gchar *guid;
@ -1456,7 +1423,6 @@ fu_main_get_details_from_fd (FuMainPrivate *priv, gint fd, GError **error)
{ {
AsApp *app = NULL; AsApp *app = NULL;
GPtrArray *apps; GPtrArray *apps;
guint i;
g_autoptr(AsStore) store = NULL; g_autoptr(AsStore) store = NULL;
g_autoptr(FwupdResult) res = 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) { if (apps->len > 1) {
/* we've got a .cab file with multiple components, /* we've got a .cab file with multiple components,
* so try to find the first thing that's installed */ * 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); FuDeviceItem *item = g_ptr_array_index (priv->devices, i);
app = fu_main_store_get_app_by_guids (store, item->device); app = fu_main_store_get_app_by_guids (store, item->device);
if (app != NULL) if (app != NULL)
@ -1500,7 +1466,6 @@ fu_main_get_details_local_from_fd (FuMainPrivate *priv, gint fd, GError **error)
{ {
GPtrArray *apps; GPtrArray *apps;
GVariantBuilder builder; GVariantBuilder builder;
guint i;
g_autoptr(AsStore) store = NULL; g_autoptr(AsStore) store = NULL;
store = fu_main_get_store_from_fd (priv, fd, error); 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 */ /* create results with all the metadata in */
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); 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; g_autoptr(FwupdResult) res = NULL;
AsApp *app = g_ptr_array_index (apps, i); AsApp *app = g_ptr_array_index (apps, i);
GVariant *tmp; GVariant *tmp;
@ -2049,15 +2014,13 @@ fu_main_daemon_get_property (GDBusConnection *connection_, const gchar *sender,
static void static void
fu_main_providers_coldplug (FuMainPrivate *priv) fu_main_providers_coldplug (FuMainPrivate *priv)
{ {
FuProvider *provider;
guint i;
g_autoptr(AsProfileTask) ptask = NULL; g_autoptr(AsProfileTask) ptask = NULL;
ptask = as_profile_start_literal (priv->profile, "FuMain:coldplug"); 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(GError) error = NULL;
g_autoptr(AsProfileTask) ptask2 = 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, ptask2 = as_profile_start (priv->profile,
"FuMain:coldplug{%s}", "FuMain:coldplug{%s}",
fu_provider_get_name (provider)); fu_provider_get_name (provider));

View File

@ -230,14 +230,13 @@ fu_pending_device_sqlite_cb (void *data,
{ {
GPtrArray *array = (GPtrArray *) data; GPtrArray *array = (GPtrArray *) data;
FwupdResult *res; FwupdResult *res;
gint i;
/* create new result */ /* create new result */
res = fwupd_result_new (); res = fwupd_result_new ();
g_ptr_array_add (array, res); g_ptr_array_add (array, res);
g_debug ("FuPending: got sql result %s", argv[0]); 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) { if (g_strcmp0 (col_name[i], "device_id") == 0) {
fwupd_result_set_device_id (res, argv[i]); fwupd_result_set_device_id (res, argv[i]);
continue; continue;

View File

@ -186,7 +186,6 @@ fu_provider_dell_match_dock_component(const gchar *query_str,
const efi_guid_t **guid_out, const efi_guid_t **guid_out,
const gchar **name_out) const gchar **name_out)
{ {
guint i;
const DOCK_DESCRIPTION list[] = { const DOCK_DESCRIPTION list[] = {
{WD15_EC_GUID, WD15_EC_STR, EC_DESC}, {WD15_EC_GUID, WD15_EC_STR, EC_DESC},
{TB15_EC_GUID, TB15_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}, {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, if (g_strcmp0 (query_str,
list[i].query) == 0) { list[i].query) == 0) {
*guid_out = &list[i].guid; *guid_out = &list[i].guid;
@ -215,11 +214,10 @@ fu_provider_dell_inject_fake_data (FuProviderDell *provider_dell,
guint8 *buf) guint8 *buf)
{ {
FuProviderDellPrivate *priv = GET_PRIVATE (provider_dell); FuProviderDellPrivate *priv = GET_PRIVATE (provider_dell);
guint i;
if (!priv->fake_smbios) if (!priv->fake_smbios)
return; return;
for (i = 0; i < 4; i++) for (guint i = 0; i < 4; i++)
priv->fake_output[i] = output[i]; priv->fake_output[i] = output[i];
priv->fake_vid = vid; priv->fake_vid = vid;
priv->fake_pid = pid; priv->fake_pid = pid;
@ -249,10 +247,9 @@ fu_provider_dell_execute_simple_smi (FuProviderDell *provider_dell,
guint32 *args, guint32 *out) guint32 *args, guint32 *out)
{ {
FuProviderDellPrivate *priv = GET_PRIVATE (provider_dell); FuProviderDellPrivate *priv = GET_PRIVATE (provider_dell);
guint i;
if (priv->fake_smbios) { if (priv->fake_smbios) {
for (i = 0; i < 4; i++) for (guint i = 0; i < 4; i++)
out[i] = priv->fake_output[i]; out[i] = priv->fake_output[i];
return TRUE; return TRUE;
} }
@ -317,7 +314,6 @@ fu_provider_dell_device_free (FuProviderDellDockItem *item)
static AsVersionParseFlag static AsVersionParseFlag
fu_provider_dell_get_version_format (void) fu_provider_dell_get_version_format (void)
{ {
guint i;
g_autofree gchar *content = NULL; g_autofree gchar *content = NULL;
/* any vendors match */ /* any vendors match */
@ -325,7 +321,7 @@ fu_provider_dell_get_version_format (void)
&content, NULL, NULL)) &content, NULL, NULL))
return AS_VERSION_PARSE_FLAG_USE_TRIPLET; return AS_VERSION_PARSE_FLAG_USE_TRIPLET;
g_strchomp (content); 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) if (g_strcmp0 (content, quirk_table[i].sys_vendor) == 0)
return quirk_table[i].flags; return quirk_table[i].flags;
} }
@ -425,7 +421,6 @@ fu_provider_dell_device_added_cb (GUsbContext *ctx,
guint buf_size; guint buf_size;
g_autoptr(fu_dell_smi_obj) smi = NULL; g_autoptr(fu_dell_smi_obj) smi = NULL;
gint result; gint result;
gint i;
guint32 location; guint32 location;
const efi_guid_t *guid_raw = NULL; const efi_guid_t *guid_raw = NULL;
efi_guid_t tmpguid; 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); g_debug ("Dell: dock component count: %d", dock_info->component_count);
parse_flags = fu_provider_dell_get_version_format (); 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) { if (i > MAX_COMPONENTS) {
g_debug ("Dell: Too many components. Invalid: #%d", i); g_debug ("Dell: Too many components. Invalid: #%d", i);
break; break;
@ -640,7 +635,7 @@ fu_provider_dell_device_removed_cb (GUsbContext *ctx,
return; return;
/* remove any components already in database? */ /* 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_raw = &guids[i];
guid_str = g_strdup ("00000000-0000-0000-0000-000000000000"); guid_str = g_strdup ("00000000-0000-0000-0000-000000000000");
efi_guid_to_str (guid_raw, &guid_str); 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;
const gchar *tpm_mode_alt; const gchar *tpm_mode_alt;
guint16 system_id = 0; guint16 system_id = 0;
guint i;
gboolean can_switch_modes = TRUE; gboolean can_switch_modes = TRUE;
g_autofree gchar *pretty_tpm_name_alt = NULL; g_autofree gchar *pretty_tpm_name_alt = NULL;
g_autofree gchar *pretty_tpm_name = 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) if (!priv->fake_smbios)
system_id = sysinfo_get_dell_system_id (); 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) { if (tpm_switch_blacklist[i] == system_id) {
can_switch_modes = FALSE; can_switch_modes = FALSE;
} }

View File

@ -55,7 +55,6 @@ fu_provider_rpi_strstr (const guint8 *haystack,
const gchar *needle, const gchar *needle,
guint *offset) guint *offset)
{ {
guint i;
guint needle_len; guint needle_len;
if (needle == NULL || needle[0] == '\0') if (needle == NULL || needle[0] == '\0')
@ -65,7 +64,7 @@ fu_provider_rpi_strstr (const guint8 *haystack,
needle_len = strlen (needle); needle_len = strlen (needle);
if (needle_len > haystack_len) if (needle_len > haystack_len)
return NULL; 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 (memcmp (haystack + i, needle, needle_len) == 0) {
if (offset != NULL) if (offset != NULL)
*offset = i + needle_len; *offset = i + needle_len;

View File

@ -240,19 +240,17 @@ fu_provider_udev_coldplug (FuProvider *provider, GError **error)
FuProviderUdev *provider_udev = FU_PROVIDER_UDEV (provider); FuProviderUdev *provider_udev = FU_PROVIDER_UDEV (provider);
FuProviderUdevPrivate *priv = GET_PRIVATE (provider_udev); FuProviderUdevPrivate *priv = GET_PRIVATE (provider_udev);
GList *devices; GList *devices;
GList *l;
GUdevDevice *udev_device; GUdevDevice *udev_device;
const gchar *devclass[] = { "usb", "pci", NULL }; const gchar *devclass[] = { "usb", "pci", NULL };
guint i;
g_autoptr(AsProfile) profile = as_profile_new (); g_autoptr(AsProfile) profile = as_profile_new ();
/* get all devices of class */ /* 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; g_autoptr(AsProfileTask) ptask = NULL;
ptask = as_profile_start (profile, "FuProviderUdev:coldplug{%s}", devclass[i]); ptask = as_profile_start (profile, "FuProviderUdev:coldplug{%s}", devclass[i]);
devices = g_udev_client_query_by_subsystem (priv->gudev_client, devices = g_udev_client_query_by_subsystem (priv->gudev_client,
devclass[i]); devclass[i]);
for (l = devices; l != NULL; l = l->next) { for (GList *l = devices; l != NULL; l = l->next) {
udev_device = l->data; udev_device = l->data;
fu_provider_udev_client_add (provider_udev, udev_device); fu_provider_udev_client_add (provider_udev, udev_device);
} }

View File

@ -222,14 +222,13 @@ fu_provider_uefi_update (FuProvider *provider,
static AsVersionParseFlag static AsVersionParseFlag
fu_provider_uefi_get_version_format (void) fu_provider_uefi_get_version_format (void)
{ {
guint i;
g_autofree gchar *content = NULL; g_autofree gchar *content = NULL;
/* any vendors match */ /* any vendors match */
if (!g_file_get_contents ("/sys/class/dmi/id/sys_vendor", if (!g_file_get_contents ("/sys/class/dmi/id/sys_vendor",
&content, NULL, NULL)) &content, NULL, NULL))
return AS_VERSION_PARSE_FLAG_USE_TRIPLET; return AS_VERSION_PARSE_FLAG_USE_TRIPLET;
g_strchomp (content); 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) if (g_strcmp0 (content, quirk_table[i].sys_vendor) == 0)
return quirk_table[i].flags; return quirk_table[i].flags;
} }

View File

@ -107,7 +107,6 @@ fu_provider_schedule_update (FuProvider *provider,
GError **error) GError **error)
{ {
gchar tmpname[] = {"XXXXXX.cap"}; gchar tmpname[] = {"XXXXXX.cap"};
guint i;
g_autofree gchar *dirname = NULL; g_autofree gchar *dirname = NULL;
g_autofree gchar *filename = NULL; g_autofree gchar *filename = NULL;
g_autoptr(FwupdResult) res_tmp = NULL; g_autoptr(FwupdResult) res_tmp = NULL;
@ -135,7 +134,7 @@ fu_provider_schedule_update (FuProvider *provider,
} }
/* get a random filename */ /* 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'); tmpname[i] = g_random_int_range ('A', 'Z');
filename = g_build_filename (dirname, tmpname, NULL); filename = g_build_filename (dirname, tmpname, NULL);

View File

@ -96,7 +96,6 @@ fu_rom_kind_to_string (FuRomKind kind)
static guint8 * static guint8 *
fu_rom_pci_strstr (FuRomPciHeader *hdr, const gchar *needle) fu_rom_pci_strstr (FuRomPciHeader *hdr, const gchar *needle)
{ {
guint i;
guint needle_len; guint needle_len;
guint8 *haystack; guint8 *haystack;
gsize haystack_len; gsize haystack_len;
@ -112,7 +111,7 @@ fu_rom_pci_strstr (FuRomPciHeader *hdr, const gchar *needle)
needle_len = strlen (needle); needle_len = strlen (needle);
if (needle_len > haystack_len) if (needle_len > haystack_len)
return NULL; 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 (memcmp (haystack + i, needle, needle_len) == 0)
return &haystack[i]; return &haystack[i];
} }
@ -138,14 +137,13 @@ static gchar *
fu_rom_get_hex_dump (guint8 *buffer, gssize sz) fu_rom_get_hex_dump (guint8 *buffer, gssize sz)
{ {
GString *str = NULL; GString *str = NULL;
guint i;
str = g_string_new (""); str = g_string_new ("");
if (sz <= 0) if (sz <= 0)
return NULL; 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_printf (str, "%02x ", buffer[i]);
g_string_append (str, " "); g_string_append (str, " ");
for (i = 0; i < (guint) sz; i++) { for (guint i = 0; i < (guint) sz; i++) {
gchar tmp = '?'; gchar tmp = '?';
if (g_ascii_isprint (buffer[i])) if (g_ascii_isprint (buffer[i]))
tmp = buffer[i]; tmp = buffer[i];
@ -229,8 +227,7 @@ static guint8
fu_rom_pci_header_get_checksum (FuRomPciHeader *hdr) fu_rom_pci_header_get_checksum (FuRomPciHeader *hdr)
{ {
guint8 chksum_check = 0x00; guint8 chksum_check = 0x00;
guint i; for (guint i = 0; i < hdr->rom_len; i++)
for (i = 0; i < hdr->rom_len; i++)
chksum_check += hdr->rom_data[i]; chksum_check += hdr->rom_data[i];
return chksum_check; return chksum_check;
} }
@ -304,9 +301,8 @@ fu_rom_extract_all (FuRom *rom, const gchar *path, GError **error)
{ {
FuRomPrivate *priv = GET_PRIVATE (rom); FuRomPrivate *priv = GET_PRIVATE (rom);
FuRomPciHeader *hdr; 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; g_autofree gchar *fn = NULL;
hdr = g_ptr_array_index (priv->hdrs, i); hdr = g_ptr_array_index (priv->hdrs, i);
fn = g_strdup_printf ("%s/%02i.bin", path, 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); FuRomPrivate *priv = GET_PRIVATE (rom);
FuRomPciHeader *hdr; FuRomPciHeader *hdr;
guint i;
guint8 *tmp; guint8 *tmp;
/* bail if not likely */ /* bail if not likely */
@ -337,7 +332,7 @@ fu_rom_find_and_blank_serial_numbers (FuRom *rom)
return; 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); hdr = g_ptr_array_index (priv->hdrs, i);
g_debug ("looking for PPID at 0x%04x", hdr->rom_offset); g_debug ("looking for PPID at 0x%04x", hdr->rom_offset);
tmp = fu_rom_pci_strstr (hdr, "PPID"); 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 */ /* 2175_RYan PC 14.34 06/06/2013 21:27:53 */
str = (gchar *) fu_rom_pci_strstr (hdr, "Build Number:"); str = (gchar *) fu_rom_pci_strstr (hdr, "Build Number:");
if (str != NULL) { if (str != NULL) {
guint i;
g_auto(GStrv) split = NULL; g_auto(GStrv) split = NULL;
split = g_strsplit (str + 14, " ", -1); 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) if (g_strstr_len (split[i], -1, ".") == NULL)
continue; continue;
return g_strdup (split[i]); return g_strdup (split[i]);
@ -565,7 +559,6 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
gssize sz; gssize sz;
guint32 jump = 0; guint32 jump = 0;
guint hdr_sz = 0; guint hdr_sz = 0;
guint i;
guint number_reads = 0; guint number_reads = 0;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
@ -655,7 +648,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
gboolean found_data = FALSE; gboolean found_data = FALSE;
/* check it's not just NUL padding */ /* 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) { if (buffer[hdr_sz + jump + i] != 0x00) {
found_data = TRUE; found_data = TRUE;
break; break;
@ -706,7 +699,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
} }
/* print all headers */ /* 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); hdr = g_ptr_array_index (priv->hdrs, i);
fu_rom_pci_print_header (hdr); fu_rom_pci_print_header (hdr);
} }
@ -755,7 +748,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
/* update checksum */ /* update checksum */
if (flags & FU_ROM_LOAD_FLAG_BLANK_PPID) if (flags & FU_ROM_LOAD_FLAG_BLANK_PPID)
fu_rom_find_and_blank_serial_numbers (rom); 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); hdr = g_ptr_array_index (priv->hdrs, i);
g_checksum_update (priv->checksum_wip, hdr->rom_data, hdr->rom_len); g_checksum_update (priv->checksum_wip, hdr->rom_data, hdr->rom_len);
} }

View File

@ -53,7 +53,6 @@ fu_test_get_filename (const gchar *filename)
static void static void
fu_rom_func (void) fu_rom_func (void)
{ {
guint i;
struct { struct {
FuRomKind kind; FuRomKind kind;
const gchar *fn; const gchar *fn;
@ -95,7 +94,7 @@ fu_rom_func (void)
{ FU_ROM_KIND_UNKNOWN, NULL, NULL, NULL, 0x0000, 0x0000 } { 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; gboolean ret;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autofree gchar *filename = NULL; g_autofree gchar *filename = NULL;

View File

@ -92,8 +92,6 @@ fu_util_add (GPtrArray *array,
const gchar *description, const gchar *description,
FuUtilPrivateCb callback) FuUtilPrivateCb callback)
{ {
guint i;
FuUtilItem *item;
g_auto(GStrv) names = NULL; g_auto(GStrv) names = NULL;
g_return_if_fail (name != NULL); g_return_if_fail (name != NULL);
@ -102,8 +100,8 @@ fu_util_add (GPtrArray *array,
/* add each one */ /* add each one */
names = g_strsplit (name, ",", -1); names = g_strsplit (name, ",", -1);
for (i = 0; names[i] != NULL; i++) { for (guint i = 0; names[i] != NULL; i++) {
item = g_new0 (FuUtilItem, 1); FuUtilItem *item = g_new0 (FuUtilItem, 1);
item->name = g_strdup (names[i]); item->name = g_strdup (names[i]);
if (i == 0) { if (i == 0) {
item->description = g_strdup (description); item->description = g_strdup (description);
@ -121,17 +119,14 @@ fu_util_add (GPtrArray *array,
static gchar * static gchar *
fu_util_get_descriptions (GPtrArray *array) fu_util_get_descriptions (GPtrArray *array)
{ {
guint i;
guint j;
guint len; guint len;
const guint max_len = 35; const guint max_len = 35;
FuUtilItem *item;
GString *string; GString *string;
/* print each command */ /* print each command */
string = g_string_new (""); string = g_string_new ("");
for (i = 0; i < array->len; i++) { for (guint i = 0; i < array->len; i++) {
item = g_ptr_array_index (array, i); FuUtilItem *item = g_ptr_array_index (array, i);
g_string_append (string, " "); g_string_append (string, " ");
g_string_append (string, item->name); g_string_append (string, item->name);
len = strlen (item->name) + 2; len = strlen (item->name) + 2;
@ -141,13 +136,13 @@ fu_util_get_descriptions (GPtrArray *array)
len += strlen (item->arguments) + 1; len += strlen (item->arguments) + 1;
} }
if (len < max_len) { 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_c (string, ' ');
g_string_append (string, item->description); g_string_append (string, item->description);
g_string_append_c (string, '\n'); g_string_append_c (string, '\n');
} else { } else {
g_string_append_c (string, '\n'); 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_c (string, ' ');
g_string_append (string, item->description); g_string_append (string, item->description);
g_string_append_c (string, '\n'); g_string_append_c (string, '\n');
@ -164,12 +159,9 @@ fu_util_get_descriptions (GPtrArray *array)
static gboolean static gboolean
fu_util_run (FuUtilPrivate *priv, const gchar *command, gchar **values, GError **error) fu_util_run (FuUtilPrivate *priv, const gchar *command, gchar **values, GError **error)
{ {
guint i;
FuUtilItem *item;
/* find command */ /* find command */
for (i = 0; i < priv->cmd_array->len; i++) { for (guint i = 0; i < priv->cmd_array->len; i++) {
item = g_ptr_array_index (priv->cmd_array, i); FuUtilItem *item = g_ptr_array_index (priv->cmd_array, i);
if (g_strcmp0 (item->name, command) == 0) if (g_strcmp0 (item->name, command) == 0)
return item->callback (priv, values, error); return item->callback (priv, values, error);
} }
@ -225,8 +217,6 @@ fu_util_status_changed_cb (FwupdClient *client,
static gboolean static gboolean
fu_util_get_devices (FuUtilPrivate *priv, gchar **values, GError **error) fu_util_get_devices (FuUtilPrivate *priv, gchar **values, GError **error)
{ {
FwupdResult *res;
guint i;
g_autoptr(GPtrArray) results = NULL; g_autoptr(GPtrArray) results = NULL;
/* get results from daemon */ /* get results from daemon */
@ -241,9 +231,9 @@ fu_util_get_devices (FuUtilPrivate *priv, gchar **values, GError **error)
return TRUE; return TRUE;
} }
for (i = 0; i < results->len; i++) { for (guint i = 0; i < results->len; i++) {
g_autofree gchar *tmp = NULL; 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); tmp = fwupd_result_to_string (res);
g_print ("%s\n", tmp); g_print ("%s\n", tmp);
} }
@ -302,7 +292,6 @@ fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error)
static gboolean static gboolean
fu_util_get_details (FuUtilPrivate *priv, gchar **values, GError **error) fu_util_get_details (FuUtilPrivate *priv, gchar **values, GError **error)
{ {
guint i;
g_autoptr(GPtrArray) array = NULL; g_autoptr(GPtrArray) array = NULL;
/* check args */ /* 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); array = fwupd_client_get_details_local (priv->client, values[0], NULL, error);
if (array == NULL) if (array == NULL)
return FALSE; 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); FwupdResult *res = g_ptr_array_index (array, i);
g_autofree gchar *tmp = NULL; g_autofree gchar *tmp = NULL;
tmp = fwupd_result_to_string (res); tmp = fwupd_result_to_string (res);
@ -356,7 +345,6 @@ fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
{ {
gint vercmp; gint vercmp;
guint cnt = 0; guint cnt = 0;
guint i;
g_autofree gchar *link = NULL; g_autofree gchar *link = NULL;
g_autoptr(GPtrArray) results = NULL; g_autoptr(GPtrArray) results = NULL;
g_autoptr(FuPending) pending = NULL; g_autoptr(FuPending) pending = NULL;
@ -399,9 +387,8 @@ fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
return FALSE; return FALSE;
/* apply each update */ /* apply each update */
for (i = 0; i < results->len; i++) { for (guint i = 0; i < results->len; i++) {
FwupdResult *res; FwupdResult *res = g_ptr_array_index (results, i);
res = g_ptr_array_index (results, i);
/* check not already done */ /* check not already done */
if (fwupd_result_get_update_state (res) != FWUPD_UPDATE_STATE_PENDING) 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 static gboolean
fu_util_dump_rom (FuUtilPrivate *priv, gchar **values, GError **error) fu_util_dump_rom (FuUtilPrivate *priv, gchar **values, GError **error)
{ {
guint i;
if (g_strv_length (values) == 0) { if (g_strv_length (values) == 0) {
g_set_error_literal (error, g_set_error_literal (error,
FWUPD_ERROR, FWUPD_ERROR,
@ -485,7 +470,7 @@ fu_util_dump_rom (FuUtilPrivate *priv, gchar **values, GError **error)
"Invalid arguments: expected 'filename.rom'"); "Invalid arguments: expected 'filename.rom'");
return FALSE; return FALSE;
} }
for (i = 0; values[i] != NULL; i++) { for (guint i = 0; values[i] != NULL; i++) {
g_autoptr(FuRom) rom = NULL; g_autoptr(FuRom) rom = NULL;
g_autoptr(GFile) file = NULL; g_autoptr(GFile) file = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
@ -513,7 +498,6 @@ fu_util_verify_update_internal (FuUtilPrivate *priv,
gchar **values, gchar **values,
GError **error) GError **error)
{ {
guint i;
g_autoptr(AsStore) store = NULL; g_autoptr(AsStore) store = NULL;
g_autoptr(GFile) xml_file = NULL; g_autoptr(GFile) xml_file = NULL;
@ -528,7 +512,7 @@ fu_util_verify_update_internal (FuUtilPrivate *priv,
/* add new values */ /* add new values */
as_store_set_api_version (store, 0.9); 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_autofree gchar *id = NULL;
g_autoptr(AsApp) app = NULL; g_autoptr(AsApp) app = NULL;
g_autoptr(AsChecksum) csum = NULL; g_autoptr(AsChecksum) csum = NULL;
@ -581,22 +565,19 @@ fu_util_verify_update_internal (FuUtilPrivate *priv,
static gboolean static gboolean
fu_util_verify_update_all (FuUtilPrivate *priv, const gchar *fn, GError **error) fu_util_verify_update_all (FuUtilPrivate *priv, const gchar *fn, GError **error)
{ {
GList *devices;
GList *l;
GUdevDevice *dev; GUdevDevice *dev;
const gchar *devclass[] = { "pci", NULL }; const gchar *devclass[] = { "pci", NULL };
const gchar *subsystems[] = { NULL }; const gchar *subsystems[] = { NULL };
guint i;
g_autoptr(GUdevClient) gudev_client = NULL; g_autoptr(GUdevClient) gudev_client = NULL;
g_autoptr(GPtrArray) roms = NULL; g_autoptr(GPtrArray) roms = NULL;
/* get all devices of class */ /* get all devices of class */
gudev_client = g_udev_client_new (subsystems); gudev_client = g_udev_client_new (subsystems);
roms = g_ptr_array_new_with_free_func (g_free); roms = g_ptr_array_new_with_free_func (g_free);
for (i = 0; devclass[i] != NULL; i++) { for (guint i = 0; devclass[i] != NULL; i++) {
devices = g_udev_client_query_by_subsystem (gudev_client, GList *devices = g_udev_client_query_by_subsystem (gudev_client,
devclass[i]); 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; g_autofree gchar *rom_fn = NULL;
dev = l->data; dev = l->data;
rom_fn = g_build_filename (g_udev_device_get_sysfs_path (dev), "rom", NULL); 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 static gboolean
fu_util_verify_all (FuUtilPrivate *priv, GError **error) fu_util_verify_all (FuUtilPrivate *priv, GError **error)
{ {
FwupdResult *res;
guint i;
g_autoptr(GPtrArray) results = NULL; g_autoptr(GPtrArray) results = NULL;
/* get devices from daemon */ /* get devices from daemon */
@ -815,9 +794,9 @@ fu_util_verify_all (FuUtilPrivate *priv, GError **error)
return FALSE; return FALSE;
/* get results */ /* get results */
for (i = 0; i < results->len; i++) { for (guint i = 0; i < results->len; i++) {
g_autoptr(GError) error_local = NULL; 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, if (!fwupd_client_verify (priv->client,
fwupd_result_get_device_id (res), fwupd_result_get_device_id (res),
NULL, NULL,
@ -865,8 +844,6 @@ fu_util_unlock (FuUtilPrivate *priv, gchar **values, GError **error)
static void static void
fu_util_print_data (const gchar *title, const gchar *msg) fu_util_print_data (const gchar *title, const gchar *msg)
{ {
guint i;
guint j;
guint title_len; guint title_len;
g_auto(GStrv) lines = NULL; g_auto(GStrv) lines = NULL;
@ -877,8 +854,8 @@ fu_util_print_data (const gchar *title, const gchar *msg)
/* pad */ /* pad */
title_len = strlen (title) + 1; title_len = strlen (title) + 1;
lines = g_strsplit (msg, "\n", -1); lines = g_strsplit (msg, "\n", -1);
for (j = 0; lines[j] != NULL; j++) { for (guint j = 0; lines[j] != NULL; j++) {
for (i = title_len; i < 25; i++) for (guint i = title_len; i < 25; i++)
g_print (" "); g_print (" ");
g_print ("%s\n", lines[j]); g_print ("%s\n", lines[j]);
title_len = 0; title_len = 0;
@ -902,19 +879,17 @@ _g_checksum_type_to_string (GChecksumType checksum_type)
static gboolean static gboolean
fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error) fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
{ {
FwupdResult *res;
GPtrArray *results = NULL; GPtrArray *results = NULL;
GPtrArray *guids; GPtrArray *guids;
GChecksumType checksum_type; GChecksumType checksum_type;
const gchar *tmp; const gchar *tmp;
guint i, j;
/* print any updates */ /* print any updates */
results = fwupd_client_get_updates (priv->client, NULL, error); results = fwupd_client_get_updates (priv->client, NULL, error);
if (results == NULL) if (results == NULL)
return FALSE; return FALSE;
for (i = 0; i < results->len; i++) { for (guint i = 0; i < results->len; i++) {
res = g_ptr_array_index (results, i); FwupdResult *res = g_ptr_array_index (results, i);
/* TRANSLATORS: first replacement is device name */ /* TRANSLATORS: first replacement is device name */
g_print (_("%s has firmware updates:"), fwupd_result_get_device_name (res)); 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 */ /* TRANSLATORS: a GUID for the hardware */
guids = fwupd_result_get_guids (res); 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); tmp = g_ptr_array_index (guids, j);
fu_util_print_data (_("GUID"), tmp); fu_util_print_data (_("GUID"), tmp);
} }
@ -1039,22 +1014,20 @@ fu_util_monitor (FuUtilPrivate *priv, gchar **values, GError **error)
static gboolean static gboolean
fu_util_update (FuUtilPrivate *priv, gchar **values, GError **error) fu_util_update (FuUtilPrivate *priv, gchar **values, GError **error)
{ {
FwupdResult *res;
GPtrArray *results = NULL; GPtrArray *results = NULL;
guint i;
/* apply any updates */ /* apply any updates */
results = fwupd_client_get_updates (priv->client, NULL, error); results = fwupd_client_get_updates (priv->client, NULL, error);
if (results == NULL) if (results == NULL)
return FALSE; return FALSE;
for (i = 0; i < results->len; i++) { for (guint i = 0; i < results->len; i++) {
GChecksumType checksum_type; GChecksumType checksum_type;
const gchar *checksum; const gchar *checksum;
const gchar *uri; const gchar *uri;
g_autofree gchar *basename = NULL; g_autofree gchar *basename = NULL;
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
res = g_ptr_array_index (results, i); FwupdResult *res = g_ptr_array_index (results, i);
/* download file */ /* download file */
checksum = fwupd_result_get_update_checksum (res); checksum = fwupd_result_get_update_checksum (res);