svn commit: r328956 - in head/sys: kern sys
Ian Lepore
ian at FreeBSD.org
Tue Feb 6 22:17:02 UTC 2018
Author: ian
Date: Tue Feb 6 22:17:01 2018
New Revision: 328956
URL: https://svnweb.freebsd.org/changeset/base/328956
Log:
Use const pointers for input data not modified by clock utility functions.
Modified:
head/sys/kern/subr_clock.c
head/sys/kern/subr_fattime.c
head/sys/sys/clock.h
Modified: head/sys/kern/subr_clock.c
==============================================================================
--- head/sys/kern/subr_clock.c Tue Feb 6 22:13:40 2018 (r328955)
+++ head/sys/kern/subr_clock.c Tue Feb 6 22:17:01 2018 (r328956)
@@ -132,7 +132,7 @@ leapyear(int year)
}
static void
-print_ct(struct clocktime *ct)
+print_ct(const struct clocktime *ct)
{
printf("[%04d-%02d-%02d %02d:%02d:%02d]",
ct->year, ct->mon, ct->day,
@@ -140,7 +140,7 @@ print_ct(struct clocktime *ct)
}
int
-clock_ct_to_ts(struct clocktime *ct, struct timespec *ts)
+clock_ct_to_ts(const struct clocktime *ct, struct timespec *ts)
{
int i, year, days;
@@ -200,7 +200,7 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *
}
int
-clock_bcd_to_ts(struct bcd_clocktime *bct, struct timespec *ts, bool ampm)
+clock_bcd_to_ts(const struct bcd_clocktime *bct, struct timespec *ts, bool ampm)
{
struct clocktime ct;
int bcent, byear;
@@ -249,7 +249,7 @@ clock_bcd_to_ts(struct bcd_clocktime *bct, struct time
}
void
-clock_ts_to_ct(struct timespec *ts, struct clocktime *ct)
+clock_ts_to_ct(const struct timespec *ts, struct clocktime *ct)
{
time_t i, year, days;
time_t rsec; /* remainder seconds */
@@ -310,7 +310,7 @@ clock_ts_to_ct(struct timespec *ts, struct clocktime *
}
void
-clock_ts_to_bcd(struct timespec *ts, struct bcd_clocktime *bct, bool ampm)
+clock_ts_to_bcd(const struct timespec *ts, struct bcd_clocktime *bct, bool ampm)
{
struct clocktime ct;
Modified: head/sys/kern/subr_fattime.c
==============================================================================
--- head/sys/kern/subr_fattime.c Tue Feb 6 22:13:40 2018 (r328955)
+++ head/sys/kern/subr_fattime.c Tue Feb 6 22:17:01 2018 (r328956)
@@ -137,7 +137,8 @@ static const struct {
void
-timespec2fattime(struct timespec *tsp, int utc, uint16_t *ddp, uint16_t *dtp, uint8_t *dhp)
+timespec2fattime(const struct timespec *tsp, int utc, uint16_t *ddp,
+ uint16_t *dtp, uint8_t *dhp)
{
time_t t1;
unsigned t2, l, m;
@@ -217,7 +218,8 @@ static const uint16_t daytab[64] = {
};
void
-fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp)
+fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc,
+ struct timespec *tsp)
{
unsigned day;
Modified: head/sys/sys/clock.h
==============================================================================
--- head/sys/sys/clock.h Tue Feb 6 22:13:40 2018 (r328955)
+++ head/sys/sys/clock.h Tue Feb 6 22:17:01 2018 (r328956)
@@ -88,8 +88,8 @@ struct clocktime {
long nsec; /* nano seconds */
};
-int clock_ct_to_ts(struct clocktime *, struct timespec *);
-void clock_ts_to_ct(struct timespec *, struct clocktime *);
+int clock_ct_to_ts(const struct clocktime *, struct timespec *);
+void clock_ts_to_ct(const struct timespec *, struct clocktime *);
/*
* Structure to hold the values typically reported by time-of-day clocks,
@@ -125,8 +125,8 @@ struct bcd_clocktime {
bool ispm; /* true if hour represents pm time */
};
-int clock_bcd_to_ts(struct bcd_clocktime *, struct timespec *, bool ampm);
-void clock_ts_to_bcd(struct timespec *, struct bcd_clocktime *, bool ampm);
+int clock_bcd_to_ts(const struct bcd_clocktime *, struct timespec *, bool ampm);
+void clock_ts_to_bcd(const struct timespec *, struct bcd_clocktime *, bool ampm);
/*
* Time-of-day clock functions and flags. These functions might sleep.
@@ -177,8 +177,10 @@ void clock_unregister(device_t _clockdev);
/* Traditional POSIX base year */
#define POSIX_BASE_YEAR 1970
-void timespec2fattime(struct timespec *tsp, int utc, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp);
-void fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp);
+void timespec2fattime(const struct timespec *tsp, int utc, u_int16_t *ddp,
+ u_int16_t *dtp, u_int8_t *dhp);
+void fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc,
+ struct timespec *tsp);
#endif /* _KERNEL */
More information about the svn-src-all
mailing list