Skip to content

writer: Fix return value of lcfs_node_unset_xattr#401

Merged
allisonkarlitskaya merged 2 commits intocomposefs:mainfrom
cgwalters:fix-unset-xattr-retval
Dec 9, 2024
Merged

writer: Fix return value of lcfs_node_unset_xattr#401
allisonkarlitskaya merged 2 commits intocomposefs:mainfrom
cgwalters:fix-unset-xattr-retval

Conversation

@cgwalters
Copy link
Copy Markdown
Contributor

Since the first creation of this code in
5ac1f5c "lib: Update xattr APIs" this function
has always returned an error code - but nothing
checked it, so it didn't matter.

Now also, currently this function cannot fail
but let's give ourselves some flexibility here;
perhaps we want to e.g. invoke realloc
and in that case we'd need to handle OOM.

I just noticed this while working on commit
02077e8
to reject empty xattr names.

Change this to return success, and also check its
return value in the set path.

Copy link
Copy Markdown
Collaborator

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something went wrong with the commit message formatting...

Since the first creation of this code in
5ac1f5c "lib: Update xattr APIs" this function
has always returned an error code - but nothing
checked it, so it didn't matter.

Now also, currently this function cannot fail
but let's give ourselves some flexibility here;
perhaps we want to e.g. invoke `realloc`
and in that case we'd need to handle OOM.

I just noticed this while working on commit
02077e8
to reject empty xattr names.

Change this to return success, and also check its
return value in the set path.

Signed-off-by: Colin Walters <walters@verbum.org>
Came up in chat, the semantics defined today is last-one-wins.
Let's test that.

Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters force-pushed the fix-unset-xattr-retval branch from 586776f to 306f24d Compare December 2, 2024 21:46
@cgwalters
Copy link
Copy Markdown
Contributor Author

I also added a test case for the multiple xattr path.

@cgwalters
Copy link
Copy Markdown
Contributor Author

Something went wrong with the commit message formatting...

Can you be more specific?

@allisonkarlitskaya
Copy link
Copy Markdown
Collaborator

Can you be more specific?

Same as we talked about today. It's wrapped at 50. Not important :)

Copy link
Copy Markdown
Collaborator

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

else
node->xattr_size = 0; // If last xattr, remove the overhead too
assert(node->xattr_size >= 0);
if (index < 0) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way around reads a lot nicer now. Thanks for the change.

@allisonkarlitskaya allisonkarlitskaya merged commit ed3ee0d into composefs:main Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants