From a8dc90b02fbbd7b951be59704d4c5969463ab8f2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 16 Oct 2019 13:44:46 +0000 Subject: [PATCH] tree-wide: [scan-build]: Add some asserts that pointers are non-NULL More "scan-build doesn't understand GError and our out-param conventions" AKA "these errors would be impossible with Rust's sum type Result<> approach". --- src/libostree/ostree-sysroot-cleanup.c | 1 + src/libostree/ostree-sysroot.c | 1 + src/ostree/ot-builtin-fsck.c | 1 + src/ostree/ot-dump.c | 5 ++++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libostree/ostree-sysroot-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c index 7a352e6b..ef95d13c 100644 --- a/src/libostree/ostree-sysroot-cleanup.c +++ b/src/libostree/ostree-sysroot-cleanup.c @@ -313,6 +313,7 @@ cleanup_old_deployments (OstreeSysroot *self, if (!list_all_deployment_directories (self, &all_deployment_dirs, cancellable, error)) return FALSE; + g_assert (all_deployment_dirs); /* Pacify static analysis */ for (guint i = 0; i < all_deployment_dirs->len; i++) { OstreeDeployment *deployment = all_deployment_dirs->pdata[i]; diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index e17cc233..1c9dbf37 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -945,6 +945,7 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self, g_autoptr(GPtrArray) deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); + g_assert (boot_loader_configs); /* Pacify static analysis */ for (guint i = 0; i < boot_loader_configs->len; i++) { OstreeBootconfigParser *config = boot_loader_configs->pdata[i]; diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c index 5ad3bf38..dea03af4 100644 --- a/src/ostree/ot-builtin-fsck.c +++ b/src/ostree/ot-builtin-fsck.c @@ -434,6 +434,7 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation, if (opt_add_tombstones) { guint i; + g_assert (tombstones); /* Pacify static analysis */ if (tombstones->len) { if (!ot_enable_tombstone_commits (repo, error)) diff --git a/src/ostree/ot-dump.c b/src/ostree/ot-dump.c index 1ef63740..38f3730b 100644 --- a/src/ostree/ot-dump.c +++ b/src/ostree/ot-dump.c @@ -125,7 +125,10 @@ dump_commit (GVariant *variant, timestamp = GUINT64_FROM_BE (timestamp); str = format_timestamp (timestamp, &local_error); if (!str) - errx (1, "Failed to read commit: %s", local_error->message); + { + g_assert (local_error); /* Pacify static analysis */ + errx (1, "Failed to read commit: %s", local_error->message); + } g_autofree char *contents = ostree_commit_get_content_checksum (variant) ?: ""; g_print ("ContentChecksum: %s\n", contents); g_print ("Date: %s\n", str);