| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| } 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; | ||
| } |
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.
Sorry, something went wrong.
There was a problem hiding this comment.
This PR ensures msgpack_pack_timestamp() correctly propagates failures from the underlying packing helpers, so callers can observe and handle allocation/write errors instead of silently succeeding.
Changes:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What is this PR?
This PR makes it so that return codes of helpers called in msgpack_pack_ext are 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).