Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Fix the various todr_gettime() and todr_settime() fallou...



details:   https://anonhg.NetBSD.org/src/rev/464837878ff9
branches:  trunk
changeset: 581743:464837878ff9
user:      he <he%NetBSD.org@localhost>
date:      Sat Jun 04 20:14:24 2005 +0000

description:
Fix the various todr_gettime() and todr_settime() fallouts from
-Wcast-qual differently, by instead changing the signatore of those
"functions" to take a "volatile struct timeval*" instead of a
"struct timeval*".  Many places, these functions are called with
&time, and time is declared as volatile in <sys/kernel.h>.  This
way we can get rid of all the ugly casts which now also triggered
warnings, and caused more code to be added to work around the
problem.

Reviewed by thorpej.

diffstat:

 sys/arch/acorn26/ioc/rtc.c              |   6 +++---
 sys/arch/arc/arc/todclock.c             |  18 ++++++------------
 sys/arch/arm/ep93xx/epclk.c             |   8 ++++----
 sys/arch/arm/iomd/iomd_clock.c          |  20 +++++++-------------
 sys/arch/arm/xscale/becc_timer.c        |  15 +++++----------
 sys/arch/arm/xscale/i80321_timer.c      |   8 ++++----
 sys/arch/arm/xscale/ixp425_timer.c      |   8 ++++----
 sys/arch/evbarm/iq80310/iq80310_timer.c |   8 ++++----
 sys/arch/mvme68k/mvme68k/clock.c        |  18 ++++++------------
 sys/arch/mvmeppc/mvmeppc/clock.c        |  21 +++++++--------------
 sys/arch/powerpc/ibm4xx/dev/rtc.c       |   9 ++++-----
 sys/arch/prep/prep/clock.c              |   8 ++++----
 sys/arch/sbmips/sbmips/rtc.c            |   6 +++---
 sys/arch/sparc/sparc/clock.c            |  18 ++++++------------
 sys/dev/clock_subr.h                    |   8 +++++---
 sys/dev/i2c/ds1307.c                    |  10 +++++-----
 sys/dev/i2c/m41st84.c                   |  10 +++++-----
 sys/dev/i2c/m41t00.c                    |  10 +++++-----
 sys/dev/i2c/max6900.c                   |  10 +++++-----
 sys/dev/i2c/pcf8583.c                   |  10 +++++-----
 sys/dev/i2c/x1226.c                     |  12 ++++++------
 sys/dev/ic/intersil7170.c               |  12 ++++++------
 sys/dev/ic/mc146818.c                   |  12 ++++++------
 sys/dev/ic/mk48txx.c                    |  12 ++++++------
 sys/dev/ic/mm58167.c                    |  12 ++++++------
 25 files changed, 127 insertions(+), 162 deletions(-)

diffs (truncated from 1114 to 300 lines):

