From: Bruno Haible Date: Sat, 12 Aug 2023 22:09:06 +0000 (+0200) Subject: readutmp, boot-time: Fix parsing of /proc/uptime. X-Git-Tag: v1.0~922 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8501d38f157422dc5f41495016ee6915b36acd07;p=gnulib.git readutmp, boot-time: Fix parsing of /proc/uptime. * lib/boot-time-aux.h (get_linux_uptime): Use c_strtod, not strtod. * lib/readutmp.c: Include c-strtod.h. * lib/boot-time.c: Likewise. * modules/readutmp (Depends-on): Add c-strtod. * modules/boot-time (Depends-on): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 3f47da62fb..4330034fbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-08-12 Bruno Haible + + readutmp, boot-time: Fix parsing of /proc/uptime. + * lib/boot-time-aux.h (get_linux_uptime): Use c_strtod, not strtod. + * lib/readutmp.c: Include c-strtod.h. + * lib/boot-time.c: Likewise. + * modules/readutmp (Depends-on): Add c-strtod. + * modules/boot-time (Depends-on): Likewise. + 2023-08-12 Bruno Haible readutmp: On Linux, don't fail if /var/run/utmp is not accessible. diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h index e9f58e9d7e..4c5474c6c8 100644 --- a/lib/boot-time-aux.h +++ b/lib/boot-time-aux.h @@ -48,7 +48,7 @@ get_linux_uptime (struct timespec *p_uptime) buf[n] = '\0'; /* buf now contains two values: the uptime and the idle time. */ char *endptr; - double uptime = strtod (buf, &endptr); + double uptime = c_strtod (buf, &endptr); if (endptr > buf) { p_uptime->tv_sec = (time_t) uptime; diff --git a/lib/boot-time.c b/lib/boot-time.c index d813bfa582..339ee8e938 100644 --- a/lib/boot-time.c +++ b/lib/boot-time.c @@ -43,6 +43,7 @@ # include #endif +#include "c-strtod.h" #include "idx.h" #include "readutmp.h" #include "stat-time.h" diff --git a/lib/readutmp.c b/lib/readutmp.c index ef9f0aff43..6054511edf 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -51,6 +51,7 @@ # include #endif +#include "c-strtod.h" #include "stat-time.h" #include "xalloc.h" diff --git a/modules/boot-time b/modules/boot-time index ba8a2b4e6f..8890406d6c 100644 --- a/modules/boot-time +++ b/modules/boot-time @@ -9,6 +9,7 @@ lib/readutmp.h m4/readutmp.m4 Depends-on: +c-strtod extensions fopen-gnu idx diff --git a/modules/readutmp b/modules/readutmp index 85bbf74954..fcbc7ff149 100644 --- a/modules/readutmp +++ b/modules/readutmp @@ -9,6 +9,7 @@ m4/readutmp.m4 m4/systemd.m4 Depends-on: +c-strtod extensions fopen-gnu idx