Skip to content

Commit

Permalink
src/manifest: simplify parse_manifest() return handling
Browse files Browse the repository at this point in the history
The 'free:' label has no purpose, thus we can remove 'res' variable and
return FALSE on error directly to simplify code flow.

Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Mar 2, 2022
1 parent 84a68ee commit 16ae560
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr
{
GError *ierror = NULL;
g_autoptr(RaucManifest) raucm = NULL;
gboolean res = FALSE;
g_autofree gchar *tmp = NULL;
g_auto(GStrv) groups = NULL;
gsize group_count;
Expand All @@ -120,14 +119,14 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr
raucm->update_compatible = key_file_consume_string(key_file, "update", "compatible", &ierror);
if (!raucm->update_compatible) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}
raucm->update_version = key_file_consume_string(key_file, "update", "version", NULL);
raucm->update_description = key_file_consume_string(key_file, "update", "description", NULL);
raucm->update_build = key_file_consume_string(key_file, "update", "build", NULL);
if (!check_remaining_keys(key_file, "update", &ierror)) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}
g_key_file_remove_group(key_file, "update", NULL);

Expand All @@ -146,11 +145,11 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr
} else {
g_set_error(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE,
"Invalid format value '%s' in group '[bundle]'", tmp);
goto free;
return FALSE;
}
if (!check_remaining_keys(key_file, "bundle", &ierror)) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}
g_key_file_remove_group(key_file, "bundle", NULL);

Expand All @@ -159,7 +158,7 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr
raucm->handler_args = key_file_consume_string(key_file, "handler", "args", NULL);
if (!check_remaining_keys(key_file, "handler", &ierror)) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}
g_key_file_remove_group(key_file, "handler", NULL);

Expand All @@ -173,13 +172,13 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr
} else {
g_set_error(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE,
"install hook type '%s' not supported", bundle_hooks[j]);
goto free;
return FALSE;
}
}

if (!check_remaining_keys(key_file, "hooks", &ierror)) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}
g_key_file_remove_group(key_file, "hooks", NULL);

Expand All @@ -191,7 +190,7 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr

if (!parse_image(key_file, groups[i], &image, &ierror)) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}

raucm->images = g_list_append(raucm->images, image);
Expand All @@ -200,13 +199,12 @@ static gboolean parse_manifest(GKeyFile *key_file, RaucManifest **manifest, GErr

if (!check_remaining_groups(key_file, &ierror)) {
g_propagate_error(error, ierror);
goto free;
return FALSE;
}

res = TRUE;
*manifest = g_steal_pointer(&raucm);
free:
return res;

return TRUE;
}

gboolean load_manifest_mem(GBytes *mem, RaucManifest **manifest, GError **error)
Expand Down

0 comments on commit 16ae560

Please sign in to comment.