aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gsr-stream-page.c
diff options
context:
space:
mode:
authorTrung Lê <8@tle.id.au>2026-06-10 10:04:30 +1000
committerTrung Lê <8@tle.id.au>2026-06-10 10:04:30 +1000
commitf6009527636f8a8017d5b9192efe96a1d03d2028 (patch)
treee9d1a229cb32e08534f10cbf0ae489840add73ac /src/gsr-stream-page.c
parent76ff689850c160e7eca27ee51852dcf17cc1938a (diff)
ci: adopt gobject-linter as a blocking static-analysis gate
Add gobject-linter (github.com/bilelmoussaoui/gobject-linter) to CI to catch GObject/GLib correctness and idiom issues. Config (gobject-linter.toml): - min_glib_version = 2.80 (libadwaita >= 1.8) - default_level = error: every enabled rule blocks CI - type_style ignored: the project deliberately uses plain C scalar types - untranslated_string ignored: app is not internationalized yet - use_auto_cleanup downgraded to warn: it mis-fires on floating GVariant references (consumed by g_variant_new_tuple/builders) and on objects kept alive past the function (the GlobalShortcuts GDBusProxy); converting those to g_autoptr would over-unref and crash, so it advises rather than blocks Workflow (.github/workflows/gobject-linter.yml): runs the official container image on push/PR, uploads SARIF to code scanning (non-fatal for fork PRs), and fails the build on any error-level finding. Code is brought to a green baseline by applying the auto-fixable findings: - strcmp -> g_strcmp0 (NULL-safe) - manual g_free/g_strdup -> g_set_str - manual source removal -> g_clear_handle_id / g_clear_object / g_clear_pointer - g_string_free(.., FALSE) -> g_string_free_and_steal - g_idle_add one-shot -> g_idle_add_once (id now stored and cleared in finalize, also closing a latent use-after-free if the window is finalized first) - include ordering and #pragma once The 37 remaining use_auto_cleanup findings are reported as warnings for incremental manual review.
Diffstat (limited to 'src/gsr-stream-page.c')
-rw-r--r--src/gsr-stream-page.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/gsr-stream-page.c b/src/gsr-stream-page.c
index e3ec495..989927b 100644
--- a/src/gsr-stream-page.c
+++ b/src/gsr-stream-page.c
@@ -1,9 +1,12 @@
#include "gsr-stream-page.h"
+
+#include <time.h>
+
+#include "gsr-window.h"
+
#ifdef HAVE_X11
#include "gsr-shortcut-accel-dialog.h"
#endif
-#include "gsr-window.h"
-#include <time.h>
/* ═══════════════════════════════════════════════════════════════════
* GsrStreamPage — "Stream" tab
@@ -185,8 +188,7 @@ on_x11_start_stop_shortcut_set(GsrShortcutAccelDialog *dialog,
GsrStreamPage *self = GSR_STREAM_PAGE(user_data);
const char *accel = gsr_shortcut_accel_dialog_get_accelerator(dialog);
- g_free(self->x11_start_stop_accel);
- self->x11_start_stop_accel = g_strdup(accel);
+ g_set_str(&self->x11_start_stop_accel, accel);
if (self->x11_start_stop_label)
gtk_shortcut_label_set_accelerator(self->x11_start_stop_label,
@@ -415,10 +417,7 @@ gsr_stream_page_finalize(GObject *object)
{
GsrStreamPage *self = GSR_STREAM_PAGE(object);
- if (self->timer_source_id) {
- g_source_remove(self->timer_source_id);
- self->timer_source_id = 0;
- }
+ g_clear_handle_id(&self->timer_source_id, g_source_remove);
#ifdef HAVE_X11
g_free(self->x11_start_stop_accel);
@@ -571,24 +570,16 @@ gsr_stream_page_read_config(GsrStreamPage *self, GsrConfig *config)
{
GsrStreamingConfig *s = &config->streaming_config;
- g_free(s->streaming_service);
- s->streaming_service = g_strdup(service_index_to_string(
+ g_set_str(&s->streaming_service, service_index_to_string(
adw_combo_row_get_selected(self->service_row)));
- g_free(s->twitch_stream_key);
- s->twitch_stream_key = g_strdup(
- gtk_editable_get_text(GTK_EDITABLE(self->twitch_key_row)));
+ g_set_str(&s->twitch_stream_key, gtk_editable_get_text(GTK_EDITABLE(self->twitch_key_row)));
- g_free(s->youtube_stream_key);
- s->youtube_stream_key = g_strdup(
- gtk_editable_get_text(GTK_EDITABLE(self->youtube_key_row)));
+ g_set_str(&s->youtube_stream_key, gtk_editable_get_text(GTK_EDITABLE(self->youtube_key_row)));
- g_free(s->custom_url);
- s->custom_url = g_strdup(
- gtk_editable_get_text(GTK_EDITABLE(self->custom_url_row)));
+ g_set_str(&s->custom_url, gtk_editable_get_text(GTK_EDITABLE(self->custom_url_row)));
- g_free(s->custom_container);
- s->custom_container = g_strdup(stream_container_display_to_id(
+ g_set_str(&s->custom_container, stream_container_display_to_id(
combo_row_get_selected_string(self->container_row)));
/* Hotkeys */
@@ -618,10 +609,7 @@ gsr_stream_page_set_active(GsrStreamPage *self, gboolean active)
/* Reset internal state (handles external stop via handle_child_death) */
self->is_active = FALSE;
- if (self->timer_source_id) {
- g_source_remove(self->timer_source_id);
- self->timer_source_id = 0;
- }
+ g_clear_handle_id(&self->timer_source_id, g_source_remove);
}
}