Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor fixes and maintenance #789

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libvalent/device/valent-device-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,6 @@ valent_device_manager_save_state (ValentDeviceManager *self)

g_assert (VALENT_IS_DEVICE_MANAGER (self));

generator = g_object_new (JSON_TYPE_GENERATOR,
"pretty", TRUE,
"root", self->state,
NULL);

for (unsigned int i = 0, len = self->devices->len; i < len; i++)
{
ValentDevice *device = g_ptr_array_index (self->devices, i);
Expand All @@ -629,6 +624,11 @@ valent_device_manager_save_state (ValentDeviceManager *self)
}
}

generator = g_object_new (JSON_TYPE_GENERATOR,
"pretty", TRUE,
"root", self->state,
NULL);

file = valent_context_get_cache_file (self->context, "devices.json");
if (!json_generator_to_file (generator, g_file_peek_path (file), &error))
g_warning ("%s(): %s", G_STRFUNC, error->message);
Expand Down
11 changes: 6 additions & 5 deletions src/plugins/lan/valent-lan-channel-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ on_channel_destroyed (ValentLanChannelService *self,
g_assert (VALENT_IS_LAN_CHANNEL_SERVICE (self));
g_assert (VALENT_IS_LAN_CHANNEL (channel));

valent_object_lock (VALENT_OBJECT (self));
certificate = valent_channel_get_certificate (VALENT_CHANNEL (channel));
device_id = valent_certificate_get_common_name (certificate);

valent_object_lock (VALENT_OBJECT (self));
g_hash_table_remove (self->channels, device_id);
valent_object_unlock (VALENT_OBJECT (self));
}
Expand Down Expand Up @@ -130,7 +129,7 @@ valent_lan_channel_service_verify_channel (ValentLanChannelService *self,

valent_object_lock (VALENT_OBJECT (self));
channel = g_hash_table_lookup (self->channels, device_id);
if (channel != NULL)
if (channel != NULL && !valent_object_in_destruction (VALENT_OBJECT (channel)))
certificate = valent_channel_get_peer_certificate (VALENT_CHANNEL (channel));
valent_object_unlock (VALENT_OBJECT (self));

Expand Down Expand Up @@ -896,7 +895,9 @@ valent_lan_channel_service_channel (ValentChannelService *service,
device_id = valent_certificate_get_common_name (peer_certificate);

valent_object_lock (VALENT_OBJECT (service));
g_hash_table_replace (self->channels, g_strdup (device_id), channel);
g_hash_table_replace (self->channels,
g_strdup (device_id),
g_object_ref (channel));
g_signal_connect_object (channel,
"destroy",
G_CALLBACK (on_channel_destroyed),
Expand Down Expand Up @@ -1160,7 +1161,7 @@ valent_lan_channel_service_init (ValentLanChannelService *self)
self->channels = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
NULL);
g_object_unref);
self->monitor = g_network_monitor_get_default ();
}

35 changes: 7 additions & 28 deletions tests/extra/cppcheck.supp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,10 @@ leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:787
leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:806
leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:810

# src/plugins/battery/
memleak:src/plugins/battery/valent-battery-gadget.c

# src/plugins/pipewire/
memleak:src/plugins/pipewire/valent-pipewire-mixer.c:698

# src/plugins/sms/
leakNoVarFunctionCall:src/plugins/sms/valent-conversation-page.c:568
leakNoVarFunctionCall:src/plugins/sms/valent-conversation-page.c:573
# tests/plugins/bluez/
memleak:tests/plugins/bluez/test-bluez-plugin.c:183

# tests/plugins/connectivity_report/
memleak:src/plugins/connectivity_report/valent-connectivity_report-gadget.c:206
leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:258
leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:260
leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:262
Expand All @@ -40,25 +32,12 @@ leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report
leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:279
leakNoVarFunctionCall:src/plugins/connectivity_report/valent-connectivity_report-plugin.c:281

# tests/plugins/gnome/
leakNoVarFunctionCall:src/plugins/gnome/valent-mutter-input.c:174

# tests/plugins/bluez/
memleak:tests/plugins/bluez/test-bluez-plugin.c:183

# tests/plugins/fdo/
leakNoVarFunctionCall:tests/plugins/fdo/test-fdo-notifications.c:122
leakNoVarFunctionCall:tests/plugins/fdo/test-fdo-session.c:65
memleak:tests/plugins/fdo/test-fdo-notifications.c:164

# tests/plugins/gtk/
leakNoVarFunctionCall:tests/plugins/gtk/test-gtk-notifications.c:115
leakNoVarFunctionCall:tests/plugins/gtk/test-gtk-notifications.c:117
leakNoVarFunctionCall:tests/plugins/gtk/test-gtk-notifications.c:119

# tests/plugins/lan/
memleak:src/plugins/lan/valent-lan-channel-service.c:544
memleak:src/plugins/lan/valent-lan-channel-service.c:559
memleak:src/plugins/lan/valent-lan-channel-service.c:543
memleak:src/plugins/lan/valent-lan-channel-service.c:558
memleak:src/plugins/lan/valent-lan-dnssd.c:84
memleak:src/plugins/lan/valent-lan-dnssd.c:94

# src/plugins/pipewire/
memleak:src/plugins/pipewire/valent-pipewire-mixer.c:698

Loading