mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
Merge pull request #1947 from cgwalters/more-scan-build-2
More scan build 2
This commit is contained in:
commit
1645416aac
@ -1588,7 +1588,6 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(_OstreeRepoAutoTransaction) txn = NULL;
|
||||
guint64 reserved_bytes = 0;
|
||||
|
||||
g_return_val_if_fail (self->in_transaction == FALSE, FALSE);
|
||||
@ -1596,7 +1595,8 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
|
||||
g_debug ("Preparing transaction in repository %p", self);
|
||||
|
||||
/* Set up to abort the transaction if we return early from this function. */
|
||||
txn = self;
|
||||
g_autoptr(_OstreeRepoAutoTransaction) txn = self;
|
||||
(void) txn; /* Add use to silence static analysis */
|
||||
|
||||
memset (&self->txn.stats, 0, sizeof (OstreeRepoTransactionStats));
|
||||
|
||||
@ -1652,7 +1652,7 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
|
||||
return FALSE;
|
||||
|
||||
/* Success: do not abort the transaction when returning. */
|
||||
txn = NULL;
|
||||
txn = NULL; (void) txn;
|
||||
|
||||
if (out_transaction_resume)
|
||||
*out_transaction_resume = ret_transaction_resume;
|
||||
|
@ -2181,7 +2181,6 @@ static void
|
||||
start_fetch (OtPullData *pull_data,
|
||||
FetchObjectData *fetch)
|
||||
{
|
||||
gboolean is_meta;
|
||||
g_autofree char *obj_subpath = NULL;
|
||||
guint64 *expected_max_size_p;
|
||||
guint64 expected_max_size;
|
||||
@ -2190,13 +2189,12 @@ start_fetch (OtPullData *pull_data,
|
||||
GPtrArray *mirrorlist = NULL;
|
||||
|
||||
ostree_object_name_deserialize (fetch->object, &expected_checksum, &objtype);
|
||||
is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
|
||||
|
||||
g_debug ("starting fetch of %s.%s%s", expected_checksum,
|
||||
ostree_object_type_to_string (objtype),
|
||||
fetch->is_detached_meta ? " (detached)" : "");
|
||||
|
||||
is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
|
||||
gboolean is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
|
||||
if (is_meta)
|
||||
pull_data->n_outstanding_metadata_fetches++;
|
||||
else
|
||||
|
@ -250,9 +250,8 @@ ot_gio_splice_get_checksum (GOutputStream *out,
|
||||
|
||||
guint8 digest[_OSTREE_SHA256_DIGEST_LEN];
|
||||
ot_checksum_get_digest (&checksum, digest, sizeof (digest));
|
||||
g_autofree guchar *ret_csum = g_malloc (sizeof (digest));
|
||||
memcpy (ret_csum, digest, sizeof (digest));
|
||||
ot_transfer_out_value (out_csum, &ret_csum);
|
||||
if (out_csum)
|
||||
*out_csum = g_memdup (digest, sizeof (digest));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1150,14 +1150,8 @@ ot_variant_builder_end (OtVariantBuilder *builder,
|
||||
GError **error)
|
||||
{
|
||||
OtVariantBuilderInfo *info = builder->head;
|
||||
gsize total_size;
|
||||
gsize offset_size;
|
||||
int i;
|
||||
g_autofree guchar *offset_table = NULL;
|
||||
gsize offset_table_size;
|
||||
gboolean add_offset_table = FALSE;
|
||||
gboolean reverse_offset_table = FALSE;
|
||||
guchar *p;
|
||||
|
||||
g_return_val_if_fail (info->n_children >= info->min_items,
|
||||
FALSE);
|
||||
@ -1188,15 +1182,14 @@ ot_variant_builder_end (OtVariantBuilder *builder,
|
||||
|
||||
if (add_offset_table)
|
||||
{
|
||||
total_size = gvs_calculate_total_size (info->offset, info->child_ends->len);
|
||||
offset_size = gvs_get_offset_size (total_size);
|
||||
|
||||
offset_table_size = total_size - info->offset;
|
||||
offset_table = g_malloc (offset_table_size);
|
||||
p = offset_table;
|
||||
const gsize total_size = gvs_calculate_total_size (info->offset, info->child_ends->len);
|
||||
const gsize offset_size = gvs_get_offset_size (total_size);
|
||||
const gsize offset_table_size = total_size - info->offset;
|
||||
g_autofree guchar *offset_table = g_malloc (offset_table_size);
|
||||
guchar *p = offset_table;
|
||||
if (reverse_offset_table)
|
||||
{
|
||||
for (i = info->child_ends->len - 1; i >= 0; i--)
|
||||
for (int i = info->child_ends->len - 1; i >= 0; i--)
|
||||
{
|
||||
gvs_write_unaligned_le (p, g_array_index (info->child_ends, guint64, i), offset_size);
|
||||
p += offset_size;
|
||||
@ -1204,7 +1197,7 @@ ot_variant_builder_end (OtVariantBuilder *builder,
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < info->child_ends->len; i++)
|
||||
for (int i = 0; i < info->child_ends->len; i++)
|
||||
{
|
||||
gvs_write_unaligned_le (p, g_array_index (info->child_ends, guint64, i), offset_size);
|
||||
p += offset_size;
|
||||
|
@ -145,7 +145,7 @@ ot_test_setup_sysroot (GCancellable *cancellable,
|
||||
|
||||
g_autoptr(GString) buf = g_string_new ("mutable-deployments");
|
||||
|
||||
gboolean can_relabel;
|
||||
gboolean can_relabel = FALSE;
|
||||
if (!ot_check_relabeling (&can_relabel, error))
|
||||
return FALSE;
|
||||
if (!can_relabel)
|
||||
|
@ -199,16 +199,15 @@ test_get_value_with_default_group_optional (void)
|
||||
static void
|
||||
test_copy_group (void)
|
||||
{
|
||||
g_auto(GStrv) keys = NULL;
|
||||
g_auto(GStrv) keys2 = NULL;
|
||||
gsize length, length2, ii;
|
||||
GKeyFile *tmp = g_key_file_new ();
|
||||
gsize length, length2;
|
||||
const char *section = "section";
|
||||
GLogLevelFlags always_fatal_mask;
|
||||
|
||||
/* Avoid that g_return_val_if_fail causes the test to fail. */
|
||||
always_fatal_mask = g_log_set_always_fatal (0);
|
||||
|
||||
g_autoptr(GKeyFile) tmp = g_key_file_new ();
|
||||
|
||||
g_assert_false (ot_keyfile_copy_group (NULL, tmp, section));
|
||||
g_assert_false (ot_keyfile_copy_group (g_keyfile, NULL, section));
|
||||
g_assert_false (ot_keyfile_copy_group (g_keyfile, tmp, NULL));
|
||||
@ -218,21 +217,17 @@ test_copy_group (void)
|
||||
|
||||
g_assert_true (ot_keyfile_copy_group (g_keyfile, tmp, section));
|
||||
|
||||
keys = g_key_file_get_keys (g_keyfile, section, &length, NULL);
|
||||
keys2 = g_key_file_get_keys (tmp, section, &length2, NULL);
|
||||
g_auto(GStrv) keys = g_key_file_get_keys (g_keyfile, section, &length, NULL);
|
||||
g_strfreev (g_key_file_get_keys (tmp, section, &length2, NULL));
|
||||
g_assert_cmpint(length, ==, length2);
|
||||
|
||||
for (ii = 0; ii < length; ii++)
|
||||
for (gsize ii = 0; ii < length; ii++)
|
||||
{
|
||||
g_autofree char *value = NULL;
|
||||
g_autofree char *value2 = NULL;
|
||||
|
||||
value = g_key_file_get_value (g_keyfile, section, keys[ii], NULL);
|
||||
value2 = g_key_file_get_value (g_keyfile, section, keys[ii], NULL);
|
||||
g_autofree char *value = g_key_file_get_value (g_keyfile, section, keys[ii], NULL);
|
||||
g_autofree char *value2 = g_key_file_get_value (g_keyfile, section, keys[ii], NULL);
|
||||
g_assert_cmpstr (value, ==, value2);
|
||||
}
|
||||
|
||||
g_key_file_free (tmp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user