Skip to content

Commit

Permalink
offsetScaledLogVariance: change it to unsigned short (SCA _032 Avnu#65)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PawelModrzejewski committed Jan 21, 2021
1 parent 0baef8a commit 2a06af5
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/avbts_clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct ClockQuality {
unsigned char clockAccuracy; /*!< Clock Accuracy - clause 8.6.2.3.
Indicates the expected time accuracy of
a clock master.*/
int16_t offsetScaledLogVariance; /*!< ::Offset Scaled log variance - Clause 8.6.2.4.
uint16_t offsetScaledLogVariance; /*!< ::Offset Scaled log variance - Clause 8.6.2.4.
Is the scaled, offset representation
of an estimate of the PTP variance. The
PTP variance characterizes the
Expand Down
2 changes: 1 addition & 1 deletion common/avbts_osipc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class OS_IPC {
uint8_t clock_identity[],
uint8_t priority1,
uint8_t clock_class,
int16_t offset_scaled_log_variance,
uint16_t offset_scaled_log_variance,
uint8_t clock_accuracy,
uint8_t priority2,
uint8_t domain_number,
Expand Down
2 changes: 1 addition & 1 deletion common/ipcdef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ typedef struct {
uint8_t clock_identity[PTP_CLOCK_IDENTITY_LENGTH]; //!< The clock identity of the interface
uint8_t priority1; //!< The priority1 field of the grandmaster functionality of the interface, or 0xFF if not supported
uint8_t clock_class; //!< The clockClass field of the grandmaster functionality of the interface, or 0xFF if not supported
int16_t offset_scaled_log_variance; //!< The offsetScaledLogVariance field of the grandmaster functionality of the interface, or 0x0000 if not supported
uint16_t offset_scaled_log_variance; //!< The offsetScaledLogVariance field of the grandmaster functionality of the interface, or 0x0000 if not supported
uint8_t clock_accuracy; //!< The clockAccuracy field of the grandmaster functionality of the interface, or 0xFF if not supported
uint8_t priority2; //!< The priority2 field of the grandmaster functionality of the interface, or 0xFF if not supported
uint8_t domain_number; //!< The domainNumber field of the grandmaster functionality of the interface, or 0 if not supported
Expand Down
2 changes: 1 addition & 1 deletion linux/shm_test/shm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
fprintf(stdout, "clock_accuracy %u\n", (unsigned int) ptpData->clock_accuracy);
fprintf(stdout, "priority2 %u\n", (unsigned int) ptpData->priority2);
fprintf(stdout, "domain_number %u\n", (unsigned int) ptpData->domain_number);
Expand Down
2 changes: 1 addition & 1 deletion linux/src/linux_hal_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ bool LinuxSharedMemoryIPC::update_network_interface(
uint8_t clock_identity[],
uint8_t priority1,
uint8_t clock_class,
int16_t offset_scaled_log_variance,
uint16_t offset_scaled_log_variance,
uint8_t clock_accuracy,
uint8_t priority2,
uint8_t domain_number,
Expand Down
2 changes: 1 addition & 1 deletion linux/src/linux_hal_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ class LinuxSharedMemoryIPC:public OS_IPC {
uint8_t clock_identity[],
uint8_t priority1,
uint8_t clock_class,
int16_t offset_scaled_log_variance,
uint16_t offset_scaled_log_variance,
uint8_t clock_accuracy,
uint8_t priority2,
uint8_t domain_number,
Expand Down

0 comments on commit 2a06af5

Please sign in to comment.