From c26a48a9aa88c1179efd5dac9aeb9b96b71d259a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 16 Apr 2021 10:37:42 +0100 Subject: [PATCH] Fix various unused variables detected by scan-build scan-build has a lot of false positives for this codebase because it doesn't understand __attribute__((__cleanup__)) or GLib's GError convention, but it seems to have been right about these. Signed-off-by: Simon McVittie --- app/flatpak-builtins-repair.c | 3 --- app/flatpak-builtins-search.c | 2 -- app/flatpak-builtins-utils.c | 2 -- common/flatpak-dir.c | 15 +-------------- tests/testlibrary.c | 4 ---- 5 files changed, 1 insertion(+), 25 deletions(-) diff --git a/app/flatpak-builtins-repair.c b/app/flatpak-builtins-repair.c index 1c064e7c..14ec70c0 100644 --- a/app/flatpak-builtins-repair.c +++ b/app/flatpak-builtins-repair.c @@ -290,7 +290,6 @@ flatpak_builtin_repair (int argc, char **argv, GCancellable *cancellable, GError g_autoptr(GPtrArray) refs = NULL; FlatpakDir *dir = NULL; g_autoptr(GHashTable) all_refs = NULL; - g_autoptr(GHashTable) invalid_refs = NULL; g_autoptr(GHashTable) object_status_cache = NULL; g_autoptr(FlatpakTransaction) transaction = NULL; OstreeRepo *repo; @@ -343,8 +342,6 @@ flatpak_builtin_repair (int argc, char **argv, GCancellable *cancellable, GError object_status_cache = g_hash_table_new_full (ostree_hash_object_name, g_variant_equal, (GDestroyNotify) g_variant_unref, NULL); - invalid_refs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - /* Validate that the commit for each ref is available */ if (!ostree_repo_list_refs (repo, NULL, &all_refs, cancellable, error)) return FALSE; diff --git a/app/flatpak-builtins-search.c b/app/flatpak-builtins-search.c index 2ea0d8a7..d7f2a4c1 100644 --- a/app/flatpak-builtins-search.c +++ b/app/flatpak-builtins-search.c @@ -60,12 +60,10 @@ get_remote_stores (GPtrArray *dirs, const char *arch, GCancellable *cancellable) for (i = 0; i < dirs->len; ++i) { FlatpakDir *dir = g_ptr_array_index (dirs, i); - g_autofree char *install_path = NULL; g_auto(GStrv) remotes = NULL; flatpak_log_dir_access (dir); - install_path = g_file_get_path (flatpak_dir_get_path (dir)); remotes = flatpak_dir_list_enumerated_remotes (dir, cancellable, &error); if (error) { diff --git a/app/flatpak-builtins-utils.c b/app/flatpak-builtins-utils.c index 45b163ec..e3de1f8f 100644 --- a/app/flatpak-builtins-utils.c +++ b/app/flatpak-builtins-utils.c @@ -630,12 +630,10 @@ get_appstream_timestamp (FlatpakDir *dir, const char *arch) { g_autoptr(GFile) ts_file = NULL; - g_autofree char *ts_file_path = NULL; g_autofree char *subdir = NULL; subdir = g_strdup_printf ("appstream/%s/%s/.timestamp", remote, arch); ts_file = g_file_resolve_relative_path (flatpak_dir_get_path (dir), subdir); - ts_file_path = g_file_get_path (ts_file); return get_file_age (ts_file); } diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 0fe89455..6f2b55c4 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -5594,7 +5594,6 @@ flatpak_dir_pull_oci (FlatpakDir *self, g_autoptr(FlatpakOciRegistry) registry = NULL; g_autoptr(FlatpakOciVersioned) versioned = NULL; g_autoptr(FlatpakOciImage) image_config = NULL; - g_autofree char *full_ref = NULL; const char *oci_repository = NULL; const char *delta_url = NULL; g_autofree char *oci_digest = NULL; @@ -5644,8 +5643,6 @@ flatpak_dir_pull_oci (FlatpakDir *self, if (image_config == NULL) return FALSE; - full_ref = g_strdup_printf ("%s:%s", state->remote_name, ref); - if (repo == NULL) repo = self->repo; @@ -6616,7 +6613,6 @@ flatpak_dir_run_triggers (FlatpakDir *self, if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_REGULAR && g_str_has_suffix (name, ".trigger")) { - g_autoptr(GPtrArray) argv_array = NULL; /* We need to canonicalize the basedir, because if has a symlink somewhere the bind mount will be on the target of that, not at that exact path. */ @@ -6629,7 +6625,6 @@ flatpak_dir_run_triggers (FlatpakDir *self, bwrap = flatpak_bwrap_new (NULL); - argv_array = g_ptr_array_new_with_free_func (g_free); #ifndef DISABLE_SANDBOXED_TRIGGERS flatpak_bwrap_add_arg (bwrap, flatpak_get_bwrap ()); flatpak_bwrap_add_args (bwrap, @@ -6853,14 +6848,12 @@ rewrite_mime_xml (xmlDoc *doc) xmlNode *sub_node = NULL; xmlNode *next_sub_node = NULL; - xml_autofree xmlChar *mimetype = NULL; if (mime_node->type != XML_ELEMENT_NODE) continue; if (strcmp ((char *) mime_node->name, "mime-type") != 0) return FALSE; - mimetype = xmlGetProp (mime_node, (xmlChar *) "type"); for (sub_node = mime_node->children; sub_node; sub_node = next_sub_node) { next_sub_node = sub_node->next; @@ -11077,7 +11070,6 @@ flatpak_dir_remote_make_oci_summary (FlatpakDir *self, g_autoptr(GFile) index_cache = NULL; g_autofree char *index_uri = NULL; g_autoptr(GFile) summary_cache = NULL; - g_autofree char *self_name = NULL; g_autoptr(GError) local_error = NULL; g_autoptr(GMappedFile) mfile = NULL; g_autoptr(GBytes) cache_bytes = NULL; @@ -11104,8 +11096,6 @@ flatpak_dir_remote_make_oci_summary (FlatpakDir *self, } else { - self_name = flatpak_dir_get_name (self); - index_cache = flatpak_dir_update_oci_index (self, remote, &index_uri, cancellable, error); if (index_cache == NULL) return FALSE; @@ -12035,8 +12025,6 @@ _flatpak_dir_get_remote_state (FlatpakDir *self, const char *name = var_summary_index_subsummaries_entry_get_key (entry); VarSubsummaryRef subsummary = var_summary_index_subsummaries_entry_get_value (entry); gsize checksum_bytes_len; - const guchar *checksum_bytes; - g_autofree char *digest = NULL; const char *dash, *subsummary_arch; dash = strchr (name, '-'); @@ -12059,13 +12047,12 @@ _flatpak_dir_get_remote_state (FlatpakDir *self, } } - checksum_bytes = var_subsummary_peek_checksum (subsummary, &checksum_bytes_len); + var_subsummary_peek_checksum (subsummary, &checksum_bytes_len); if (G_UNLIKELY (checksum_bytes_len != OSTREE_SHA256_DIGEST_LEN)) { g_debug ("Invalid checksum for digested summary, not using cache"); continue; } - digest = ostree_checksum_from_bytes (checksum_bytes); g_hash_table_insert (state->index_ht, g_strdup (subsummary_arch), var_subsummary_to_owned_gvariant (subsummary, state->index)); } diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 292b1a94..aaa37a3d 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -1927,15 +1927,11 @@ test_list_updates (void) FlatpakInstalledRef *update_ref = NULL; g_autoptr(FlatpakInstalledRef) updated_ref = NULL; g_autofree gchar *app = NULL; - g_autofree gchar *runtime = NULL; gboolean res; app = g_strdup_printf ("app/org.test.Hello/%s/master", flatpak_get_default_arch ()); - runtime = g_strdup_printf ("runtime/org.test.Platform/%s/master", - flatpak_get_default_arch ()); - inst = flatpak_installation_new_user (NULL, &error); g_assert_no_error (error);