aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorPatrick Oppenlander <patrick.oppenlander@gmail.com>2020-10-15 12:50:40 +1100
committerRob Landley <rob@landley.net>2020-10-15 23:01:52 -0500
commit55edd44d8f351606b948347c1c78263c054eaf89 (patch)
tree3ff1e7cae2bf3cd301eced883d97fad12b59a254 /toys/other
parent6e331aef7f2ce0c6f905ab099028d8cf8f91b1a0 (diff)
downloadtoybox-55edd44d8f351606b948347c1c78263c054eaf89.tar.gz
hwclock: default to UTC if /etc/adjtime can't be read
This is consistent with the util-linux implementation.
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/hwclock.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c
index ba28cc3d..a6db923a 100644
--- a/toys/other/hwclock.c
+++ b/toys/other/hwclock.c
@@ -40,10 +40,8 @@ void hwclock_main()
if (FLAG(u)) utc = 1;
else if (FLAG(l)) utc = 0;
- else {
- xreadfile("/etc/adjtime", toybuf, sizeof(toybuf));
- utc = !!strstr(toybuf, "UTC");
- }
+ else utc = !readfile("/etc/adjtime", toybuf, sizeof(toybuf)) ||
+ !!strstr(toybuf, "UTC");
if (!FLAG(t)) {
if (!TT.f) TT.f = "/dev/rtc0";