From 0781e12f45b4416ad37da143ab9fb5235cc8c283 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 18 Nov 2022 16:34:06 +0000 Subject: [PATCH 1/3] tests: Add additional assertions to gsubprocess test This should quell a scan-build warning about passing `NULL` to `strlen()`. Signed-off-by: Philip Withnall --- gio/tests/gsubprocess.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c index 036c2afad..515a11267 100644 --- a/gio/tests/gsubprocess.c +++ b/gio/tests/gsubprocess.c @@ -757,11 +757,15 @@ on_communicate_complete (GObject *proc, { if (data->is_utf8) { + g_assert_nonnull (stdout_str); stdout_data = (guint8*)stdout_str; stdout_len = strlen (stdout_str); } else - stdout_data = g_bytes_get_data (stdout_bytes, &stdout_len); + { + g_assert_nonnull (stdout_bytes); + stdout_data = g_bytes_get_data (stdout_bytes, &stdout_len); + } g_assert_cmpmem (stdout_data, stdout_len, "# hello world" LINEEND, 13 + strlen (LINEEND)); } From 146a0a001d2fb98a78f290459f56422301d8457f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 18 Nov 2022 16:36:47 +0000 Subject: [PATCH 2/3] gslice: Tag mem_error() as not returning because it aborts This should quell some scan-build warnings about code breaking after returning from mem_error() in a weird state. Signed-off-by: Philip Withnall --- glib/gslice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gslice.c b/glib/gslice.c index 36fa0841f..56f217d32 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -212,7 +212,7 @@ #endif /* special helpers to avoid gmessage.c dependency */ -static void mem_error (const char *format, ...) G_GNUC_PRINTF (1,2); +G_NORETURN static void mem_error (const char *format, ...) G_GNUC_PRINTF (1,2) G_ANALYZER_NORETURN; #define mem_assert(cond) do { if (G_LIKELY (cond)) ; else mem_error ("assertion failed: %s", #cond); } while (0) /* --- structures --- */ From e5771df6434beff21d233245e9181571d6b25d1c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 18 Nov 2022 17:00:42 +0000 Subject: [PATCH 3/3] gvariant: Add an assertion to clarify some tuple logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should quell a scan-build error about dereferencing `member_info` when it’s `NULL` at the end of the function, due to having zero iterations of the `for` loop. Signed-off-by: Philip Withnall --- glib/gvariant-serialiser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glib/gvariant-serialiser.c b/glib/gvariant-serialiser.c index d5970d2d1..6ebaec7d4 100644 --- a/glib/gvariant-serialiser.c +++ b/glib/gvariant-serialiser.c @@ -983,6 +983,10 @@ gvs_tuple_needed_size (GVariantTypeInfo *type_info, offset = 0; + /* We must go through at least one iteration below. If the tuple had no + * children, it would have a fixed size. */ + g_assert (n_children > 0); + for (i = 0; i < n_children; i++) { guint alignment;