Skip to content
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

Merged
merged 1 commit into from Aug 1, 2023

Conversation

dkogan
Copy link
Contributor

@dkogan dkogan commented Jul 19, 2023

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.

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.
@LeStarch LeStarch self-requested a review July 24, 2023 19:07
Copy link
Collaborator

@LeStarch LeStarch left a 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!

@LeStarch
Copy link
Collaborator

@thomas-bc @timcanham would either of you review this change too?

Copy link
Collaborator

@thomas-bc thomas-bc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@LeStarch
Copy link
Collaborator

LeStarch commented Aug 1, 2023

The check timed out. I have no reason to believe this would affect code QL as the change is a single digit.

@LeStarch LeStarch merged commit e554335 into nasa:devel Aug 1, 2023
22 of 23 checks passed
thomas-bc pushed a commit that referenced this pull request Aug 4, 2023
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 <Dmitriy.Kogan@jpl.nasa.gov>
thomas-bc added a commit that referenced this pull request Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants