if (use_dev_port) {
unsigned char v = reg | 0x80;
lseek(dev_port_fd, clock_ctl_addr, 0);
- write(dev_port_fd, &v, 1);
+ if (write(dev_port_fd, &v, 1) == -1 && debug)
+ printf("cmos_read(): write to control address %X failed: %s\n", clock_ctl_addr, strerror(errno));
lseek(dev_port_fd, clock_data_addr, 0);
- read(dev_port_fd, &v, 1);
+ if (read(dev_port_fd, &v, 1) == -1 && debug)
+ printf("cmos_read(): read data address %X failed: %s\n", clock_data_addr, strerror(errno));
return v;
} else {
/* We only want to read CMOS data, but unfortunately
if (use_dev_port) {
unsigned char v = reg | 0x80;
lseek(dev_port_fd, clock_ctl_addr, 0);
- write(dev_port_fd, &v, 1);
+ if (write(dev_port_fd, &v, 1) == -1 && debug)
+ printf("cmos_write(): write to control address %X failed: %s\n", clock_ctl_addr, strerror(errno));
v = (val & 0xff);
lseek(dev_port_fd, clock_data_addr, 0);
- write(dev_port_fd, &v, 1);
+ if (write(dev_port_fd, &v, 1) == -1 && debug)
+ printf("cmos_write(): write to data address %X failed: %s\n", clock_data_addr, strerror(errno));
} else {
outb (reg, clock_ctl_addr);
outb (val, clock_data_addr);
char line3[81]; /* String: third line of adjtime file */
long timeval;
- line1[0] = '\0'; /* In case fgets fails */
- fgets(line1, sizeof(line1), adjfile);
- line2[0] = '\0'; /* In case fgets fails */
- fgets(line2, sizeof(line2), adjfile);
- line3[0] = '\0'; /* In case fgets fails */
- fgets(line3, sizeof(line3), adjfile);
+ if (!fgets(line1, sizeof(line1), adjfile))
+ line1[0] = '\0'; /* In case fgets fails */
+ if (!fgets(line2, sizeof(line2), adjfile))
+ line2[0] = '\0'; /* In case fgets fails */
+ if (!fgets(line3, sizeof(line3), adjfile))
+ line3[0] = '\0'; /* In case fgets fails */
fclose(adjfile);
return 10;
}
- date_resp[0] = '\0'; /* in case fgets fails */
- fgets(date_resp, sizeof(date_resp), date_child_fp);
+ if (!fgets(date_resp, sizeof(date_resp), date_child_fp))
+ date_resp[0] = '\0'; /* in case fgets fails */
if (debug)
printf(_("response from date command = %s\n"), date_resp);
if (strncmp(date_resp, magic, sizeof(magic)-1) != 0) {
struct timeval startup_time;
/* The time we started up, in seconds into the epoch, including
fractions. */
- time_t set_time; /* Time to which user said to set Hardware Clock */
+ time_t set_time = 0; /* Time to which user said to set Hardware Clock */
bool permitted; /* User is permitted to do the function */
int rc, c;