fix: properly handle return codes in pack_timestamp#672
Open
KowalskiThomas wants to merge 1 commit into
Open
Conversation
KowalskiThomas
commented
May 11, 2026
Comment on lines
578
to
589
| } else { | ||
| /* seconds is signed or >34bits */ | ||
| unsigned char buf[12]; | ||
| _msgpack_store32(&buf[0], nanoseconds); | ||
| _msgpack_store64(&buf[4], seconds); | ||
| msgpack_pack_ext(x, -1, 12); | ||
| msgpack_pack_raw_body(x, buf, 12); | ||
| /* seconds is signed or >34bits */ | ||
| unsigned char buf[12]; | ||
| _msgpack_store32(&buf[0], nanoseconds); | ||
| _msgpack_store64(&buf[4], seconds); | ||
| ret = msgpack_pack_ext(x, -1, 12); | ||
| if (ret != 0) | ||
| return ret; | ||
|
|
||
| return msgpack_pack_raw_body(x, buf, 12); | ||
| } | ||
| return 0; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
If this was my code, I would probably prefer doing something like
if (condition) {
// whatever
return something;
}
// the contents of the elseto make it clear to the reader that we never not return a value from the function. This is even more relevant now that I've removed the return 0 at the end. But it's not my code so... let me know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR?
This PR makes it so that return codes of helpers called in
msgpack_pack_extare properly checked and surfaced if they're indicative of a failure.Note the "big" diff at the end of the function is an indentation change on top of the actual change -- the code used to be indented with three spaces instead of four. I changed that (should be clear looking at the diff without whitespace changes).