Avoid shadowing local variables

This should help with code readability.

Fixes https://github.com/ostreedev/ostree/issues/2194
This commit is contained in:
Phaedrus Leeds committed 2020-09-13 10:08:02 -07:00
1 parent 9c040c1a73
commit c4f26bfdc8
21 files changed
+93 -94

No files matched your search

+3 -3
View File
@@ -341,14 +341,14 @@ check_multi_info (OstreeFetcher *fetcher)
if (req->idx + 1 == req->mirrorlist->len)
{
g_autofree char *msg = g_strdup_printf ("Server returned HTTP %lu", response);
g_autofree char *response_msg = g_strdup_printf ("Server returned HTTP %lu", response);
g_task_return_new_error (task, G_IO_ERROR, giocode,
"%s", msg);
"%s", response_msg);
if (req->fetcher->remote_name &&
!((req->flags & OSTREE_FETCHER_REQUEST_OPTIONAL_CONTENT) > 0 &&
giocode == G_IO_ERROR_NOT_FOUND))
_ostree_fetcher_journal_failure (req->fetcher->remote_name,
eff_url, msg);
eff_url, response_msg);
}
else
@@ -91,14 +91,14 @@ parse_txt_record (const guint8 *txt,
/* TODO: Docs. Return value is only valid as long as @txt is. Reference: RFC 6763, §6. */
GHashTable *
_ostree_txt_records_parse (AvahiStringList *txt)
_ostree_txt_records_parse (AvahiStringList *txt_list)
{
AvahiStringList *l;
g_autoptr(GHashTable) out = NULL;
out = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_bytes_unref);
for (l = txt; l != NULL; l = avahi_string_list_get_next (l))
for (l = txt_list; l != NULL; l = avahi_string_list_get_next (l))
{
const guint8 *txt;
gsize txt_len;
+1 -1
View File
@@ -336,7 +336,6 @@ ostree_repo_finder_mount_resolve_async (OstreeRepoFinder *finde
g_autoptr(GHashTable) repo_to_refs = NULL; /* (element-type UriAndKeyring GHashTable) */
GHashTable *supported_ref_to_checksum; /* (element-type OstreeCollectionRef utf8) */
GHashTableIter iter;
UriAndKeyring *repo;
g_autoptr(GError) local_error = NULL;
mount_name = g_mount_get_name (mount);
@@ -525,6 +524,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
/* Aggregate the results. */
g_hash_table_iter_init (&iter, repo_to_refs);
UriAndKeyring *repo;
while (g_hash_table_iter_next (&iter, (gpointer *) &repo, (gpointer *) &supported_ref_to_checksum))
{
g_autoptr(OstreeRemote) remote = NULL;
+1 -1
View File
@@ -151,7 +151,6 @@ ostree_repo_finder_override_resolve_async (OstreeRepoFinder *fi
GHashTable *supported_ref_to_checksum; /* (element-type OstreeCollectionRef utf8) */
GHashTableIter iter;
const gchar *remote_uri;
OstreeRemote *remote;
task = g_task_new (finder, cancellable, callback, user_data);
g_task_set_source_tag (task, ostree_repo_finder_override_resolve_async);
@@ -242,6 +241,7 @@ ostree_repo_finder_override_resolve_async (OstreeRepoFinder *fi
/* Aggregate the results. */
g_hash_table_iter_init (&iter, repo_remote_to_refs);
OstreeRemote *remote;
while (g_hash_table_iter_next (&iter, (gpointer *) &remote, (gpointer *) &supported_ref_to_checksum))
g_ptr_array_add (results, ostree_repo_finder_result_new (remote, finder, priority, supported_ref_to_checksum, NULL, 0));
+3 -3
View File
@@ -1161,16 +1161,16 @@ write_directory_to_libarchive_recurse (OstreeRepo *self,
{
guint8 buf[8192];
g_autoptr(GInputStream) file_in = NULL;
g_autoptr(GFileInfo) file_info = NULL;
g_autoptr(GFileInfo) regular_file_info = NULL;
const char *checksum;
checksum = ostree_repo_file_get_checksum ((OstreeRepoFile*)path);
if (!ostree_repo_load_file (self, checksum, &file_in, &file_info, NULL,
if (!ostree_repo_load_file (self, checksum, &file_in, &regular_file_info, NULL,
cancellable, error))
goto out;
archive_entry_set_size (entry, g_file_info_get_size (file_info));
archive_entry_set_size (entry, g_file_info_get_size (regular_file_info));
if (archive_write_header (a, entry) != ARCHIVE_OK)
{
+7 -7
View File
@@ -1625,13 +1625,13 @@ scan_commit_object (OtPullData *pull_data,
}
if (pull_data->timestamp_check_from_rev)
{
g_autoptr(GVariant) commit = NULL;
g_autoptr(GVariant) timestamp_commit = NULL;
if (!ostree_repo_load_commit (pull_data->repo, pull_data->timestamp_check_from_rev,
&commit, NULL, error))
&timestamp_commit, NULL, error))
return glnx_prefix_error (error, "Reading %s for timestamp-check-from-rev",
pull_data->timestamp_check_from_rev);
guint64 ts = ostree_commit_get_timestamp (commit);
guint64 ts = ostree_commit_get_timestamp (timestamp_commit);
if (!_ostree_compare_timestamps (pull_data->timestamp_check_from_rev, ts, checksum, new_ts, error))
return FALSE;
}
@@ -3389,7 +3389,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
const char *url_override = NULL;
gboolean inherit_transaction = FALSE;
g_autoptr(GHashTable) updated_requested_refs_to_fetch = NULL; /* (element-type OstreeCollectionRef utf8) */
int i;
gsize i;
g_autofree char **opt_localcache_repos = NULL;
g_autoptr(GVariantIter) ref_keyring_map_iter = NULL;
g_autoptr(GVariant) summary_bytes_v = NULL;
@@ -3849,7 +3849,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
{
g_autoptr(GBytes) bytes_sig = NULL;
gsize i, n;
gsize n;
g_autoptr(GVariant) refs = NULL;
g_autoptr(GVariant) deltas = NULL;
g_autoptr(GVariant) additional_metadata = NULL;
@@ -5227,7 +5227,7 @@ find_remotes_process_refs (OstreeRepo *self,
static void
find_remotes_cb (GObject *obj,
GAsyncResult *result,
GAsyncResult *async_result,
gpointer user_data)
{
OstreeRepo *self;
@@ -5259,7 +5259,7 @@ find_remotes_cb (GObject *obj,
/* progress = data->progress; */
/* Finish finding the remotes. */
results = ostree_repo_finder_resolve_all_finish (result, &error);
results = ostree_repo_finder_resolve_all_finish (async_result, &error);
if (results == NULL)
{
+9 -9
View File
@@ -3782,14 +3782,14 @@ load_metadata_internal (OstreeRepo *self,
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (sha256);
*out_state = 0;
glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->repo_dir_fd, commitpartial_path, &fd, error))
glnx_autofd int commitpartial_fd = -1;
if (!ot_openat_ignore_enoent (self->repo_dir_fd, commitpartial_path, &commitpartial_fd, error))
return FALSE;
if (fd != -1)
if (commitpartial_fd != -1)
{
*out_state |= OSTREE_REPO_COMMIT_STATE_PARTIAL;
char reason;
if (read (fd, &reason, 1) == 1)
if (read (commitpartial_fd, &reason, 1) == 1)
{
if (reason == 'f')
*out_state |= OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL;
@@ -5831,19 +5831,19 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
collection_map = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
(GDestroyNotify) g_hash_table_unref);
const OstreeCollectionRef *ref;
const OstreeCollectionRef *c_ref;
const char *checksum;
while (g_hash_table_iter_next (&iter, (gpointer *) &ref, (gpointer *) &checksum))
while (g_hash_table_iter_next (&iter, (gpointer *) &c_ref, (gpointer *) &checksum))
{
GHashTable *ref_map = g_hash_table_lookup (collection_map, ref->collection_id);
GHashTable *ref_map = g_hash_table_lookup (collection_map, c_ref->collection_id);
if (ref_map == NULL)
{
ref_map = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
g_hash_table_insert (collection_map, ref->collection_id, ref_map);
g_hash_table_insert (collection_map, c_ref->collection_id, ref_map);
}
g_hash_table_insert (ref_map, ref->ref_name, (gpointer) checksum);
g_hash_table_insert (ref_map, c_ref->ref_name, (gpointer) checksum);
}
g_autoptr(GVariantBuilder) collection_refs_builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sa(s(taya{sv}))}"));
+11 -11
View File
@@ -348,7 +348,7 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
{
SoupURI *uri, fixed_base;
const char *end, *hash, *colon, *at, *path, *question;
const char *p, *hostend;
const char *c, *hostend;
gboolean remove_dot_segments = TRUE;
int len;
@@ -402,17 +402,17 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
}
/* Find scheme */
p = uri_string;
while (p < end && (g_ascii_isalpha (*p) ||
(p > uri_string && (g_ascii_isdigit (*p) ||
*p == '.' ||
*p == '+' ||
*p == '-'))))
p++;
c = uri_string;
while (c < end && (g_ascii_isalpha (*c) ||
(c > uri_string && (g_ascii_isdigit (*c) ||
*c == '.' ||
*c == '+' ||
*c == '-'))))
c++;
if (p > uri_string && *p == ':') {
uri->scheme = soup_uri_parse_scheme (uri_string, p - uri_string);
uri_string = p + 1;
if (c > uri_string && *c == ':') {
uri->scheme = soup_uri_parse_scheme (uri_string, c - uri_string);
uri_string = c + 1;
}
if (uri_string == end && !base && !uri->fragment) {
+4 -4
View File
@@ -1945,8 +1945,8 @@ install_deployment_kernel (OstreeSysroot *sysroot,
if (kernel_layout->devicetree_namever)
{
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_namever, NULL);
ostree_bootconfig_parser_set (bootconfig, "devicetree", boot_relpath);
g_autofree char * dt_boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_namever, NULL);
ostree_bootconfig_parser_set (bootconfig, "devicetree", dt_boot_relpath);
}
else if (kernel_layout->devicetree_srcpath)
{
@@ -1954,8 +1954,8 @@ install_deployment_kernel (OstreeSysroot *sysroot,
* want to point to a whole directory of device trees.
* See: https://github.com/ostreedev/ostree/issues/1900
*/
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_srcpath, NULL);
ostree_bootconfig_parser_set (bootconfig, "fdtdir", boot_relpath);
g_autofree char * dt_boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->devicetree_srcpath, NULL);
ostree_bootconfig_parser_set (bootconfig, "fdtdir", dt_boot_relpath);
}
/* Note this is parsed in ostree-impl-system-generator.c */