Fix bogus "system time" report for 64 bit systems

Eric Lammerts writes:
This is known as Debian bug #195620, which is almost three years old!

The problem is that a uint32_t which comes out of ntohl() (but
actually represents a signed value) is directly promoted to long.
Therefore no sign extension takes place.

Patch below solves the problem. There are other places where this
needs to be fixed, but I'll leave that to a less lazy person.
This commit is contained in:
Eric Lammerts 2006-04-13 11:15:26 -04:00 committed by Richard P. Curnow
parent 1e7e7d3231
commit 4771cbe8b0

View file

@ -1652,7 +1652,7 @@ process_cmd_tracking(char *line)
ref_time.tv_usec = ntohl(reply.data.tracking.ref_time_us); ref_time.tv_usec = ntohl(reply.data.tracking.ref_time_us);
ref_time_tm = *gmtime((time_t *)&ref_time.tv_sec); ref_time_tm = *gmtime((time_t *)&ref_time.tv_sec);
printf("Ref time (UTC) : %s", asctime(&ref_time_tm)); printf("Ref time (UTC) : %s", asctime(&ref_time_tm));
correction_tv.tv_sec = ntohl(reply.data.tracking.current_correction_s); correction_tv.tv_sec = (int32_t)ntohl(reply.data.tracking.current_correction_s);
correction_tv.tv_usec = ntohl(reply.data.tracking.current_correction_us); correction_tv.tv_usec = ntohl(reply.data.tracking.current_correction_us);
correction = (double) correction_tv.tv_sec + 1.0e-6 * correction_tv.tv_usec; correction = (double) correction_tv.tv_sec + 1.0e-6 * correction_tv.tv_usec;
printf("System time : %.6f seconds %s of NTP time\n", fabs(correction), printf("System time : %.6f seconds %s of NTP time\n", fabs(correction),