-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
EVR output: we print 6 digits worth of microseconds #2143
Conversation
This avoids a pernicious behavior where EVR timestamps lie about their sub-second values. I have this test program: #include <stdio.h> #include <inttypes.h> void main(void) { printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 12); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 123); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 1234); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 12356); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 123456); } It produces this output: 01:02:03.012 01:02:03.123 01:02:03.1234 01:02:03.12356 01:02:03.123456 so prior to this patch, if we were 1 hour, 2 minutes, 3 seconds, 123 microseconds past midnight, this was printed as "01:02:03.123" instead of "01:02:03.000123". Any reasonable human looking at "01:02:03.123" would see a value of "123000" microseconds.
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.
Looks right to me!
@thomas-bc @timcanham would either of you review this change too? |
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.
LGTM!
The check timed out. I have no reason to believe this would affect code QL as the change is a single digit. |
This avoids a pernicious behavior where EVR timestamps lie about their sub-second values. I have this test program: #include <stdio.h> #include <inttypes.h> void main(void) { printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 12); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 123); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 1234); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 12356); printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 123456); } It produces this output: 01:02:03.012 01:02:03.123 01:02:03.1234 01:02:03.12356 01:02:03.123456 so prior to this patch, if we were 1 hour, 2 minutes, 3 seconds, 123 microseconds past midnight, this was printed as "01:02:03.123" instead of "01:02:03.000123". Any reasonable human looking at "01:02:03.123" would see a value of "123000" microseconds. Co-authored-by: Dima Kogan <[email protected]>
This avoids a pernicious behavior where EVR timestamps lie about their
sub-second values. I have this test program:
#include <stdio.h>
#include <inttypes.h>
void main(void)
{
printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 12);
printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 123);
printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 1234);
printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 12356);
printf("%02d:%02d:%02d.%03" PRIu32 "\n", 1,2,3, 123456);
}
It produces this output:
01:02:03.012
01:02:03.123
01:02:03.1234
01:02:03.12356
01:02:03.123456
so prior to this patch, if we were 1 hour, 2 minutes, 3 seconds, 123
microseconds past midnight, this was printed as "01:02:03.123" instead of
"01:02:03.000123". Any reasonable human looking at "01:02:03.123" would see a
value of "123000" microseconds.