diff -r a509090d124f -r 464837878ff9 sys/arch/acorn26/ioc/rtc.c
--- a/sys/arch/acorn26/ioc/rtc.c        Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/acorn26/ioc/rtc.c        Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtc.c,v 1.7 2003/09/30 00:35:30 thorpej Exp $  */
+/*     $NetBSD: rtc.c,v 1.8 2005/06/04 20:14:24 he Exp $       */
 
 /*
  * Copyright (c) 2000 Ben Harris
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.7 2003/09/30 00:35:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.8 2005/06/04 20:14:24 he Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -102,6 +102,6 @@
                return;
 
        if (todr_handle != NULL &&
-           todr_settime(todr_handle, (struct timeval *)&time) != 0)
+           todr_settime(todr_handle, &time) != 0)
                printf("resettodr: failed to set time\n");
 }
diff -r a509090d124f -r 464837878ff9 sys/arch/arc/arc/todclock.c
--- a/sys/arch/arc/arc/todclock.c       Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/arc/arc/todclock.c       Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: todclock.c,v 1.7 2005/06/03 12:32:44 tsutsui Exp $ */
+/* $NetBSD: todclock.c,v 1.8 2005/06/04 20:14:24 he Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.7 2005/06/03 12:32:44 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.8 2005/06/04 20:14:24 he Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -71,7 +71,6 @@
 void
 inittodr(time_t base)
 {
-       struct timeval tv;
        int badbase, waszero;
 
        badbase = 0;
@@ -90,8 +89,8 @@
                badbase = 1;
        }
 
-       if (todr_gettime(todr_handle, &tv) != 0 ||
-           tv.tv_sec == 0) {
+       if (todr_gettime(todr_handle, &time) != 0 ||
+           time.tv_sec == 0) {
                printf("WARNING: bad date in battery clock");
                /*
                 * Believe the time in the file system for lack of
@@ -101,10 +100,7 @@
                if (!badbase)
                        resettodr();
        } else {
-               int deltat;
-
-               time = tv;
-               deltat = time.tv_sec - base;
+               int deltat = time.tv_sec - base;
 
                if (deltat < 0)
                        deltat = -deltat;
@@ -125,12 +121,10 @@
 void
 resettodr(void)
 {
-       struct timeval tv;
 
        if (time.tv_sec == 0)
                return;
 
-       tv = time;
-       if (todr_settime(todr_handle, &tv) != 0)
+       if (todr_settime(todr_handle, &time) != 0)
                printf("resettodr: cannot set time in time-of-day clock\n");
 }
diff -r a509090d124f -r 464837878ff9 sys/arch/arm/ep93xx/epclk.c
--- a/sys/arch/arm/ep93xx/epclk.c       Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/arm/ep93xx/epclk.c       Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: epclk.c,v 1.4 2005/02/26 12:00:52 simonb Exp $ */
+/*     $NetBSD: epclk.c,v 1.5 2005/06/04 20:14:24 he Exp $     */
 
 /*
  * Copyright (c) 2004 Jesse Off
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: epclk.c,v 1.4 2005/02/26 12:00:52 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: epclk.c,v 1.5 2005/06/04 20:14:24 he Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -334,7 +334,7 @@
                badbase = 0;
 
        if (todr_handle == NULL ||
-           todr_gettime(todr_handle, (struct timeval *)&time) != 0 ||
+           todr_gettime(todr_handle, &time) != 0 ||
            time.tv_sec == 0) {
                /*
                 * Believe the time in the file system for lack of
@@ -380,6 +380,6 @@
                return;
 
        if (todr_handle != NULL &&
-           todr_settime(todr_handle, (struct timeval *)&time) != 0)
+           todr_settime(todr_handle, &time) != 0)
                printf("resettodr: failed to set time\n");
 }
diff -r a509090d124f -r 464837878ff9 sys/arch/arm/iomd/iomd_clock.c
--- a/sys/arch/arm/iomd/iomd_clock.c    Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/arm/iomd/iomd_clock.c    Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iomd_clock.c,v 1.14 2005/06/04 00:47:18 chris Exp $    */
+/*     $NetBSD: iomd_clock.c,v 1.15 2005/06/04 20:14:24 he Exp $       */
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -175,7 +175,7 @@
 
 
 /*
- * void setstatclockrate(int hz)
+ * void setstatclockrate(int newhz)
  *
  * Set the stat clock rate. The stat clock uses timer1
  */
