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

offsetScaledLogVariance: change it to unsigned short (SCA _032 #65) #77

Conversation

PawelModrzejewski
Copy link
Contributor

Static code analysis fix _032 (Issue #65)

SCA complains here about ntohs() but the real issue is the type of offsetScaledLogVariance,
which currently in the code is int16_t. There seems to be inconsistency in IEEE 802.1AS-2011:

- in 6.3.3.8 ClockQuality offsetScaledLogVariance is defined as UInteger16;
- later in the document it's used as Integer16 (Table 14-1, code examples etc.);

This inconsistency has been corrected in IEEE 802.1AS-2011/Cor 1-2013 where UInteger16 was specified
in the Table 14-1 and used later in the code examples. IEEE 1588-2008 defines offsetScaledLogVariance also
as UInteger16 (see 5.3.7 ClockQuality).

Static code analysis fix _032 (Issue Avnu#65)

SCA complains here about ntohs() but the real issue is the type of offsetScaledLogVariance,
which currently in the code is int16_t. There seems to be inconsistency in IEEE 802.1AS-2011:

    - in 6.3.3.8 ClockQuality offsetScaledLogVariance is defined as UInteger16;
    - later in the document it's used as Integer16 (Table 14-1, code examples etc.);

This inconsistency has been corrected in IEEE 802.1AS-2011/Cor 1-2013 where UInteger16 was specified
in the Table 14-1 and used later in the code examples.
@PawelModrzejewski
Copy link
Contributor Author

Please review

@PawelModrzejewski
Copy link
Contributor Author

Hello, hello! Any comments here?

@PawelModrzejewski
Copy link
Contributor Author

Anybody out there?

@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
(unsigned int) ptpData->clock_identity[6], (unsigned int) ptpData->clock_identity[7]);
fprintf(stdout, "priority1 %u\n", (unsigned int) ptpData->priority1);
fprintf(stdout, "clock_class %u\n", (unsigned int) ptpData->clock_class);
fprintf(stdout, "offset_scaled_log_variance %d\n", (int) ptpData->offset_scaled_log_variance);
fprintf(stdout, "offset_scaled_log_variance %d\n", (unsigned int) ptpData->offset_scaled_log_variance);
Copy link
Contributor

Choose a reason for hiding this comment

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

%u should be used for printing unsigned int

@MarcinMiklas MarcinMiklas merged commit d5ddcc0 into Avnu:master Mar 3, 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.

2 participants