-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
aws_util: fix leading zeros in time_key #8116
Conversation
Signed-off-by: Wesley Pettit <[email protected]>
Signed-off-by: Wesley Pettit <[email protected]>
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.
How about using printf format like "%09" PRIu64 ?
"%" PRIu64, (uint64_t) tms->tm.tv_nsec / 1000000); | ||
snprintf(nanosecond_str, FLB_AWS_NANOSECOND_FORMATTER_LENGTH+1, | ||
snprintf(nanosecond_str, FLB_AWS_NANOSECOND_LENGTH+1, |
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.
How about ensuring like following code ?
snprintf(nanosecond_str, FLB_AWS_NANOSECOND_LENGTH+1, "%09" PRIu64, (uint64_t) tms->tm.tv_nsec);
Example code:
#include <stdio.h>
#include <inttypes.h>
int main()
{
uint64_t val = 1;
int i;
for (i=0; i<9; i++) {
printf("i=%d " "%09" PRIu64 "\n", i, val);
val *= 10;
}
}
Output is
i=0 000000001
i=1 000000010
i=2 000000100
i=3 000001000
i=4 000010000
i=5 000100000
i=6 001000000
i=7 010000000
i=8 100000000
@@ -1002,28 +1017,34 @@ size_t flb_aws_strftime_precision(char **out_buf, const char *time_format, | |||
} | |||
|
|||
/* Replace %3N to millisecond, %9N and %L to nanosecond in time_format. */ | |||
snprintf(millisecond_str, FLB_AWS_MILLISECOND_FORMATTER_LENGTH+1, | |||
snprintf(millisecond_str, FLB_AWS_MILLISECOND_LENGTH+1, |
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.
How about ensuring like following code ?
snprintf(nanosecond_str, FLB_AWS_MILLISECOND_LENGTH+1, "%03" PRIu64, (uint64_t) tms->tm.tv_nsec / 1000000);
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
ping @PettitWesley |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
fixed in #9128 |
Fixes #7538
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.