#include "c.h"
#include "nls.h"
+#include "pathnames.h"
#if defined(__i386__) || defined(__x86_64__)
# ifdef HAVE_SYS_IO_H
{
FILE *cpuinfo;
char field[256];
- char format[256];
+ char format[sizeof(field)];
int found = 0;
sprintf(format, "%s : %s", fmt, "%255s");
- cpuinfo = fopen("/proc/cpuinfo", "r");
+ cpuinfo = fopen(_PATH_PROC_CPUINFO, "r");
if (cpuinfo) {
do {
if (fscanf(cpuinfo, format, field) == 1) {
__attribute__((__unused__)), struct tm *tm)
{
bool got_time = FALSE;
- unsigned char status, pmbit;
-
- status = pmbit = 0; /* just for gcc */
+ unsigned char status = 0, pmbit = 0;
while (!got_time) {
/*
int rc;
if (use_dev_port) {
- if ((dev_port_fd = open("/dev/port", O_RDWR)) < 0) {
- warn(_("cannot open %s"), "/dev/port");
+ if ((dev_port_fd = open(_PATH_DEV_PORT, O_RDWR)) < 0) {
+ warn(_("cannot open %s"), _PATH_DEV_PORT);
rc = 1;
} else
rc = 0;
return rc ? 1 : 0;
}
-static struct clock_ops cmos = {
+static struct clock_ops cmos_interface = {
N_("Using direct I/O instructions to ISA clock."),
get_permissions_cmos,
read_hardware_clock_cmos,
*/
struct clock_ops *probe_for_cmos_clock(void)
{
- int have_cmos =
+ static const int have_cmos =
#if defined(__i386__) || defined(__alpha__) || defined(__x86_64__)
TRUE;
#else
FALSE;
#endif
- return have_cmos ? &cmos : NULL;
+ return have_cmos ? &cmos_interface : NULL;
}
# include <asm/rtc.h>
#endif
*/
+#ifdef __sparc__
/* The following is roughly equivalent */
struct sparc_rtc_time
{
int month; /* Month of year 1-12 */
int year; /* Year 0-99 */
};
-
#define RTCGET _IOR('p', 20, struct sparc_rtc_time)
#define RTCSET _IOW('p', 21, struct sparc_rtc_time)
+#endif
/*
* struct rtc_time is present since 1.3.99.
return 0;
}
-static struct clock_ops rtc = {
+static struct clock_ops rtc_interface = {
N_("Using the rtc interface to the clock."),
get_permissions_rtc,
read_hardware_clock_rtc,
/* return &rtc if /dev/rtc can be opened, NULL otherwise */
struct clock_ops *probe_for_rtc_clock(const struct hwclock_control *ctl)
{
- int rtc_fd = open_rtc(ctl);
- if (rtc_fd >= 0)
- return &rtc;
- if (ctl->debug)
- warn(_("cannot open rtc device"));
- return NULL;
+ const int rtc_fd = open_rtc(ctl);
+
+ if (rtc_fd < 0)
+ return NULL;
+ return &rtc_interface;
}
+#ifdef __alpha__
/*
* Get the Hardware Clock epoch setting from the kernel.
*/
return 0;
}
+#endif /* __alpha__ */