[ntpsec commit] Cleanup - consistent return type for adj_systtime() and step_systime().

Eric S. Raymond esr at ntpsec.org
Tue Oct 13 09:59:42 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    e0c4f820b8b9b4d7cb40efcf4ce15dacc826f2fd
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=e0c4f820b8b9b4d7cb40efcf4ce15dacc826f2fd

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Tue Oct 13 01:08:28 2015 -0400

Cleanup - consistent return type for adj_systtime() and step_systime().

---

 include/ntp_fp.h                 | 4 ++--
 libntp/systime.c                 | 4 ++--
 ports/winnt/ntpd/nt_clockstuff.c | 6 +++---
 sntp/main.c                      | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/ntp_fp.h b/include/ntp_fp.h
index d9ea4ec..16e7323 100644
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -355,8 +355,8 @@ extern	void	init_systime	(void);
 extern  void	get_ostime	(struct timespec *tsp);
 extern	void	normalize_time	(struct timespec, long, l_fp *);
 extern	void	get_systime	(l_fp *);
-extern	int	step_systime	(double);
-extern	int	adj_systime	(double);
+extern	bool	step_systime	(double);
+extern	bool	adj_systime	(double);
 
 extern	struct tm * ntp2unix_tm (uint32_t ntp, int local);
 
diff --git a/libntp/systime.c b/libntp/systime.c
index ea7dc78..f8703f4 100644
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -322,7 +322,7 @@ normalize_time(
  * adj_systime - adjust system time by the argument.
  */
 #if !defined SYS_WINNT
-int				/* 0 okay, 1 error */
+bool				/* true on okay, false on error */
 adj_systime(
 	double now		/* adjustment (s) */
 	)
@@ -393,7 +393,7 @@ adj_systime(
  * step_systime - step the system clock.
  */
 
-int
+bool
 step_systime(
 	double step
 	)
diff --git a/ports/winnt/ntpd/nt_clockstuff.c b/ports/winnt/ntpd/nt_clockstuff.c
index 7c8d5b5..47beb58 100644
--- a/ports/winnt/ntpd/nt_clockstuff.c
+++ b/ports/winnt/ntpd/nt_clockstuff.c
@@ -454,9 +454,9 @@ set_mm_timer(
  * threshold, 128 msec by default.  For the remainder of the frequency
  * training interval, adj_systime is called with 0 offset each second
  * and slew the large offset at 500 PPM (500 usec/sec).
- * Returns 1 if okay, 0 if trouble.
+ * Returns true if okay, false if trouble.
  */
-int
+bool
 adj_systime(
 	double now
 	)
@@ -632,7 +632,7 @@ adj_systime(
 		rc = TRUE;
 	}
 
-	return rc;
+	return (bool)rc;
 }
 
 
diff --git a/sntp/main.c b/sntp/main.c
index a764cda..c9927c8 100644
--- a/sntp/main.c
+++ b/sntp/main.c
@@ -1505,7 +1505,7 @@ set_time(
 	double offset
 	)
 {
-	int rc;
+	bool rc;
 
 	if (time_adjusted)
 		return EXIT_SUCCESS;
@@ -1538,7 +1538,7 @@ set_time(
 		rc = adj_systime(offset);
 
 		/* If there was a problem, can we rely on errno? */
-		if (1 == rc)
+		if (rc)
 			time_adjusted = true;
 		return (time_adjusted)
 			   ? EXIT_SUCCESS



More information about the vc mailing list