trivial: Fix a tiny memory leak in the Udev plugin

Also, fix some method prefixes to match the plugin name.
This commit is contained in:
Richard Hughes 2016-12-16 14:03:08 +00:00
parent a59777ad8d
commit 04042a10e8

View File

@ -32,8 +32,9 @@ struct FuPluginData {
GUdevClient *gudev_client; GUdevClient *gudev_client;
}; };
//FIXME: this needs to move to the plugin core
static gchar * static gchar *
fu_plugin_get_id (GUdevDevice *device) fu_plugin_udev_get_id (GUdevDevice *device)
{ {
gchar *id; gchar *id;
id = g_strdup_printf ("ro-%s", g_udev_device_get_sysfs_path (device)); id = g_strdup_printf ("ro-%s", g_udev_device_get_sysfs_path (device));
@ -109,9 +110,8 @@ fu_plugin_verify (FuPlugin *plugin,
} }
static void static void
fu_plugin_client_add (FuPlugin *plugin, GUdevDevice *device) fu_plugin_udev_add (FuPlugin *plugin, GUdevDevice *device)
{ {
FuDevice *dev;
const gchar *display_name; const gchar *display_name;
const gchar *guid; const gchar *guid;
const gchar *product; const gchar *product;
@ -122,6 +122,7 @@ fu_plugin_client_add (FuPlugin *plugin, GUdevDevice *device)
g_auto(GStrv) split = NULL; g_auto(GStrv) split = NULL;
g_autoptr(AsProfile) profile = as_profile_new (); g_autoptr(AsProfile) profile = as_profile_new ();
g_autoptr(AsProfileTask) ptask = NULL; g_autoptr(AsProfileTask) ptask = NULL;
g_autoptr(FuDevice) dev = NULL;
/* interesting device? */ /* interesting device? */
guid = g_udev_device_get_property (device, "FWUPD_GUID"); guid = g_udev_device_get_property (device, "FWUPD_GUID");
@ -134,7 +135,7 @@ fu_plugin_client_add (FuPlugin *plugin, GUdevDevice *device)
g_debug ("adding udev device: %s", g_udev_device_get_sysfs_path (device)); g_debug ("adding udev device: %s", g_udev_device_get_sysfs_path (device));
/* is already in database */ /* is already in database */
id = fu_plugin_get_id (device); id = fu_plugin_udev_get_id (device);
dev = fu_plugin_cache_lookup (plugin, id); dev = fu_plugin_cache_lookup (plugin, id);
if (dev != NULL) { if (dev != NULL) {
g_debug ("ignoring duplicate %s", id); g_debug ("ignoring duplicate %s", id);
@ -183,7 +184,7 @@ fu_plugin_client_add (FuPlugin *plugin, GUdevDevice *device)
} }
static void static void
fu_plugin_client_remove (FuPlugin *plugin, GUdevDevice *device) fu_plugin_udev_remove (FuPlugin *plugin, GUdevDevice *device)
{ {
FuDevice *dev; FuDevice *dev;
g_autofree gchar *id = NULL; g_autofree gchar *id = NULL;
@ -193,7 +194,7 @@ fu_plugin_client_remove (FuPlugin *plugin, GUdevDevice *device)
return; return;
/* already in database */ /* already in database */
id = fu_plugin_get_id (device); id = fu_plugin_udev_get_id (device);
dev = fu_plugin_cache_lookup (plugin, id); dev = fu_plugin_cache_lookup (plugin, id);
if (dev == NULL) if (dev == NULL)
return; return;
@ -201,17 +202,17 @@ fu_plugin_client_remove (FuPlugin *plugin, GUdevDevice *device)
} }
static void static void
fu_plugin_client_uevent_cb (GUdevClient *gudev_client, fu_plugin_udev_uevent_cb (GUdevClient *gudev_client,
const gchar *action, const gchar *action,
GUdevDevice *udev_device, GUdevDevice *udev_device,
FuPlugin *plugin) FuPlugin *plugin)
{ {
if (g_strcmp0 (action, "remove") == 0) { if (g_strcmp0 (action, "remove") == 0) {
fu_plugin_client_remove (plugin, udev_device); fu_plugin_udev_remove (plugin, udev_device);
return; return;
} }
if (g_strcmp0 (action, "add") == 0) { if (g_strcmp0 (action, "add") == 0) {
fu_plugin_client_add (plugin, udev_device); fu_plugin_udev_add (plugin, udev_device);
return; return;
} }
} }
@ -224,7 +225,7 @@ fu_plugin_init (FuPlugin *plugin)
data->gudev_client = g_udev_client_new (subsystems); data->gudev_client = g_udev_client_new (subsystems);
g_signal_connect (data->gudev_client, "uevent", g_signal_connect (data->gudev_client, "uevent",
G_CALLBACK (fu_plugin_client_uevent_cb), plugin); G_CALLBACK (fu_plugin_udev_uevent_cb), plugin);
} }
void void
@ -252,7 +253,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
devclass[i]); devclass[i]);
for (GList *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_plugin_client_add (plugin, udev_device); fu_plugin_udev_add (plugin, udev_device);
} }
g_list_foreach (devices, (GFunc) g_object_unref, NULL); g_list_foreach (devices, (GFunc) g_object_unref, NULL);
g_list_free (devices); g_list_free (devices);