exit(retval);
}
-static int may_wakeup(const char *devname)
+static int is_wakeup_enabled(const char *devname)
{
char buf[128], *s;
FILE *f;
*/
if (ioctl(fd, RTC_RD_TIME, &rtc) < 0) {
perror(_("read rtc time"));
- return 0;
+ return -1;
}
sys_time = time(0);
if (sys_time == (time_t)-1) {
perror(_("read system time"));
- return 0;
+ return -1;
}
/* convert rtc_time to normal arithmetic-friendly form,
if (rtc_time == (time_t)-1) {
perror(_("convert rtc time"));
- return 0;
+ return -1;
}
if (verbose) {
(long) rtc_time, asctime(&tm));
}
- return 1;
+ return 0;
}
static int setup_alarm(int fd, time_t *wakeup)
}
}
- return 1;
+ return 0;
}
static void suspend_system(const char *suspend)
fp = fopen(ADJTIME_PATH, "r");
if (!fp)
- return 0;
+ return -1;
/* skip first line */
if (!fgets(linebuf, MAX_LINE, fp)) {
fclose(fp);
- return 0;
+ return -1;
}
/* skip second line */
if (!fgets(linebuf, MAX_LINE, fp)) {
fclose(fp);
- return 0;
+ return -1;
}
/* read third line */
if (!fgets(linebuf, MAX_LINE, fp)) {
fclose(fp);
- return 0;
+ return -1;
}
if (strncmp(linebuf, "UTC", 3) == 0)
fclose(fp);
- return 1;
+ return 0;
}
int main(int argc, char **argv)
}
if (clock_mode == CM_AUTO) {
- if (!read_clock_mode()) {
+ if (read_clock_mode() < 0) {
printf(_("%s: assuming RTC uses UTC ...\n"), progname);
clock_mode = CM_UTC;
}
devname = new_devname;
}
- if (strcmp(suspend, "on") != 0 && !may_wakeup(devname)) {
+ if (strcmp(suspend, "on") != 0 && !is_wakeup_enabled(devname)) {
fprintf(stderr, _("%s: %s not enabled for wakeup events\n"),
progname, devname);
exit(EXIT_FAILURE);
}
/* relative or absolute alarm time, normalized to time_t */
- if (!get_basetimes(fd))
+ if (get_basetimes(fd) < 0)
exit(EXIT_FAILURE);
if (verbose)
printf(_("alarm %ld, sys_time %ld, rtc_time %ld, seconds %u\n"),