@@ -387,7 +387,6 @@
 {
        time_t deltat;
        int badbase;
-       struct timeval thetime;
 
        if (base < (MINYEAR - 1970) * SECYR) {
                printf("WARNING: preposterous time in file system");
@@ -398,8 +397,8 @@
                badbase = 0;
 
        if (todr_handle == NULL ||
-           todr_gettime(todr_handle, &thetime) != 0 ||
-           thetime.tv_sec == 0) {
+           todr_gettime(todr_handle, &time) != 0 ||
+           time.tv_sec == 0) {
                /*
                 * Believe the time in the file system for lack of
                 * anything better, resetting the TODR.
@@ -418,16 +417,14 @@
                 * See if we gained/lost two or more days; if
                 * so, assume something is amiss.
                 */
-               deltat = thetime.tv_sec - base;
+               deltat = time.tv_sec - base;
                if (deltat < 0)
                        deltat = -deltat;
                if (deltat < 2 * SECDAY)
                        return;         /* all is well */
                printf("WARNING: clock %s %ld days\n",
-                   thetime.tv_sec < base ? "lost" : "gained",
+                   time.tv_sec < base ? "lost" : "gained",
                    (long)deltat / SECDAY);
-
-               time = thetime;
        }
  bad:
        printf("WARNING: CHECK AND RESET THE DATE!\n");
@@ -441,15 +438,12 @@
 void
 resettodr(void)
 {
-       struct timeval thetime;
 
        if (time.tv_sec == 0)
                return;
 
-       thetime = time;
-
        if (todr_handle != NULL &&
-           todr_settime(todr_handle, &thetime) != 0)
+           todr_settime(todr_handle, &time) != 0)
                printf("resettodr: failed to set time\n");
 }
 
diff -r a509090d124f -r 464837878ff9 sys/arch/arm/xscale/becc_timer.c
--- a/sys/arch/arm/xscale/becc_timer.c  Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/arm/xscale/becc_timer.c  Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: becc_timer.c,v 1.7 2005/06/04 14:00:18 rearnsha Exp $  */
+/*     $NetBSD: becc_timer.c,v 1.8 2005/06/04 20:14:24 he Exp $        */
 
 /*
  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: becc_timer.c,v 1.7 2005/06/04 14:00:18 rearnsha Exp $");
+__KERNEL_RCSID(0, "$NetBSD: becc_timer.c,v 1.8 2005/06/04 20:14:24 he Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -291,7 +291,6 @@
 void
 inittodr(time_t base)
 {
-       struct timeval tv;
        time_t deltat;
        int badbase;
 
@@ -304,7 +303,7 @@
                badbase = 0;
 
        if (todr_handle == NULL ||
-           todr_gettime(todr_handle, &tv) != 0 || tv.tv_sec == 0) {
+           todr_gettime(todr_handle, &time) != 0 || time.tv_sec == 0) {
                /*
                 * Believe the time in the file system for lack of
                 * anything better, resetting the TODR.
@@ -316,8 +315,6 @@
                        resettodr();
                }
                goto bad;
-       } else {
-               time = tv;
        }
 
        if (!badbase) {
@@ -346,15 +343,13 @@
 void
 resettodr(void)
 {
-       struct timeval tv;
 
        if (time.tv_sec == 0)
                return;
 
-       if (todr_handle != NULL && todr_settime(todr_handle, &tv) != 0)
+       if (todr_handle != NULL &&
+           todr_settime(todr_handle, &time) != 0)
                printf("resettodr: failed to set time\n");
-       else
-               time = tv;
 }
 
 /*
diff -r a509090d124f -r 464837878ff9 sys/arch/arm/xscale/i80321_timer.c
--- a/sys/arch/arm/xscale/i80321_timer.c        Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/arm/xscale/i80321_timer.c        Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i80321_timer.c,v 1.9 2005/02/26 12:00:52 simonb Exp $  */
+/*     $NetBSD: i80321_timer.c,v 1.10 2005/06/04 20:14:24 he Exp $     */
 
 /*
  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i80321_timer.c,v 1.9 2005/02/26 12:00:52 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i80321_timer.c,v 1.10 2005/06/04 20:14:24 he Exp $");
 
 #include "opt_perfctrs.h"
 #include "opt_i80321.h"
@@ -357,7 +357,7 @@
                badbase = 0;
 
        if (todr_handle == NULL ||
-           todr_gettime(todr_handle, (struct timeval *)&time) != 0 ||
+           todr_gettime(todr_handle, &time) != 0 ||
            time.tv_sec == 0) {
                /*
                 * Believe the time in the file system for lack of
@@ -403,7 +403,7 @@
                return;
 
        if (todr_handle != NULL &&
-           todr_settime(todr_handle, (struct timeval *)&time) != 0)
+           todr_settime(todr_handle, &time) != 0)
                printf("resettodr: failed to set time\n");
 }
 
diff -r a509090d124f -r 464837878ff9 sys/arch/arm/xscale/ixp425_timer.c
--- a/sys/arch/arm/xscale/ixp425_timer.c        Sat Jun 04 20:09:56 2005 +0000
+++ b/sys/arch/arm/xscale/ixp425_timer.c        Sat Jun 04 20:14:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ixp425_timer.c,v 1.6 2005/02/26 12:00:52 simonb Exp $ */



Home | Main Index | Thread Index | Old Index