Skip to content

Commit

Permalink
src/hash_index: simplify flow of r_hash_index_open_*()
Browse files Browse the repository at this point in the history
Now that we do not need to close the fd at the end anymore, replace goto
by immediate returns.

Signed-off-by: Enrico Joerns <[email protected]>
  • Loading branch information
ejoerns committed Aug 30, 2024
1 parent d890477 commit 8519707
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/hash_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ RaucHashIndex *r_hash_index_open_slot(const gchar *label, const RaucSlot *slot,
G_FILE_ERROR,
g_file_error_from_errno(err),
"Failed to open slot device %s: %s", slot->device, g_strerror(err));
goto out;
return NULL;
}

dir = r_slot_get_checksum_data_directory(slot, NULL, &ierror);
if (!dir) {
g_propagate_error(error, ierror);
goto out;
return NULL;
}

index_filename = g_build_filename(dir, "block-hash-index", NULL);
Expand All @@ -349,11 +349,11 @@ RaucHashIndex *r_hash_index_open_slot(const gchar *label, const RaucSlot *slot,
idx = r_hash_index_open(label, data_fd, index_filename, &ierror);
if (!idx) {
g_propagate_error(error, ierror);
goto out;
return NULL;
}

g_debug("opened hash index for slot %s as %s", slot->name, label);
out:

return g_steal_pointer(&idx);
}

Expand All @@ -375,19 +375,19 @@ RaucHashIndex *r_hash_index_open_image(const gchar *label, const RaucImage *imag
G_FILE_ERROR,
g_file_error_from_errno(err),
"Failed to open image file %s: %s", image->filename, g_strerror(err));
goto out;
return NULL;
}

index_filename = g_strdup_printf("%s.block-hash-index", image->filename);

idx = r_hash_index_open(label, data_fd, index_filename, &ierror);
if (!idx) {
g_propagate_error(error, ierror);
goto out;
return NULL;
}

g_debug("opened hash index for image %s with index %s", image->filename, index_filename);
out:

return g_steal_pointer(&idx);
}

Expand Down

0 comments on commit 8519707

Please sign in to comment.