net: gptp: Fix type mismatch calculation error in gptp_mi

NSEC_PER_SEC is an unsigned integer macro. Thus, -NSEC_PER_SEC will be
treated as unsigned integer as well which lead to calculation error on
64bits integer variables. Added the correct type casting into the formula
to fix the calculation error.

Signed-off-by: Kweh Hock Leong <hock.leong.kweh@intel.com>
This commit is contained in:
Kweh Hock Leong 2022-03-28 14:12:53 +08:00 committed by Christopher Friedt
parent 3f958347c2
commit 9b18f4a730
1 changed files with 1 additions and 1 deletions

View File

@ -778,7 +778,7 @@ static void gptp_update_local_port_clock(void)
if (second_diff < 0 && nanosecond_diff > 0) {
second_diff++;
nanosecond_diff = -NSEC_PER_SEC + nanosecond_diff;
nanosecond_diff = -(int64_t)NSEC_PER_SEC + nanosecond_diff;
}
ptp_clock_rate_adjust(clk, port_ds->neighbor_rate_ratio);