diff --git a/3002-Fixed-format-strings-and-type-casts-in-hwclock-to-wo.patch b/3002-Fixed-format-strings-and-type-casts-in-hwclock-to-wo.patch new file mode 100644 index 0000000000000000000000000000000000000000..bb411dbfba58689c2ad426fa1c34e4d793fa5e97 --- /dev/null +++ b/3002-Fixed-format-strings-and-type-casts-in-hwclock-to-wo.patch @@ -0,0 +1,231 @@ +From 1990c7532b31ec613532bd111ce1f0f9ce8ba9a1 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 20 Feb 2025 15:29:22 +0800 +Subject: [PATCH] Fixed format strings and type casts in hwclock to work with + 64-bit time_t on 32-bit linux + +from upstream: #a937ef831891c30bb7adfc945dee439d192b3476. + +Signed-off-by: Weisson +--- + sys-utils/hwclock.c | 109 ++++++++++++++++++++++++-------------------- + 1 file changed, 59 insertions(+), 50 deletions(-) + +diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c +index 47aee63..dfb43f6 100644 +--- a/sys-utils/hwclock.c ++++ b/sys-utils/hwclock.c +@@ -169,8 +169,8 @@ static struct timeval time_inc(struct timeval addend, double increment) + { + struct timeval newtime; + +- newtime.tv_sec = addend.tv_sec + (int)increment; +- newtime.tv_usec = addend.tv_usec + (increment - (int)increment) * 1E6; ++ newtime.tv_sec = addend.tv_sec + (time_t)increment; ++ newtime.tv_usec = addend.tv_usec + (increment - (time_t)increment) * 1E6; + + /* + * Now adjust it so that the microsecond value is between 0 and 1 +@@ -237,12 +237,21 @@ static int read_adjtime(const struct hwclock_control *ctl, + + fclose(adjfile); + +- sscanf(line1, "%lf %ld %lf", +- &adjtime_p->drift_factor, +- &adjtime_p->last_adj_time, +- &adjtime_p->not_adjusted); ++ if (sizeof(time_t) > 4) { ++ sscanf(line1, "%lf %lld %lf", ++ &adjtime_p->drift_factor, ++ (int64_t*)&adjtime_p->last_adj_time, ++ &adjtime_p->not_adjusted); + +- sscanf(line2, "%ld", &adjtime_p->last_calib_time); ++ sscanf(line2, "%lld", (int64_t*)&adjtime_p->last_calib_time); ++ } else { ++ sscanf(line1, "%lf %ld %lf", ++ &adjtime_p->drift_factor, ++ (long*)&adjtime_p->last_adj_time, ++ &adjtime_p->not_adjusted); ++ ++ sscanf(line2, "%ld", (long*)&adjtime_p->last_calib_time); ++ } + + if (!strcmp(line3, "UTC\n")) { + adjtime_p->local_utc = UTC; +@@ -258,10 +267,10 @@ static int read_adjtime(const struct hwclock_control *ctl, + + if (ctl->verbose) { + printf(_ +- ("Last drift adjustment done at %ld seconds after 1969\n"), +- (long)adjtime_p->last_adj_time); +- printf(_("Last calibration done at %ld seconds after 1969\n"), +- (long)adjtime_p->last_calib_time); ++ ("Last drift adjustment done at %lld seconds after 1969\n"), ++ (int64_t)adjtime_p->last_adj_time); ++ printf(_("Last calibration done at %lld seconds after 1969\n"), ++ (int64_t)adjtime_p->last_calib_time); + printf(_("Hardware clock is on %s time\n"), + (adjtime_p->local_utc == + LOCAL) ? _("local") : (adjtime_p->local_utc == +@@ -347,9 +356,9 @@ mktime_tz(const struct hwclock_control *ctl, struct tm tm, + if (ctl->verbose) + printf(_ + ("Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = " +- "%ld seconds since 1969\n"), tm.tm_year + 1900, ++ "%lld seconds since 1969\n"), tm.tm_year + 1900, + tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, +- tm.tm_sec, (long)*systime_p); ++ tm.tm_sec, (int64_t)*systime_p); + } + return valid; + } +@@ -401,9 +410,9 @@ set_hardware_clock(const struct hwclock_control *ctl, const time_t newtime) + + if (ctl->verbose) + printf(_("Setting Hardware Clock to %.2d:%.2d:%.2d " +- "= %ld seconds since 1969\n"), ++ "= %lld seconds since 1969\n"), + new_broken_time.tm_hour, new_broken_time.tm_min, +- new_broken_time.tm_sec, (long)newtime); ++ new_broken_time.tm_sec, (int64_t)newtime); + + if (!ctl->testing) + ur->set_hardware_clock(ctl, &new_broken_time); +@@ -503,17 +512,17 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + if (ticksize < 0) { + if (ctl->verbose) + printf(_("time jumped backward %.6f seconds " +- "to %ld.%06ld - retargeting\n"), +- ticksize, nowsystime.tv_sec, +- nowsystime.tv_usec); ++ "to %lld.%06lld - retargeting\n"), ++ ticksize, (int64_t)nowsystime.tv_sec, ++ (int64_t)nowsystime.tv_usec); + /* The retarget is handled at the end of the loop. */ + } else if (deltavstarget < 0) { + /* deltavstarget < 0 if current time < target time */ + DBG(DELTA_VS_TARGET, +- ul_debug("%ld.%06ld < %ld.%06ld (%.6f)", +- nowsystime.tv_sec, nowsystime.tv_usec, +- targetsystime.tv_sec, +- targetsystime.tv_usec, deltavstarget)); ++ ul_debug("%lld.%06lld < %lld.%06lld (%.6f)", ++ (int64_t)nowsystime.tv_sec, (int64_t)nowsystime.tv_usec, ++ (int64_t)targetsystime.tv_sec, ++ (int64_t)targetsystime.tv_usec, deltavstarget)); + continue; /* not there yet - keep spinning */ + } else if (deltavstarget <= target_time_tolerance_secs) { + /* Close enough to the target time; done waiting. */ +@@ -524,12 +533,12 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + * aim for the next opportunity. + */ + if (ctl->verbose) +- printf(_("missed it - %ld.%06ld is too far " +- "past %ld.%06ld (%.6f > %.6f)\n"), +- nowsystime.tv_sec, +- nowsystime.tv_usec, +- targetsystime.tv_sec, +- targetsystime.tv_usec, ++ printf(_("missed it - %lld.%06lld is too far " ++ "past %lld.%06lld (%.6f > %.6f)\n"), ++ (int64_t)nowsystime.tv_sec, ++ (int64_t)nowsystime.tv_usec, ++ (int64_t)targetsystime.tv_sec, ++ (int64_t)targetsystime.tv_usec, + deltavstarget, + target_time_tolerance_secs); + target_time_tolerance_secs += tolerance_incr_secs; +@@ -552,14 +561,14 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + - RTC_SET_DELAY_SECS /* don't count this */ + + 0.5 /* for rounding */); + if (ctl->verbose) +- printf(_("%ld.%06ld is close enough to %ld.%06ld (%.6f < %.6f)\n" +- "Set RTC to %ld (%ld + %d; refsystime = %ld.%06ld)\n"), +- nowsystime.tv_sec, nowsystime.tv_usec, +- targetsystime.tv_sec, targetsystime.tv_usec, ++ printf(_("%lld.%06lld is close enough to %lld.%06lld (%.6f < %.6f)\n" ++ "Set RTC to %lld (%lld + %d; refsystime = %lld.%06lld)\n"), ++ (int64_t)nowsystime.tv_sec, (int64_t)nowsystime.tv_usec, ++ (int64_t)targetsystime.tv_sec, (int64_t)targetsystime.tv_usec, + deltavstarget, target_time_tolerance_secs, +- newhwtime, sethwtime, +- (int)(newhwtime - sethwtime), +- refsystime.tv_sec, refsystime.tv_usec); ++ (int64_t)newhwtime, (int64_t)sethwtime, ++ (int)((int64_t)newhwtime - (int64_t)sethwtime), ++ (int64_t)refsystime.tv_sec, (int64_t)refsystime.tv_usec); + + set_hardware_clock(ctl, newhwtime); + } +@@ -633,9 +642,9 @@ set_system_clock(const struct hwclock_control *ctl, + minuteswest); + + if (ctl->hctosys) +- printf(_("Calling settimeofday(%ld.%06ld, NULL) " ++ printf(_("Calling settimeofday(%lld.%06lld, NULL) " + "to set the System time.\n"), +- newtime.tv_sec, newtime.tv_usec); ++ (int64_t)newtime.tv_sec, (int64_t)newtime.tv_usec); + } + + if (!ctl->testing) { +@@ -775,12 +784,12 @@ calculate_adjustment(const struct hwclock_control *ctl, + tdrift_p->tv_usec = (exact_adjustment - + (double)tdrift_p->tv_sec) * 1E6; + if (ctl->verbose) { +- printf(P_("Time since last adjustment is %ld second\n", +- "Time since last adjustment is %ld seconds\n", +- (systime - last_time)), +- (systime - last_time)); +- printf(_("Calculated Hardware Clock drift is %ld.%06ld seconds\n"), +- tdrift_p->tv_sec, tdrift_p->tv_usec); ++ printf(P_("Time since last adjustment is %lld second\n", ++ "Time since last adjustment is %lld seconds\n", ++ ((int64_t)systime - (int64_t)last_time)), ++ ((int64_t)systime - (int64_t)last_time)); ++ printf(_("Calculated Hardware Clock drift is %lld.%06lld seconds\n"), ++ (int64_t)tdrift_p->tv_sec, (int64_t)tdrift_p->tv_usec); + } + } + +@@ -796,11 +805,11 @@ static int save_adjtime(const struct hwclock_control *ctl, + char *content; /* Stuff to write to disk file */ + FILE *fp; + +- xasprintf(&content, "%f %ld %f\n%ld\n%s\n", ++ xasprintf(&content, "%f %lld %f\n%lld\n%s\n", + adjtime->drift_factor, +- adjtime->last_adj_time, ++ (int64_t)adjtime->last_adj_time, + adjtime->not_adjusted, +- adjtime->last_calib_time, ++ (int64_t)adjtime->last_calib_time, + (adjtime->local_utc == LOCAL) ? "LOCAL" : "UTC"); + + if (ctl->verbose){ +@@ -936,8 +945,8 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time, + hclocktime = time_inc(hclocktime, (double) + -(tdrift.tv_sec + tdrift.tv_usec / 1E6)); + if (ctl->verbose) { +- printf(_ ("Target date: %ld\n"), set_time); +- printf(_ ("Predicted RTC: %ld\n"), hclocktime.tv_sec); ++ printf(_ ("Target date: %lld\n"), (int64_t)set_time); ++ printf(_ ("Predicted RTC: %lld\n"), (int64_t)hclocktime.tv_sec); + } + return display_time(hclocktime); + } +@@ -1346,8 +1355,8 @@ int main(int argc, char **argv) + + if (ctl.verbose) { + out_version(); +- printf(_("System Time: %ld.%06ld\n"), +- startup_time.tv_sec, startup_time.tv_usec); ++ printf(_("System Time: %lld.%06lld\n"), ++ (int64_t)startup_time.tv_sec, (int64_t)startup_time.tv_usec); + } + + if (!ctl.systz && !ctl.predict) +-- +2.43.5 + diff --git a/3003-Changed-int64_t-casts-to-long-long-int-casts.patch b/3003-Changed-int64_t-casts-to-long-long-int-casts.patch new file mode 100644 index 0000000000000000000000000000000000000000..638f7f50b0902dca9016ed25a1aa02c168b4e88e --- /dev/null +++ b/3003-Changed-int64_t-casts-to-long-long-int-casts.patch @@ -0,0 +1,172 @@ +From 2c2ac05a7f7fe50e39190414c18e2972b56deb03 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 20 Feb 2025 15:46:09 +0800 +Subject: [PATCH] Changed int64_t casts to long long int casts. + +from upstream: #56702ef2eab80248f392b4c5f1c335ac86ef02b6. + +Signed-off-by: Weisson +--- + sys-utils/hwclock.c | 58 ++++++++++++++++++++++----------------------- + 1 file changed, 29 insertions(+), 29 deletions(-) + +diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c +index dfb43f6..b45b191 100644 +--- a/sys-utils/hwclock.c ++++ b/sys-utils/hwclock.c +@@ -240,10 +240,10 @@ static int read_adjtime(const struct hwclock_control *ctl, + if (sizeof(time_t) > 4) { + sscanf(line1, "%lf %lld %lf", + &adjtime_p->drift_factor, +- (int64_t*)&adjtime_p->last_adj_time, ++ (long long int*)&adjtime_p->last_adj_time, + &adjtime_p->not_adjusted); + +- sscanf(line2, "%lld", (int64_t*)&adjtime_p->last_calib_time); ++ sscanf(line2, "%lld", (long long int*)&adjtime_p->last_calib_time); + } else { + sscanf(line1, "%lf %ld %lf", + &adjtime_p->drift_factor, +@@ -268,9 +268,9 @@ static int read_adjtime(const struct hwclock_control *ctl, + if (ctl->verbose) { + printf(_ + ("Last drift adjustment done at %lld seconds after 1969\n"), +- (int64_t)adjtime_p->last_adj_time); ++ (long long int)adjtime_p->last_adj_time); + printf(_("Last calibration done at %lld seconds after 1969\n"), +- (int64_t)adjtime_p->last_calib_time); ++ (long long int)adjtime_p->last_calib_time); + printf(_("Hardware clock is on %s time\n"), + (adjtime_p->local_utc == + LOCAL) ? _("local") : (adjtime_p->local_utc == +@@ -358,7 +358,7 @@ mktime_tz(const struct hwclock_control *ctl, struct tm tm, + ("Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = " + "%lld seconds since 1969\n"), tm.tm_year + 1900, + tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, +- tm.tm_sec, (int64_t)*systime_p); ++ tm.tm_sec, (long long int)*systime_p); + } + return valid; + } +@@ -412,7 +412,7 @@ set_hardware_clock(const struct hwclock_control *ctl, const time_t newtime) + printf(_("Setting Hardware Clock to %.2d:%.2d:%.2d " + "= %lld seconds since 1969\n"), + new_broken_time.tm_hour, new_broken_time.tm_min, +- new_broken_time.tm_sec, (int64_t)newtime); ++ new_broken_time.tm_sec, (long long int)newtime); + + if (!ctl->testing) + ur->set_hardware_clock(ctl, &new_broken_time); +@@ -513,16 +513,16 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + if (ctl->verbose) + printf(_("time jumped backward %.6f seconds " + "to %lld.%06lld - retargeting\n"), +- ticksize, (int64_t)nowsystime.tv_sec, +- (int64_t)nowsystime.tv_usec); ++ ticksize, (long long int)nowsystime.tv_sec, ++ (long long int)nowsystime.tv_usec); + /* The retarget is handled at the end of the loop. */ + } else if (deltavstarget < 0) { + /* deltavstarget < 0 if current time < target time */ + DBG(DELTA_VS_TARGET, + ul_debug("%lld.%06lld < %lld.%06lld (%.6f)", +- (int64_t)nowsystime.tv_sec, (int64_t)nowsystime.tv_usec, +- (int64_t)targetsystime.tv_sec, +- (int64_t)targetsystime.tv_usec, deltavstarget)); ++ (long long int)nowsystime.tv_sec, (long long int)nowsystime.tv_usec, ++ (long long int)targetsystime.tv_sec, ++ (long long int)targetsystime.tv_usec, deltavstarget)); + continue; /* not there yet - keep spinning */ + } else if (deltavstarget <= target_time_tolerance_secs) { + /* Close enough to the target time; done waiting. */ +@@ -535,10 +535,10 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + if (ctl->verbose) + printf(_("missed it - %lld.%06lld is too far " + "past %lld.%06lld (%.6f > %.6f)\n"), +- (int64_t)nowsystime.tv_sec, +- (int64_t)nowsystime.tv_usec, +- (int64_t)targetsystime.tv_sec, +- (int64_t)targetsystime.tv_usec, ++ (long long int)nowsystime.tv_sec, ++ (long long int)nowsystime.tv_usec, ++ (long long int)targetsystime.tv_sec, ++ (long long int)targetsystime.tv_usec, + deltavstarget, + target_time_tolerance_secs); + target_time_tolerance_secs += tolerance_incr_secs; +@@ -563,12 +563,12 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + if (ctl->verbose) + printf(_("%lld.%06lld is close enough to %lld.%06lld (%.6f < %.6f)\n" + "Set RTC to %lld (%lld + %d; refsystime = %lld.%06lld)\n"), +- (int64_t)nowsystime.tv_sec, (int64_t)nowsystime.tv_usec, +- (int64_t)targetsystime.tv_sec, (int64_t)targetsystime.tv_usec, ++ (long long int)nowsystime.tv_sec, (long long int)nowsystime.tv_usec, ++ (long long int)targetsystime.tv_sec, (long long int)targetsystime.tv_usec, + deltavstarget, target_time_tolerance_secs, +- (int64_t)newhwtime, (int64_t)sethwtime, +- (int)((int64_t)newhwtime - (int64_t)sethwtime), +- (int64_t)refsystime.tv_sec, (int64_t)refsystime.tv_usec); ++ (long long int)newhwtime, (long long int)sethwtime, ++ (int)((long long int)newhwtime - (long long int)sethwtime), ++ (long long int)refsystime.tv_sec, (long long int)refsystime.tv_usec); + + set_hardware_clock(ctl, newhwtime); + } +@@ -644,7 +644,7 @@ set_system_clock(const struct hwclock_control *ctl, + if (ctl->hctosys) + printf(_("Calling settimeofday(%lld.%06lld, NULL) " + "to set the System time.\n"), +- (int64_t)newtime.tv_sec, (int64_t)newtime.tv_usec); ++ (long long int)newtime.tv_sec, (long long int)newtime.tv_usec); + } + + if (!ctl->testing) { +@@ -786,10 +786,10 @@ calculate_adjustment(const struct hwclock_control *ctl, + if (ctl->verbose) { + printf(P_("Time since last adjustment is %lld second\n", + "Time since last adjustment is %lld seconds\n", +- ((int64_t)systime - (int64_t)last_time)), +- ((int64_t)systime - (int64_t)last_time)); ++ ((long long int)systime - (long long int)last_time)), ++ ((long long int)systime - (long long int)last_time)); + printf(_("Calculated Hardware Clock drift is %lld.%06lld seconds\n"), +- (int64_t)tdrift_p->tv_sec, (int64_t)tdrift_p->tv_usec); ++ (long long int)tdrift_p->tv_sec, (long long int)tdrift_p->tv_usec); + } + } + +@@ -807,9 +807,9 @@ static int save_adjtime(const struct hwclock_control *ctl, + + xasprintf(&content, "%f %lld %f\n%lld\n%s\n", + adjtime->drift_factor, +- (int64_t)adjtime->last_adj_time, ++ (long long int)adjtime->last_adj_time, + adjtime->not_adjusted, +- (int64_t)adjtime->last_calib_time, ++ (long long int)adjtime->last_calib_time, + (adjtime->local_utc == LOCAL) ? "LOCAL" : "UTC"); + + if (ctl->verbose){ +@@ -945,8 +945,8 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time, + hclocktime = time_inc(hclocktime, (double) + -(tdrift.tv_sec + tdrift.tv_usec / 1E6)); + if (ctl->verbose) { +- printf(_ ("Target date: %lld\n"), (int64_t)set_time); +- printf(_ ("Predicted RTC: %lld\n"), (int64_t)hclocktime.tv_sec); ++ printf(_ ("Target date: %lld\n"), (long long int)set_time); ++ printf(_ ("Predicted RTC: %lld\n"), (long long int)hclocktime.tv_sec); + } + return display_time(hclocktime); + } +@@ -1356,7 +1356,7 @@ int main(int argc, char **argv) + if (ctl.verbose) { + out_version(); + printf(_("System Time: %lld.%06lld\n"), +- (int64_t)startup_time.tv_sec, (int64_t)startup_time.tv_usec); ++ (long long int)startup_time.tv_sec, (long long int)startup_time.tv_usec); + } + + if (!ctl.systz && !ctl.predict) +-- +2.43.5 + diff --git a/3004-Fixed-wrongful-time_t-long-assumptions-in-hwclock.c-.patch b/3004-Fixed-wrongful-time_t-long-assumptions-in-hwclock.c-.patch new file mode 100644 index 0000000000000000000000000000000000000000..b442f8a1ebb007efc3bcacd016a69907f4393ef8 --- /dev/null +++ b/3004-Fixed-wrongful-time_t-long-assumptions-in-hwclock.c-.patch @@ -0,0 +1,293 @@ +From f9fc7ab6bb50c669a76a44d092a1330a69e0c65b Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 20 Feb 2025 15:53:29 +0800 +Subject: [PATCH] Fixed wrongful time_t=long assumptions in hwclock.c and + timeutils.c + +from upstream #ce3355cc54d97711bc240783324f7ab51fd6e371 + +Signed-off-by: Weisson +--- + lib/timeutils.c | 9 ++-- + sys-utils/hwclock.c | 115 +++++++++++++++++++++----------------------- + 2 files changed, 59 insertions(+), 65 deletions(-) + +diff --git a/lib/timeutils.c b/lib/timeutils.c +index d403ced..1d8b150 100644 +--- a/lib/timeutils.c ++++ b/lib/timeutils.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include "c.h" + #include "nls.h" +@@ -432,14 +433,14 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf + } + + if (flags & ISO_DOTUSEC) { +- len = snprintf(p, bufsz, ".%06ld", (long) usec); ++ len = snprintf(p, bufsz, ".%06"PRId64, (int64_t) usec); + if (len < 0 || (size_t) len > bufsz) + goto err; + bufsz -= len; + p += len; + + } else if (flags & ISO_COMMAUSEC) { +- len = snprintf(p, bufsz, ",%06ld", (long) usec); ++ len = snprintf(p, bufsz, ",%06"PRId64, (int64_t) usec); + if (len < 0 || (size_t) len > bufsz) + goto err; + bufsz -= len; +@@ -474,7 +475,7 @@ int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz) + if (rc) + return format_iso_time(&tm, tv->tv_usec, flags, buf, bufsz); + +- warnx(_("time %ld is out of range."), tv->tv_sec); ++ warnx(_("time %"PRId64" is out of range."), (int64_t)(tv->tv_sec)); + return -1; + } + +@@ -498,7 +499,7 @@ int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz) + if (rc) + return format_iso_time(&tm, 0, flags, buf, bufsz); + +- warnx(_("time %ld is out of range."), (long)t); ++ warnx(_("time %"PRId64" is out of range."), (int64_t)*t); + return -1; + } + +diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c +index b45b191..d6de6b0 100644 +--- a/sys-utils/hwclock.c ++++ b/sys-utils/hwclock.c +@@ -218,6 +218,8 @@ static int read_adjtime(const struct hwclock_control *ctl, + char line1[81]; /* String: first line of adjtime file */ + char line2[81]; /* String: second line of adjtime file */ + char line3[81]; /* String: third line of adjtime file */ ++ int64_t last_adj_time; ++ int64_t last_calib_time; + + if (access(ctl->adj_file_name, R_OK) != 0) + return EXIT_SUCCESS; +@@ -237,21 +239,15 @@ static int read_adjtime(const struct hwclock_control *ctl, + + fclose(adjfile); + +- if (sizeof(time_t) > 4) { +- sscanf(line1, "%lf %lld %lf", +- &adjtime_p->drift_factor, +- (long long int*)&adjtime_p->last_adj_time, +- &adjtime_p->not_adjusted); ++ sscanf(line1, "%lf %"SCNd64" %lf", ++ &adjtime_p->drift_factor, ++ &last_adj_time, ++ &adjtime_p->not_adjusted); + +- sscanf(line2, "%lld", (long long int*)&adjtime_p->last_calib_time); +- } else { +- sscanf(line1, "%lf %ld %lf", +- &adjtime_p->drift_factor, +- (long*)&adjtime_p->last_adj_time, +- &adjtime_p->not_adjusted); ++ sscanf(line2, "%"SCNd64, &last_calib_time); + +- sscanf(line2, "%ld", (long*)&adjtime_p->last_calib_time); +- } ++ adjtime_p->last_adj_time = (time_t)last_adj_time; ++ adjtime_p->last_calib_time = (time_t)last_calib_time; + + if (!strcmp(line3, "UTC\n")) { + adjtime_p->local_utc = UTC; +@@ -266,11 +262,10 @@ static int read_adjtime(const struct hwclock_control *ctl, + } + + if (ctl->verbose) { +- printf(_ +- ("Last drift adjustment done at %lld seconds after 1969\n"), +- (long long int)adjtime_p->last_adj_time); +- printf(_("Last calibration done at %lld seconds after 1969\n"), +- (long long int)adjtime_p->last_calib_time); ++ printf(_("Last drift adjustment done at %"PRId64" seconds after 1969\n"), ++ (int64_t)adjtime_p->last_adj_time); ++ printf(_("Last calibration done at %"PRId64" seconds after 1969\n"), ++ (int64_t)adjtime_p->last_calib_time); + printf(_("Hardware clock is on %s time\n"), + (adjtime_p->local_utc == + LOCAL) ? _("local") : (adjtime_p->local_utc == +@@ -354,11 +349,10 @@ mktime_tz(const struct hwclock_control *ctl, struct tm tm, + } else { + valid = 1; + if (ctl->verbose) +- printf(_ +- ("Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = " +- "%lld seconds since 1969\n"), tm.tm_year + 1900, ++ printf(_("Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = " ++ "%"PRId64" seconds since 1969\n"), tm.tm_year + 1900, + tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, +- tm.tm_sec, (long long int)*systime_p); ++ tm.tm_sec, (int64_t)*systime_p); + } + return valid; + } +@@ -381,8 +375,7 @@ read_hardware_clock(const struct hwclock_control *ctl, + return err; + + if (ctl->verbose) +- printf(_ +- ("Time read from Hardware Clock: %4d/%.2d/%.2d %02d:%02d:%02d\n"), ++ printf(_("Time read from Hardware Clock: %4d/%.2d/%.2d %02d:%02d:%02d\n"), + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, + tm.tm_min, tm.tm_sec); + *valid_p = mktime_tz(ctl, tm, systime_p); +@@ -410,9 +403,9 @@ set_hardware_clock(const struct hwclock_control *ctl, const time_t newtime) + + if (ctl->verbose) + printf(_("Setting Hardware Clock to %.2d:%.2d:%.2d " +- "= %lld seconds since 1969\n"), ++ "= %"PRId64" seconds since 1969\n"), + new_broken_time.tm_hour, new_broken_time.tm_min, +- new_broken_time.tm_sec, (long long int)newtime); ++ new_broken_time.tm_sec, (int64_t)newtime); + + if (!ctl->testing) + ur->set_hardware_clock(ctl, &new_broken_time); +@@ -512,17 +505,17 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + if (ticksize < 0) { + if (ctl->verbose) + printf(_("time jumped backward %.6f seconds " +- "to %lld.%06lld - retargeting\n"), +- ticksize, (long long int)nowsystime.tv_sec, +- (long long int)nowsystime.tv_usec); ++ "to %"PRId64".%06"PRId64" - retargeting\n"), ++ ticksize, (int64_t)nowsystime.tv_sec, ++ (int64_t)nowsystime.tv_usec); + /* The retarget is handled at the end of the loop. */ + } else if (deltavstarget < 0) { + /* deltavstarget < 0 if current time < target time */ + DBG(DELTA_VS_TARGET, +- ul_debug("%lld.%06lld < %lld.%06lld (%.6f)", +- (long long int)nowsystime.tv_sec, (long long int)nowsystime.tv_usec, +- (long long int)targetsystime.tv_sec, +- (long long int)targetsystime.tv_usec, deltavstarget)); ++ ul_debug("%"PRId64".%06"PRId64" < %"PRId64".%06"PRId64" (%.6f)", ++ (int64_t)nowsystime.tv_sec, (int64_t)nowsystime.tv_usec, ++ (int64_t)targetsystime.tv_sec, ++ (int64_t)targetsystime.tv_usec, deltavstarget)); + continue; /* not there yet - keep spinning */ + } else if (deltavstarget <= target_time_tolerance_secs) { + /* Close enough to the target time; done waiting. */ +@@ -533,12 +526,12 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + * aim for the next opportunity. + */ + if (ctl->verbose) +- printf(_("missed it - %lld.%06lld is too far " +- "past %lld.%06lld (%.6f > %.6f)\n"), +- (long long int)nowsystime.tv_sec, +- (long long int)nowsystime.tv_usec, +- (long long int)targetsystime.tv_sec, +- (long long int)targetsystime.tv_usec, ++ printf(_("missed it - %"PRId64".%06"PRId64" is too far " ++ "past %"PRId64".%06"PRId64" (%.6f > %.6f)\n"), ++ (int64_t)nowsystime.tv_sec, ++ (int64_t)nowsystime.tv_usec, ++ (int64_t)targetsystime.tv_sec, ++ (int64_t)targetsystime.tv_usec, + deltavstarget, + target_time_tolerance_secs); + target_time_tolerance_secs += tolerance_incr_secs; +@@ -561,14 +554,14 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + - RTC_SET_DELAY_SECS /* don't count this */ + + 0.5 /* for rounding */); + if (ctl->verbose) +- printf(_("%lld.%06lld is close enough to %lld.%06lld (%.6f < %.6f)\n" +- "Set RTC to %lld (%lld + %d; refsystime = %lld.%06lld)\n"), +- (long long int)nowsystime.tv_sec, (long long int)nowsystime.tv_usec, +- (long long int)targetsystime.tv_sec, (long long int)targetsystime.tv_usec, ++ printf(_("%"PRId64".%06"PRId64" is close enough to %"PRId64".%06"PRId64" (%.6f < %.6f)\n" ++ "Set RTC to %"PRId64" (%"PRId64" + %d; refsystime = %"PRId64".%06"PRId64")\n"), ++ (int64_t)nowsystime.tv_sec, (int64_t)nowsystime.tv_usec, ++ (int64_t)targetsystime.tv_sec, (int64_t)targetsystime.tv_usec, + deltavstarget, target_time_tolerance_secs, +- (long long int)newhwtime, (long long int)sethwtime, +- (int)((long long int)newhwtime - (long long int)sethwtime), +- (long long int)refsystime.tv_sec, (long long int)refsystime.tv_usec); ++ (int64_t)newhwtime, (int64_t)sethwtime, ++ (int)((int64_t)newhwtime - (int64_t)sethwtime), ++ (int64_t)refsystime.tv_sec, (int64_t)refsystime.tv_usec); + + set_hardware_clock(ctl, newhwtime); + } +@@ -642,9 +635,9 @@ set_system_clock(const struct hwclock_control *ctl, + minuteswest); + + if (ctl->hctosys) +- printf(_("Calling settimeofday(%lld.%06lld, NULL) " ++ printf(_("Calling settimeofday(%"PRId64".%06"PRId64", NULL) " + "to set the System time.\n"), +- (long long int)newtime.tv_sec, (long long int)newtime.tv_usec); ++ (int64_t)newtime.tv_sec, (int64_t)newtime.tv_usec); + } + + if (!ctl->testing) { +@@ -784,12 +777,12 @@ calculate_adjustment(const struct hwclock_control *ctl, + tdrift_p->tv_usec = (exact_adjustment - + (double)tdrift_p->tv_sec) * 1E6; + if (ctl->verbose) { +- printf(P_("Time since last adjustment is %lld second\n", +- "Time since last adjustment is %lld seconds\n", +- ((long long int)systime - (long long int)last_time)), +- ((long long int)systime - (long long int)last_time)); +- printf(_("Calculated Hardware Clock drift is %lld.%06lld seconds\n"), +- (long long int)tdrift_p->tv_sec, (long long int)tdrift_p->tv_usec); ++ printf(P_("Time since last adjustment is %"PRId64" second\n", ++ "Time since last adjustment is %"PRId64" seconds\n", ++ ((int64_t)systime - (int64_t)last_time)), ++ ((int64_t)systime - (int64_t)last_time)); ++ printf(_("Calculated Hardware Clock drift is %"PRId64".%06"PRId64" seconds\n"), ++ (int64_t)tdrift_p->tv_sec, (int64_t)tdrift_p->tv_usec); + } + } + +@@ -805,11 +798,11 @@ static int save_adjtime(const struct hwclock_control *ctl, + char *content; /* Stuff to write to disk file */ + FILE *fp; + +- xasprintf(&content, "%f %lld %f\n%lld\n%s\n", ++ xasprintf(&content, "%f %"PRId64" %f\n%"PRId64"\n%s\n", + adjtime->drift_factor, +- (long long int)adjtime->last_adj_time, ++ (int64_t)adjtime->last_adj_time, + adjtime->not_adjusted, +- (long long int)adjtime->last_calib_time, ++ (int64_t)adjtime->last_calib_time, + (adjtime->local_utc == LOCAL) ? "LOCAL" : "UTC"); + + if (ctl->verbose){ +@@ -945,8 +938,8 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time, + hclocktime = time_inc(hclocktime, (double) + -(tdrift.tv_sec + tdrift.tv_usec / 1E6)); + if (ctl->verbose) { +- printf(_ ("Target date: %lld\n"), (long long int)set_time); +- printf(_ ("Predicted RTC: %lld\n"), (long long int)hclocktime.tv_sec); ++ printf(_("Target date: %"PRId64"\n"), (int64_t)set_time); ++ printf(_("Predicted RTC: %"PRId64"\n"), (int64_t)hclocktime.tv_sec); + } + return display_time(hclocktime); + } +@@ -1355,8 +1348,8 @@ int main(int argc, char **argv) + + if (ctl.verbose) { + out_version(); +- printf(_("System Time: %lld.%06lld\n"), +- (long long int)startup_time.tv_sec, (long long int)startup_time.tv_usec); ++ printf(_("System Time: %"PRId64".%06"PRId64"\n"), ++ (int64_t)startup_time.tv_sec, (int64_t)startup_time.tv_usec); + } + + if (!ctl.systz && !ctl.predict) +-- +2.43.5 + diff --git a/util-linux.spec b/util-linux.spec index 62e573ecb99d1dae3b21dcb08584531c51bf0024..4dcd2235c38dd830d88a36f8e12b460908d0dcdf 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.3 +%define anolis_release .0.4 ### Header Summary: A collection of basic system utilities Name: util-linux @@ -321,6 +321,12 @@ Patch2001: 0001-prlimit-fix-optional-arguments-parsing.patch Patch3000: 3000-lscpu-add-alibaba-hyperv-vendor.patch Patch3001: 3001-lscpu-optimize-query-virt-pci-device.patch +# Bugfix: 18732 +# from upstream: https://github.com/util-linux/util-linux/pull/1294 +Patch3002: 3002-Fixed-format-strings-and-type-casts-in-hwclock-to-wo.patch +Patch3003: 3003-Changed-int64_t-casts-to-long-long-int-casts.patch +Patch3004: 3004-Fixed-wrongful-time_t-long-assumptions-in-hwclock.c-.patch + %description The util-linux package contains a large variety of low-level system utilities that are necessary for a Linux system to function. Among @@ -1167,6 +1173,10 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Thu Feb 20 2025 Weisson 2.23.1-46.0.4 +- bugfix: anbz 18732. +- from upstream: https://github.com/util-linux/util-linux/pull/1294. + * Mon Sep 02 2024 Guixin Liu 2.23.1-46.0.3 - [Patch] lscpu: optimize find virt pci device (kanie@linux.alibaba.com)