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

libutil/cleanup: improve out of memory handling, conform to RFC 7 #2785

Merged
merged 3 commits into from
Feb 29, 2020

Conversation

garlick
Copy link
Member

@garlick garlick commented Feb 28, 2020

This PR fixes a few style anomalies in the cleanup code, and cleans up out of memory error paths.

Split from #2783 to thin that one down a bit.

Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

LGTM.

Problem: cleanup source module contains minor RFC 7
style inconsistencies, mostly white space.

Add space between function and parameter list
Remove space between '*' and pointer variable.
Start brace on same line as conditional.
Move static variable declarations above first function def.
Fix typo in comment.
Problem: If malloc fails in cleanup_push_string (),
proram will exit, which is probably not ideal.
We may want more control over the exit path than that.

Replace xstrdup () with strdup () and just skip
cleanup if the allocation fails.
Problem: if calloc() fails in cleanup_push(), a
segfault will ensue.

Don't assign values to allocated struct if calloc fails.
Also, if zlist_append() fails, free the allocated struct
instead of leaking it.
@garlick
Copy link
Member Author

garlick commented Feb 29, 2020

merci

@mergify mergify bot merged commit a8be266 into flux-framework:master Feb 29, 2020
@garlick garlick deleted the cleanup_cleanup branch March 3, 2020 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants