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: Set errno #263

Merged
merged 1 commit into from
Mar 20, 2024
Merged

Conversation

eriksjolund
Copy link
Collaborator

@eriksjolund eriksjolund commented Mar 19, 2024

According to errno(3) a function that succeeds is allowed to change errno.
What if memdup() succeeds?

I changed the code to match how it's written here

errno = ENOMEM;

Set errno in the same way as it's done further down in the same file
https://github.com/containers/composefs/blob/d5ffbeb6844cdbe029f9c10cfa98239e2d6b1570/libcomposefs/lcfs-writer.c#L1472

Set errno after munmap() to avoid overwriting the original errno.

Signed-off-by: Erik Sjölund <[email protected]>
@eriksjolund
Copy link
Collaborator Author

I added another small errno modification and rewrote the commit message.

@cgwalters cgwalters merged commit 2cb505b into containers:main Mar 20, 2024
9 of 10 checks passed
@cgwalters
Copy link
Contributor

At least systemd has a handy PRESERVE_ERRNO macro that I've used in other places too, and I think is a nicer approach. We could add that here.

@eriksjolund eriksjolund deleted the writer-set-errno branch March 20, 2024 18:26
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