From 9032182e3cb93695eb4cd63b86bf2b27c17b906e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 14 Oct 2019 14:17:09 +0000 Subject: [PATCH 1/4] repo: [scan-build] Initialize a variable Another GLib error convention issue; but eh, we might as well be conservative and always initialize variables. --- src/libostree/ostree-repo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index b654aff2..e2998f73 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -4197,7 +4197,7 @@ ostree_repo_has_object (OstreeRepo *self, GCancellable *cancellable, GError **error) { - gboolean ret_have_object; + gboolean ret_have_object = FALSE; if (!_ostree_repo_has_loose_object (self, checksum, objtype, &ret_have_object, cancellable, error)) From f1fdd885aba2aec4155124c8d294096e230ead13 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 14 Oct 2019 14:20:44 +0000 Subject: [PATCH 2/4] sysroot: [scan-build]: Remove a dead assignment Clarify the conditionals here and remove a dead assignment. --- src/libostree/ostree-sysroot-deploy.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index c342d7e0..6507b2c5 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -753,15 +753,14 @@ prepare_deployment_etc (OstreeSysroot *sysroot, return FALSE; gboolean usretc_exists = (errno == 0); - if (etc_exists && usretc_exists) - return glnx_throw (error, "Tree contains both /etc and /usr/etc"); - else if (etc_exists) + if (etc_exists) { + if (usretc_exists) + return glnx_throw (error, "Tree contains both /etc and /usr/etc"); /* Compatibility hack */ if (!glnx_renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc", error)) return FALSE; usretc_exists = TRUE; - etc_exists = FALSE; } if (usretc_exists) From 51d9aa35a936c447c21bd930d3c1d999e20ec1a3 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 14 Oct 2019 14:22:12 +0000 Subject: [PATCH 3/4] sysroot: [scan-build] Remove a dead assignment Just quieting the scan. --- src/libostree/ostree-sysroot.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 2c0c0546..e17cc233 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -1671,10 +1671,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot, /* add it last if no crossover defined (or it's the first deployment in the sysroot) */ if (!added_new) - { - g_ptr_array_add (new_deployments, g_object_ref (new_deployment)); - added_new = TRUE; - } + g_ptr_array_add (new_deployments, g_object_ref (new_deployment)); OstreeSysrootWriteDeploymentsOpts write_opts = { .do_postclean = postclean }; if (!ostree_sysroot_write_deployments_with_options (sysroot, new_deployments, &write_opts, From 806206fac253a7bcb3e1bd7048d91da6c5dcb70c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 14 Oct 2019 14:24:18 +0000 Subject: [PATCH 4/4] repo: [scan-build]: Mark a variable used We're just using this to auto-free, quiet the static analysis. --- src/libostree/ostree-repo-commit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index 0aaebbdb..d057ea34 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -871,7 +871,10 @@ write_content_object (OstreeRepo *self, /* Give a null input if there's no content */ g_autoptr(GInputStream) null_input = NULL; if (!input) - null_input = input = g_memory_input_stream_new_from_data ("", 0, NULL); + { + null_input = input = g_memory_input_stream_new_from_data ("", 0, NULL); + (void) null_input; /* quiet static analysis */ + } checksum_input = ot_checksum_instream_new_with_start (input, G_CHECKSUM_SHA256, buf, len);