-
Notifications
You must be signed in to change notification settings - Fork 852
Make format specifier for time_t portable #6860
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
Conversation
|
[approve ci autest] |
traeak
left a comment
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.
It's probably okay although perhaps we should technically use the "difftime" api which is guaranteed to return a double. I've seen "mishandling" of time_t in other places in the code.
|
[approve ci autest] |
1 similar comment
|
[approve ci autest] |
|
Yeah, you're probably right. I didn't read the code that much and just fixed the compile errors because it blocks my daily work. I'd like to leave the future improvement to people who maintain the plugins. |
| time_t const ch_time = get_date_from_cached_hdr(txnp); | ||
| DEBUG_LOG("IMS Cached header time %" PRId64 " vs IMS %" PRId64, ch_time, txn_state->ims_time); | ||
| DEBUG_LOG("IMS Cached header time %jd vs IMS %jd", static_cast<intmax_t>(ch_time), | ||
| static_cast<intmax_t>(txn_state->ims_time)); |
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.
If you prefer to cast to intmax_t then why not use PRIdMAX as the format specifier? https://en.cppreference.com/w/cpp/header/cinttypes
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.
It's not my preference. Just because Google navigated me to the example and it worked.
(cherry picked from commit dde3897)
* Slice plugin: recover out of sync slices, better handling of non 206s (#6691) The very first slice is used as the reference slice to make recovery easiest. Recover asset where slices differ in content-length, etag, last-modified. autests included to cover basic functionality. Includes additions to include/ts/experimental.h: tsapi time_t TSMimeParseDate(char const *const value_str, int const value_len); tsapi TSReturnCode TSMimeFormatDate(time_t const value_time, char *const value_str, int *const value_len); These are derived from TSMimeHdrFieldValueDateSet/TSMimeHdrFieldValueDateGet. (cherry picked from commit 6dd31eb) * Make format specifier for time_t portable (#6860) (cherry picked from commit dde3897) * autest whitespace * slice: clean up of created 502 response header (#6919) Change header debug to use TSHttpHdrPrint. Co-authored-by: Brian Olsen <[email protected]> (cherry picked from commit 9d23ab6) * default to throttling and subsequently simplify the transfer code (#7257) slice: default to throttling, 416 changes and bug fix for downstream closing. (cherry picked from commit 4462484) Co-authored-by: Masakazu Kitajo <[email protected]>
|
Backported to 9.0.1 in #7435 |
PRId64 doesn't work for time_t on macOS.
This page uses "%jd", and it works for me.
https://en.cppreference.com/w/c/chrono/time_t