Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle NULL from lcfs_node_new() and move errno code into the function #262

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions libcomposefs/lcfs-writer-erofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,6 @@ static int add_overlay_whiteouts(struct lcfs_node_s *root)

child = lcfs_node_new();
if (child == NULL) {
errno = ENOMEM;
return -1;
}

Expand Down Expand Up @@ -1236,7 +1235,6 @@ static int rewrite_tree_node_for_erofs(struct lcfs_ctx_s *ctx,
if (existing == NULL) {
struct lcfs_node_s *link = lcfs_node_new();
if (link == NULL) {
errno = ENOMEM;
return -1;
}
lcfs_node_make_hardlink(link, node);
Expand All @@ -1251,7 +1249,6 @@ static int rewrite_tree_node_for_erofs(struct lcfs_ctx_s *ctx,
if (existing == NULL) {
struct lcfs_node_s *link = lcfs_node_new();
if (link == NULL) {
errno = ENOMEM;
return -1;
}
lcfs_node_make_hardlink(link, parent);
Expand Down Expand Up @@ -1609,7 +1606,6 @@ static struct lcfs_node_s *lcfs_build_node_from_image(struct lcfs_image_data *da

node = lcfs_node_new();
if (node == NULL) {
errno = ENOMEM;
return NULL;
}

Expand Down
4 changes: 3 additions & 1 deletion libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,10 @@ static int read_xattrs(struct lcfs_node_s *ret, int dirfd, const char *fname,
struct lcfs_node_s *lcfs_node_new(void)
{
struct lcfs_node_s *node = calloc(1, sizeof(struct lcfs_node_s));
if (node == NULL)
if (node == NULL) {
errno = ENOMEM;
return NULL;
}

node->ref_count = 1;
node->inode.st_nlink = 1;
Expand Down
3 changes: 3 additions & 0 deletions tools/mkcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ static char *tree_from_dump_line(dump_info *info, const char *line, size_t line_
return err;

cleanup_node struct lcfs_node_s *node = lcfs_node_new();
if (node == NULL) {
oom();
}
lcfs_node_set_mode(node, mode);

err = tree_add_node(info, path, node);
Expand Down
Loading