summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSami Kerola2015-01-10 19:03:25 +0100
committerKarel Zak2015-06-29 13:39:37 +0200
commit3e5a54554dd1495d10427163e911c24ba4c9e558 (patch)
treed4a667f77e0d2c20d0fbb211e866c3f4dd6ac181 /lib
parentrtcwake: remove RTC_ALM_READ and RTC_ALM_SET compatibility (diff)
downloadkernel-qcow2-util-linux-3e5a54554dd1495d10427163e911c24ba4c9e558.tar.gz
kernel-qcow2-util-linux-3e5a54554dd1495d10427163e911c24ba4c9e558.tar.xz
kernel-qcow2-util-linux-3e5a54554dd1495d10427163e911c24ba4c9e558.zip
rtcwake: improve read_clock_mode()
Make skipping two lines more robust, and add message about unexpected adjfile contents when running with --verbose. Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'lib')
-rw-r--r--lib/strutils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/strutils.c b/lib/strutils.c
index cc90e043d..ebfc5110b 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -859,6 +859,18 @@ const char *split(const char **state, size_t *l, const char *separator, int quot
return current;
}
+/* Rewind file pointer forward to new line. */
+int skip_fline(FILE *fp)
+{
+ char ch;
+
+ do {
+ if ((ch = fgetc(fp)) == EOF)
+ return 1;
+ if (ch == '\n')
+ return 0;
+ } while (1);
+}
#ifdef TEST_PROGRAM