-
Notifications
You must be signed in to change notification settings - Fork 50
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
Misc Refactoring & Cleanup in libkvs #1153
Conversation
One thing I'd suggest is to add more verbose descriptions in the commit body for these commits. |
Splice flux_kvs_fence() and flux_kvs_commit() out from kvs_txn and into new kvs_commit files.
Codecov Report
@@ Coverage Diff @@
## master #1153 +/- ##
==========================================
- Coverage 77.54% 77.49% -0.06%
==========================================
Files 157 158 +1
Lines 28751 28756 +5
==========================================
- Hits 22295 22284 -11
- Misses 6456 6472 +16
|
@grondo Agreed, they were a bit too simple. Updated with more details. |
Doh, travis caught some warnings that gcc didn't catch for either of our boxes I guess.
did get one weird failure
I'll assume the error was due to something inside the travis system. Re-push & try again. |
Had a couple more "write error" builds, had to restart them. But got one with:
in the raw logs
Perhaps #1126 ? Gonna restart it. |
codecov diff is sort of bad, I"ll try and add some simple unit tests to catch bad input checks tomorrow |
src/common/libkvs/kvs_commit.c
Outdated
if (!(f = flux_kvs_fence (h, flags, zuuid_str (uuid), 1, txn))) | ||
goto done; | ||
done: | ||
saved_errno = errno; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this function could be simplified (and the confusing goto done
when the done:
label is on the next line removed) with something like this?
if (!(uuid = zuuid_new ()) || !(f = flux_kvs_fence (h, flags, zuuid_str (uuid), 1, txn)))
saved_errno = errno;
zuuid_destroy (&uuid);
errno = saved_errno;
return f;
Also avoids setting errno to assign it to saved_errno, and set it back to errno again.
If taking this approach it might be good to also initialize saved_errno. (then you could also add something like if (saved_errno) errno = saved_errno;
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would simplify it a bit.
src/common/libkvs/kvs_lookup.c
Outdated
return NULL; | ||
} | ||
if (validate_lookup_flags (flags) < 0) | ||
return NULL; | ||
if (!treeobj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an idle suggestion -- a couple lines of code could be removed by combining the two conditionals here:
if (!h || !key || strlen (key) == 0 || validate_lookup_flags (flags) < 0) {
errno = EINVAL;
return NULL;
}
as a bonus validate_lookup_flags
doesn't have to set its own errno (it is internal and only fails in one way anyhow)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like this idea
Typo in commit message for 1c26ce4? "Simply" should be "Simplify"? Also, maybe add a descriptive message to 1284050, or perhaps squash it into another commit? (Sorry didn't quite grok if the code was just moved around, in which case it might make more sense to keep your cleanup commit separate). If you feel the cleanup is simple enough to not need a message body, though, I'd be ok with that. Otherwise, is this ready? Nice work on coverage of added code 👍 |
Simplify handling of NULL transaction in flux_kvs_fence().
Add parameter checks to flux_kvs_lookup() and flux_kvs_lookupat().
Add simple error check tests for kvs_lookup and kvs_dir.
@grondo Doh, thanks for the typo catch. Yeah, not really much to say about 1284050, as it's just moving code around. I changed the commit log say "simplify" instead of "cleanup", since that may make the single line make more sense. I didn't want to squash it into the earlier commit de37f36, b/c that one was more about splitting the functions out of the Basically it's all ready for merge. |
Ok, thanks. Had to restart one of the builds due to |
Spliced out patches from a larger RFC11 PR that @garlick and I are working on. Apologies I missed these and didn't put them in #1152 as I couldn't quite see their independence at first.
All patches are from @garlick. I've reviewed and it looks good to me. But as I'm opening this PR, think it's wrong for me to hit the button.