diff options
author | Maciej S. Szmigiero <maciej.szmigiero@oracle.com> | 2023-01-05 23:11:30 +0100 |
---|---|---|
committer | Maciej S. Szmigiero <maciej.szmigiero@oracle.com> | 2023-01-05 23:29:13 +0100 |
commit | b46f8b6570f3304fca00f844403f1f4209e7ba58 (patch) | |
tree | cb096ad8fe57dd13ac7c8b407369702fc0e24793 | |
parent | becfa5837cfafa064219a5ab2c2a4eaf35b24c0b (diff) | |
download | geoclue-b46f8b6570f3304fca00f844403f1f4209e7ba58.tar.gz |
Remove manual GError memory management
-rw-r--r-- | demo/agent.c | 3 | ||||
-rw-r--r-- | demo/gclue-service-agent.c | 5 | ||||
-rw-r--r-- | src/gclue-3g.c | 3 | ||||
-rw-r--r-- | src/gclue-cdma.c | 3 | ||||
-rw-r--r-- | src/gclue-compass.c | 3 | ||||
-rw-r--r-- | src/gclue-config.c | 20 | ||||
-rw-r--r-- | src/gclue-main.c | 5 | ||||
-rw-r--r-- | src/gclue-modem-gps.c | 6 | ||||
-rw-r--r-- | src/gclue-service-client.c | 3 | ||||
-rw-r--r-- | src/gclue-service-manager.c | 12 |
10 files changed, 22 insertions, 41 deletions
diff --git a/demo/agent.c b/demo/agent.c index 8e2a3ef..b55fc05 100644 --- a/demo/agent.c +++ b/demo/agent.c @@ -51,14 +51,13 @@ on_get_bus_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { - GError *error = NULL; + g_autoptr(GError) error = NULL; GDBusConnection *connection; connection = g_bus_get_finish (res, &error); if (connection == NULL) { g_critical ("Failed to get connection to system bus: %s", error->message); - g_error_free (error); exit (-2); } diff --git a/demo/gclue-service-agent.c b/demo/gclue-service-agent.c index ac96795..0c5c08d 100644 --- a/demo/gclue-service-agent.c +++ b/demo/gclue-service-agent.c @@ -192,16 +192,15 @@ on_manager_proxy_ready (GObject *source_object, gpointer user_data) { GClueServiceAgent *agent; - GError *error = NULL; - agent = GCLUE_SERVICE_AGENT (user_data); + g_autoptr(GError) error = NULL; + agent = GCLUE_SERVICE_AGENT (user_data); agent->priv->manager_proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (agent->priv->manager_proxy == NULL) { g_critical ("Failed to create proxy to %s: %s", MANAGER_PATH, error->message); - g_error_free (error); return; } diff --git a/src/gclue-3g.c b/src/gclue-3g.c index 7521551..225b706 100644 --- a/src/gclue-3g.c +++ b/src/gclue-3g.c @@ -406,7 +406,7 @@ gclue_3g_stop (GClueLocationSource *source) GClue3G *g3g = GCLUE_3G (source); GClue3GPrivate *priv = g3g->priv; GClueLocationSourceClass *base_class; - GError *error = NULL; + g_autoptr(GError) error = NULL; GClueLocationSourceStopResult base_result; g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE); @@ -436,7 +436,6 @@ gclue_3g_stop (GClueLocationSource *source) &error)) { g_warning ("Failed to disable 3GPP: %s", error->message); - g_error_free (error); } gclue_mozilla_set_tower (priv->mozilla, NULL); diff --git a/src/gclue-cdma.c b/src/gclue-cdma.c index d6c0561..75bd5a0 100644 --- a/src/gclue-cdma.c +++ b/src/gclue-cdma.c @@ -243,7 +243,7 @@ gclue_cdma_stop (GClueLocationSource *source) { GClueCDMAPrivate *priv = GCLUE_CDMA (source)->priv; GClueLocationSourceClass *base_class; - GError *error = NULL; + g_autoptr(GError) error = NULL; GClueLocationSourceStopResult base_result; g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE); @@ -263,7 +263,6 @@ gclue_cdma_stop (GClueLocationSource *source) &error)) { g_warning ("Failed to disable CDMA: %s", error->message); - g_error_free (error); } return base_result; diff --git a/src/gclue-compass.c b/src/gclue-compass.c index f5fc594..a320f6a 100644 --- a/src/gclue-compass.c +++ b/src/gclue-compass.c @@ -79,14 +79,13 @@ gclue_compass_finalize (GObject *object) g_clear_object (&priv->cancellable); if (priv->proxy != NULL) { - GError *error = NULL; + g_autoptr(GError) error = NULL; if (!compass_call_release_compass_sync (priv->proxy, NULL, &error)) { g_warning ("Failed to release compass: %s", error->message); - g_error_free (error); } g_debug ("IIO compass released"); g_object_unref (priv->proxy); diff --git a/src/gclue-config.c b/src/gclue-config.c index 0819bd0..c6eb05e 100644 --- a/src/gclue-config.c +++ b/src/gclue-config.c @@ -105,7 +105,7 @@ static void load_agent_config (GClueConfig *config) { GClueConfigPrivate *priv = config->priv; - GError *error = NULL; + g_autoptr(GError) error = NULL; priv->agents = g_key_file_get_string_list (priv->key_file, "agent", @@ -115,7 +115,6 @@ load_agent_config (GClueConfig *config) if (error != NULL) { g_critical ("Failed to read 'agent/whitelist' key: %s", error->message); - g_error_free (error); } } @@ -139,7 +138,7 @@ load_app_configs (GClueConfig *config) gsize num_users = 0, j; gboolean allowed, system; gboolean ignore = FALSE; - GError *error = NULL; + g_autoptr(GError) error = NULL; for (j = 0; known_groups[j] != NULL; j++) if (strcmp (groups[i], known_groups[j]) == 0) { @@ -187,7 +186,6 @@ error_out: g_warning ("Failed to load configuration for app '%s': %s", groups[i], error->message); - g_error_free (error); } g_strfreev (groups); @@ -198,7 +196,7 @@ load_enable_source_config (GClueConfig *config, const char *source_name) { GClueConfigPrivate *priv = config->priv; - GError *error = NULL; + g_autoptr(GError) error = NULL; gboolean enable; enable = g_key_file_get_boolean (priv->key_file, @@ -210,7 +208,6 @@ load_enable_source_config (GClueConfig *config, " %s", source_name, error->message); - g_error_free (error); /* Source should be enabled by default */ return TRUE; @@ -227,7 +224,7 @@ static void load_wifi_config (GClueConfig *config) { GClueConfigPrivate *priv = config->priv; - GError *error = NULL; + g_autoptr(GError) error = NULL; priv->enable_wifi_source = load_enable_source_config (config, "wifi"); @@ -249,7 +246,6 @@ load_wifi_config (GClueConfig *config) if (error != NULL) { g_debug ("Failed to get config \"wifi/submit-data\": %s", error->message); - g_error_free (error); return; } @@ -272,7 +268,6 @@ load_wifi_config (GClueConfig *config) if (error != NULL) { g_debug ("Using the default submission nick: %s", error->message); - g_error_free (error); priv->wifi_submit_nick = g_strdup (DEFAULT_WIFI_SUBMIT_NICK); } } @@ -301,7 +296,8 @@ load_modem_gps_config (GClueConfig *config) static void load_network_nmea_config (GClueConfig *config) { - GError *error = NULL; + g_autoptr(GError) error = NULL; + config->priv->enable_nmea_source = load_enable_source_config (config, "network-nmea"); if (!config->priv->enable_nmea_source) @@ -312,7 +308,6 @@ load_network_nmea_config (GClueConfig *config) &error); if (error != NULL) { g_debug ("`nmea-socket` configuration not set."); - g_clear_error (&error); } } @@ -326,7 +321,7 @@ load_compass_config (GClueConfig *config) static void gclue_config_init (GClueConfig *config) { - GError *error = NULL; + g_autoptr(GError) error = NULL; config->priv = gclue_config_get_instance_private(config); config->priv->key_file = g_key_file_new (); @@ -337,7 +332,6 @@ gclue_config_init (GClueConfig *config) if (error != NULL) { g_critical ("Failed to load configuration file '%s': %s", CONFIG_FILE_PATH, error->message); - g_error_free (error); return; } diff --git a/src/gclue-main.c b/src/gclue-main.c index d14cadc..a44443c 100644 --- a/src/gclue-main.c +++ b/src/gclue-main.c @@ -123,12 +123,11 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { - GError *error = NULL; + g_autoptr(GError) error = NULL; manager = gclue_service_manager_new (connection, &error); if (manager == NULL) { g_critical ("Failed to register server: %s", error->message); - g_error_free (error); exit (-2); } @@ -159,7 +158,7 @@ int main (int argc, char **argv) { guint owner_id; - GError *error = NULL; + g_autoptr(GError) error = NULL; GOptionContext *context; GClueConfig *config; diff --git a/src/gclue-modem-gps.c b/src/gclue-modem-gps.c index fba6bcb..df2a5ab 100644 --- a/src/gclue-modem-gps.c +++ b/src/gclue-modem-gps.c @@ -216,7 +216,7 @@ on_fix_gps (GClueModem *modem, GClueLocationSource *source = GCLUE_LOCATION_SOURCE (user_data); GClueLocation *prev_location; g_autoptr(GClueLocation) location = NULL; - GError *error = NULL; + g_autoptr(GError) error = NULL; prev_location = gclue_location_source_get_location (source); location = gclue_location_create_from_nmeas (nmeas, @@ -225,7 +225,6 @@ on_fix_gps (GClueModem *modem, if (error != NULL) { g_warning ("Error: %s", error->message); - g_clear_error (&error); return; } @@ -269,7 +268,7 @@ gclue_modem_gps_stop (GClueLocationSource *source) { GClueModemGPSPrivate *priv = GCLUE_MODEM_GPS (source)->priv; GClueLocationSourceClass *base_class; - GError *error = NULL; + g_autoptr(GError) error = NULL; GClueLocationSourceStopResult base_result; g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE); @@ -289,7 +288,6 @@ gclue_modem_gps_stop (GClueLocationSource *source) &error)) { g_warning ("Failed to disable GPS: %s", error->message); - g_error_free (error); } return base_result; diff --git a/src/gclue-service-client.c b/src/gclue-service-client.c index 768c1e6..cd56179 100644 --- a/src/gclue-service-client.c +++ b/src/gclue-service-client.c @@ -203,7 +203,7 @@ on_locator_location_changed (GObject *gobject, GClueLocation *new_location; char *path = NULL; const char *prev_path; - GError *error = NULL; + g_autoptr(GError) error = NULL; new_location = gclue_location_source_get_location (locator); if (new_location == NULL) @@ -249,7 +249,6 @@ on_locator_location_changed (GObject *gobject, error_out: g_warning ("Failed to update location info: %s", error->message); - g_error_free (error); out: g_free (path); } diff --git a/src/gclue-service-manager.c b/src/gclue-service-manager.c index e038b7c..9f44a56 100644 --- a/src/gclue-service-manager.c +++ b/src/gclue-service-manager.c @@ -180,7 +180,7 @@ complete_get_client (OnClientInfoNewReadyData *data) GClueServiceClient *client; GClueClientInfo *info = data->client_info; GClueAgent *agent_proxy = NULL; - GError *error = NULL; + g_autoptr(GError) error = NULL; char *path; guint32 user_id; @@ -255,7 +255,6 @@ error_out: G_DBUS_ERROR_FAILED, error->message); out: - g_clear_error (&error); g_clear_object (&info); on_client_info_new_ready_data_free (data); g_free (path); @@ -296,7 +295,7 @@ on_client_info_new_ready (GObject *source_object, GClueServiceManagerPrivate *priv = GCLUE_SERVICE_MANAGER (data->manager)->priv; GClueClientInfo *info = NULL; GClueAgent *agent_proxy; - GError *error = NULL; + g_autoptr(GError) error = NULL; guint32 user_id; info = gclue_client_info_new_finish (res, &error); @@ -305,7 +304,6 @@ on_client_info_new_ready (GObject *source_object, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, error->message); - g_error_free (error); on_client_info_new_ready_data_free (data); return; @@ -460,7 +458,7 @@ on_agent_proxy_ready (GObject *source_object, GClueServiceManagerPrivate *priv = GCLUE_SERVICE_MANAGER (data->manager)->priv; guint32 user_id; GClueAgent *agent; - GError *error = NULL; + g_autoptr(GError) error = NULL; GList *l; agent = gclue_agent_proxy_new_for_bus_finish (res, &error); @@ -499,7 +497,6 @@ error_out: G_DBUS_ERROR_FAILED, error->message); out: - g_clear_error (&error); add_agent_data_free (data); } @@ -511,7 +508,7 @@ on_agent_info_new_ready (GObject *source_object, gpointer user_data) { AddAgentData *data = (AddAgentData *) user_data; - GError *error = NULL; + g_autoptr(GError) error = NULL; GClueConfig *config; const char *xdg_id; @@ -521,7 +518,6 @@ on_agent_info_new_ready (GObject *source_object, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, error->message); - g_error_free (error); add_agent_data_free (data); return; |