From 672a33002e440943ed1a399576bd82da2aee8b06 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 10 Apr 2024 00:13:01 +0100 Subject: [PATCH] gunixmounts: Squash a static analyser false positive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scan-build thinks that there can be a `NULL` pointer dereference of `error` here because it doesn’t understand that the function return value and `GError` are related: when a valid return value is returned, the error is `NULL` and vice-versa. Try and make that clearer to the static analyser by checking whether the error is `NULL`, rather than the return value. Signed-off-by: Philip Withnall Helps: #1767 --- gio/gunixmounts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index c4b64b481..27185c8fc 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -2079,7 +2079,7 @@ mount_monitor_start (void) if (proc_mounts_channel == NULL) proc_mounts_channel = g_io_channel_new_file (mtab_path, "r", &error); - if (proc_mounts_channel == NULL) + if (error != NULL) { g_warning ("Error creating IO channel for %s: %s (%s, %d)", mtab_path, error->message, g_quark_to_string (error->domain), error->code);