gunixmounts: Squash a static analyser false positive

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 <pwithnall@gnome.org>

Helps: #1767
This commit is contained in:
Philip Withnall 2024-04-10 00:13:01 +01:00
parent a1ff120a98
commit 672a33002e
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -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);