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

writer: Fix return value of lcfs_node_unset_xattr #401

Merged

Conversation

cgwalters
Copy link
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
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...

libcomposefs/lcfs-writer.c Show resolved Hide resolved
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
Contributor Author

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

@cgwalters
Copy link
Contributor Author

Something went wrong with the commit message formatting...

Can you be more specific?

@allisonkarlitskaya
Copy link
Collaborator

Can you be more specific?

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

Copy link
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
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 containers:main Dec 9, 2024
13 checks passed
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