From 2cd902f09f523e3a40e2bf1f5f78c9c6caae5821 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Mon, 5 Jan 2015 11:16:45 +0100 Subject: [PATCH] libc: warn on configuration errors in rtc wrapper Fixes #1336. --- repos/libports/src/lib/libc/rtc.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/repos/libports/src/lib/libc/rtc.cc b/repos/libports/src/lib/libc/rtc.cc index d9826f2565..fcbfaa341a 100644 --- a/repos/libports/src/lib/libc/rtc.cc +++ b/repos/libports/src/lib/libc/rtc.cc @@ -31,9 +31,16 @@ time_t Libc::read_rtc() { time_t rtc = 0; - int fd = open(Libc::config_rtc(), O_RDONLY); - if (fd == -1) + if (!Genode::strcmp(Libc::config_rtc(), "")) { + PWRN("%s: rtc not configured, returning %lu", __func__, rtc); return rtc; + } + + int fd = open(Libc::config_rtc(), O_RDONLY); + if (fd == -1) { + PWRN("%s: %s not readable, returning %lu", __func__, Libc::config_rtc(), rtc); + return rtc; + } char buf[32]; ssize_t n = read(fd, buf, sizeof(buf));