summaryrefslogtreecommitdiff
path: root/src/libotutil
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2019-10-18 14:56:51 +0000
committerColin Walters <walters@verbum.org>2019-10-18 15:07:39 +0000
commit57bb06419a3e4c78c6165b755004ff40b685e4db (patch)
treed6fb0899a1536ae0dbc11ac62851343c2bac0e89 /src/libotutil
parent0a808ffe20ebae0550399101b42af0bcc5bf7380 (diff)
downloadostree-57bb06419a3e4c78c6165b755004ff40b685e4db.tar.gz
lib: Port variant-builder.c to new style
Seeing `scan-build` warning here, prep for fixing it.
Diffstat (limited to 'src/libotutil')
-rw-r--r--src/libotutil/ot-variant-builder.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/libotutil/ot-variant-builder.c b/src/libotutil/ot-variant-builder.c
index 5b331e62..6636068e 100644
--- a/src/libotutil/ot-variant-builder.c
+++ b/src/libotutil/ot-variant-builder.c
@@ -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;