[Git][NTPsec/ntpsec][master] timespec's tv_nsec is a long, so no need to cast it.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Sep 27 15:55:11 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
422c4c73 by Matt Selsky at 2016-09-27T09:35:12-04:00
timespec's tv_nsec is a long, so no need to cast it.

Also, fix up printf format string to use %ld, instead of %lu.

- - - - -


4 changed files:

- ntpd/ntp_intercept.c
- ntpd/refclock_oncore.c
- ntpd/refclock_shm.c
- tests/libntp/timespecops.c


Changes:

=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -361,7 +361,7 @@ void intercept_get_systime(const char *legend, l_fp *now)
 	normalize_time(ts, sys_fuzz > 0.0 ? ntp_random() : 0, now);
 	if (mode == capture)
 	    printf("systime %s %ld.%ld\n",
-		   legend, (long)ts.tv_sec, (long)ts.tv_nsec);
+		   legend, (long)ts.tv_sec, ts.tv_nsec);
 
     }
 }
@@ -603,7 +603,7 @@ int intercept_set_tod(struct timespec *tvs)
 {
     char newset[BUFSIZ];
     snprintf(newset, sizeof(newset),
-	     "set_tod %ld %ld\n", (long)tvs->tv_sec, (long)tvs->tv_nsec);
+	     "set_tod %ld %ld\n", (long)tvs->tv_sec, tvs->tv_nsec);
     
     if (mode == replay) {
 	get_operation("set_tod");


=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -1645,7 +1645,7 @@ oncore_get_timestamp(
 			oncore_log_f(instance, LOG_DEBUG,
 				     "serial/j (%lu, %lu) %ld.%09ld", i,
 				     j, (long)tsp->tv_sec,
-				     (long)tsp->tv_nsec);
+				     tsp->tv_nsec);
 		}
 #endif
 
@@ -1667,7 +1667,7 @@ oncore_get_timestamp(
 			oncore_log_f(instance, LOG_DEBUG,
 				     "serial/j (%lu, %lu) %ld.%09ld", i,
 				     j, (long)tsp->tv_sec,
-				     (long)tsp->tv_nsec);
+				     tsp->tv_nsec);
 		}
 #endif
 


=====================================
ntpd/refclock_shm.c
=====================================
--- a/ntpd/refclock_shm.c
+++ b/ntpd/refclock_shm.c
@@ -531,7 +531,7 @@ shm_timer(
 		     "%04u-%02u-%02uT%02u:%02u:%02u.%09ldZ",
 		     cd.year, cd.month, cd.monthday,
 		     cd.hour, cd.minute, cd.second,
-		     (long)shm_stat.tvt.tv_nsec);
+		     shm_stat.tvt.tv_nsec);
 	pp->lencode = (c < (int)sizeof(pp->a_lastcode)) ? c : 0;
 
 	/* check 1: age control of local time stamp */


=====================================
tests/libntp/timespecops.c
=====================================
--- a/tests/libntp/timespecops.c
+++ b/tests/libntp/timespecops.c
@@ -99,10 +99,10 @@ static bool AssertTimespecClose(const struct timespec m, const struct timespec n
 		return true;
 	else
 	{
-		printf("m_expr which is %ld.%lu \nand\nn_expr which is %ld.%lu\nare not close; diff=%ld.%lunsec\n",
+		printf("m_expr which is %ld.%ld \nand\nn_expr which is %ld.%ld\nare not close; diff=%ld.%ldnsec\n",
 		       (long)m.tv_sec, m.tv_nsec,
 		       (long)n.tv_sec, n.tv_nsec,
-		       (long)diff.tv_sec, diff.tv_nsec); 
+		       (long)diff.tv_sec, diff.tv_nsec);
 		return false;
 	}
 }



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/422c4c7301608b35e3b00651bdfe3a68bef1eb14
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160927/d23c0d30/attachment.html>


More information about the vc mailing list