b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/adjtimex.c |
| 2 | +++ b/adjtimex.c |
| 3 | @@ -36,6 +36,7 @@ |
| 4 | * gcc -Wall -O adjtimex_1.c -o adjtimex |
| 5 | */ |
| 6 | |
| 7 | +#include <inttypes.h> |
| 8 | #include <stdio.h> |
| 9 | #include <sys/types.h> |
| 10 | #include <stdlib.h> |
| 11 | @@ -143,12 +144,12 @@ int main(int argc, char ** argv) |
| 12 | " precision: %ld\n" |
| 13 | " tolerance: %ld\n" |
| 14 | "-t tick: %ld\n" |
| 15 | - " time.tv_sec: %ld\n" |
| 16 | - " time.tv_usec: %ld\n" |
| 17 | + " time.tv_sec: %" PRId64 "\n" |
| 18 | + " time.tv_usec: %" PRId64 "\n" |
| 19 | " return value: %d (%s)\n", |
| 20 | txc.constant, |
| 21 | txc.precision, txc.tolerance, txc.tick, |
| 22 | - txc.time.tv_sec, txc.time.tv_usec, ret, |
| 23 | + (int64_t)txc.time.tv_sec, (int64_t)txc.time.tv_usec, ret, |
| 24 | (ret >= 0 && ret <= 5) ? ret_code_descript[ret] : "error" ); |
| 25 | } |
| 26 | return (ret<0); |
| 27 | --- a/ntpclient.c |
| 28 | +++ b/ntpclient.c |
| 29 | @@ -29,6 +29,7 @@ |
| 30 | * labelled "XXX fixme - non-automatic build configuration". |
| 31 | */ |
| 32 | |
| 33 | +#include <inttypes.h> |
| 34 | #include <stdio.h> |
| 35 | #include <stdlib.h> |
| 36 | #include <string.h> |
| 37 | @@ -181,7 +182,7 @@ static void set_time(struct ntptime *new |
| 38 | exit(1); |
| 39 | } |
| 40 | if (debug) { |
| 41 | - printf("set time to %lu.%.9lu\n", tv_set.tv_sec, tv_set.tv_nsec); |
| 42 | + printf("set time to %" PRId64 ".%.9" PRId64 "\n", (int64_t)tv_set.tv_sec, (int64_t)tv_set.tv_nsec); |
| 43 | } |
| 44 | #else |
| 45 | /* Traditional Linux way to set the system clock |
| 46 | @@ -196,7 +197,7 @@ static void set_time(struct ntptime *new |
| 47 | exit(1); |
| 48 | } |
| 49 | if (debug) { |
| 50 | - printf("set time to %lu.%.6lu\n", tv_set.tv_sec, tv_set.tv_usec); |
| 51 | + printf("set time to %" PRId64 ".%.6" PRId64 "\n", (int64_t)tv_set.tv_sec, (int64_t)tv_set.tv_usec); |
| 52 | } |
| 53 | #endif |
| 54 | } |