Skip to content

Commit

Permalink
testptp: Remove magic numbers related to nanosecond to second conversion
Browse files Browse the repository at this point in the history
Use existing NSEC_PER_SEC declaration in place of hardcoded magic numbers.

Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Maciek Machnikowski <maciek@machnikowski.net>
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rahul Rameshbabu authored and David S. Miller committed Jun 20, 2023
1 parent fe3834c commit 048f6d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/ptp/testptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static long ppb_to_scaled_ppm(int ppb)

static int64_t pctns(struct ptp_clock_time *t)
{
return t->sec * 1000000000LL + t->nsec;
return t->sec * NSEC_PER_SEC + t->nsec;
}

static void usage(char *progname)
Expand Down Expand Up @@ -317,7 +317,7 @@ int main(int argc, char *argv[])
tx.time.tv_usec = adjns;
while (tx.time.tv_usec < 0) {
tx.time.tv_sec -= 1;
tx.time.tv_usec += 1000000000;
tx.time.tv_usec += NSEC_PER_SEC;
}

if (clock_adjtime(clkid, &tx) < 0) {
Expand Down

0 comments on commit 048f6d9

Please sign in to comment.