[Git][NTPsec/ntpsec][master] 9 commits: libntp: make get_ostime() static.

Gary E. Miller gitlab at mg.gitlab.com
Mon May 22 23:37:19 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
c94540bf by Gary E. Miller at 2017-05-22T15:41:23-07:00
libntp: make get_ostime() static.

- - - - -
afd9153d by Gary E. Miller at 2017-05-22T15:49:17-07:00
libntp:  add missing static to atexit_ssl_cleanup()

- - - - -
b6eadd1a by Gary E. Miller at 2017-05-22T15:52:17-07:00
libntp: remove unused finction sockaddr_masktoprefixlen()

- - - - -
a1167883 by Gary E. Miller at 2017-05-22T16:01:26-07:00
libntp: move convertRefIDToLFP() into tests/libntp, make static.

It was never used except by the test.

- - - - -
dd9c6d7c by Gary E. Miller at 2017-05-22T16:11:33-07:00
libntp: remove unused function ntp_be16enc()

- - - - -
419c47d6 by Gary E. Miller at 2017-05-22T16:14:12-07:00
libntp: remive unused function ntp_be32enc()

- - - - -
f246ff08 by Gary E. Miller at 2017-05-22T16:16:04-07:00
libntp: remove unused function ntp_be64enc()

- - - - -
6cdb133d by Gary E. Miller at 2017-05-22T16:18:51-07:00
waf: show loccount in .waf help

- - - - -
c162ad86 by Gary E. Miller at 2017-05-22T16:32:36-07:00
libntp: Move +ymd2yd() into ntp_calendar.c.

Now ntpcal_edate_to_yeardays() can be static.  Another global function
gone.

- - - - -


15 changed files:

- include/ntp_calendar.h
- include/ntp_endian.h
- include/ntp_fp.h
- include/ntp_stdlib.h
- include/refidsmear.h
- libntp/ntp_calendar.c
- libntp/ntp_endian.c
- libntp/refidsmear.c
- libntp/socktoa.c
- libntp/ssl_init.c
- libntp/systime.c
- libntp/wscript
- − libntp/ymd2yd.c
- tests/libntp/refidsmear.c
- wscript


Changes:

=====================================
include/ntp_calendar.h
=====================================
--- a/include/ntp_calendar.h
+++ b/include/ntp_calendar.h
@@ -113,16 +113,6 @@ ntpcal_etime_to_seconds(int32_t /* hours */, int32_t /* minutes */,
                         int32_t /* seconds */) __attribute__((const));
 
 /*
- * Convert ELAPSED years/months/days of gregorian calendar to elapsed
- * days in year.
- *
- * Note: This will give the true difference to the start of the given year,
- * even if months & days are off-scale.
- */
-extern int32_t
-ntpcal_edate_to_yeardays(int32_t /* years */, int32_t /* months */, int32_t /* mdays */);
-
-/*
  * Convert the date part of a 'struct tm' (that is, year, month,
  * day-of-month) into the RataDie of that day.
  */


=====================================
include/ntp_endian.h
=====================================
--- a/include/ntp_endian.h
+++ b/include/ntp_endian.h
@@ -12,10 +12,7 @@
 #include <stdint.h>
 
 uint16_t ntp_be16dec(const void *buf) __attribute__((pure));
-void ntp_be16enc(void *buf, uint16_t x);
 uint32_t ntp_be32dec(const void *buf) __attribute__((pure));
-void ntp_be32enc(void *buf, uint32_t x);
 uint64_t ntp_be64dec(const void *buf) __attribute__((pure));
-void ntp_be64enc(void *buf, uint64_t x);
 
 #endif


=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -198,7 +198,6 @@ extern	char *	rfc3339date	(const l_fp);
 extern	char *	rfc3339time     (time_t);
 
 extern	void	set_sys_fuzz	(double);
-extern  void	get_ostime	(struct timespec *tsp);
 extern	void	get_systime	(l_fp *);
 extern	bool	step_systime	(double, int (*settime)(struct timespec *));
 extern	bool	adj_systime	(double, int (*adjtime)(const struct timeval *, struct timeval *));


=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -131,7 +131,6 @@ extern	char *	numtoa		(uint32_t);
 extern	const char * socktoa	(const sockaddr_u *);
 extern	const char * sockporttoa(const sockaddr_u *);
 extern	unsigned short	sock_hash(const sockaddr_u *) __attribute__((pure));
-extern	int	sockaddr_masktoprefixlen(const sockaddr_u *);
 extern	bool	octtoint	(const char *, unsigned long *);
 extern	unsigned long	ranp2		(int);
 extern	const char *refid_str	(uint32_t, int);


=====================================
include/refidsmear.h
=====================================
--- a/include/refidsmear.h
+++ b/include/refidsmear.h
@@ -1,3 +1,2 @@
 
-extern l_fp	convertRefIDToLFP(uint32_t r) __attribute__((const));
 extern uint32_t	convertLFPToRefID(l_fp num) __attribute__((const));


=====================================
libntp/ntp_calendar.c
=====================================
--- a/libntp/ntp_calendar.c
+++ b/libntp/ntp_calendar.c
@@ -31,6 +31,8 @@ ntpcal_ntp64_to_date(struct calendar * /* jd */, const time64_t /* ntp */);
 static ntpcal_split
 ntpcal_days_in_months(int32_t /* months */);
 
+static  int32_t
+ntpcal_edate_to_yeardays(int32_t, int32_t, int32_t);
 
 systime_func_ptr
 ntpcal_set_timefunc(
@@ -742,7 +744,7 @@ ntpcal_edate_to_eradays(
  * even if months & days are off-scale.
  *---------------------------------------------------------------------
  */
-int32_t
+static int32_t
 ntpcal_edate_to_yeardays(
 	int32_t years,
 	int32_t mons,
@@ -902,4 +904,26 @@ ntpcal_ntp_to_date(
 	return ntpcal_ntp64_to_date(jd, ntp64);
 }
 
+/*
+ * ymd2yd - compute the date in the year from y/m/d
+ *
+ * A thin wrapper around a more general calendar function.
+ */
+
+int
+ymd2yd(
+	int y,
+	int m,
+	int d)
+{
+	/*
+	 * convert y/m/d to elapsed calendar units, convert that to
+	 * elapsed days since the start of the given year and convert
+	 * back to unity-based day in year.
+	 *
+	 * This does no further error checking, since the underlying
+	 * function is assumed to work out how to handle the data.
+	 */
+	return ntpcal_edate_to_yeardays(y-1, m-1, d-1) + 1;
+}
 /* -*-EOF-*- */


=====================================
libntp/ntp_endian.c
=====================================
--- a/libntp/ntp_endian.c
+++ b/libntp/ntp_endian.c
@@ -16,13 +16,6 @@ uint16_t ntp_be16dec(const void *buf) {
           (uint16_t)(b[1]);
 }
 
-void ntp_be16enc(void *buf, uint16_t x) {
-	uint8_t *b = (uint8_t*)buf;
-
-	b[0] = (x >> 8) & 0xff;
-	b[1] = x & 0xff;
-}
-
 uint32_t ntp_be32dec(const void *buf) {
 	const uint8_t *b = (const uint8_t*)buf;
 	return ((uint32_t)(b[0]) << 24) +
@@ -31,14 +24,6 @@ uint32_t ntp_be32dec(const void *buf) {
 	    (uint32_t)(b[3]);
 }
 
-void ntp_be32enc(void *buf, uint32_t x) {
-	uint8_t *b = (uint8_t*)buf;
-	b[0] = (x >> 24) & 0xff;
-	b[1] = (x >> 16) & 0xff;
-	b[2] = (x >> 8) & 0xff;
-	b[3] = x & 0xff;
-}
-
 uint64_t ntp_be64dec(const void *buf) {
 	const uint8_t *b = (const uint8_t*)buf;
 	return ((uint64_t)(b[0]) << 56) +
@@ -50,15 +35,3 @@ uint64_t ntp_be64dec(const void *buf) {
 	    ((uint64_t)(b[6]) << 8) +
 	    (uint64_t)(b[7]);
 }
-
-void ntp_be64enc(void *buf, uint64_t x) {
-	uint8_t *b = (uint8_t*)buf;
-	b[0] = (x >> 56) & 0xff;
-	b[1] = (x >> 48) & 0xff;
-	b[2] = (x >> 40) & 0xff;
-	b[3] = (x >> 32) & 0xff;
-	b[4] = (x >> 24) & 0xff;
-	b[5] = (x >> 16) & 0xff;
-	b[6] = (x >> 8) & 0xff;
-	b[7] = x & 0xff;
-}


=====================================
libntp/refidsmear.c
=====================================
--- a/libntp/refidsmear.c
+++ b/libntp/refidsmear.c
@@ -13,26 +13,6 @@
  *
  */
 
-
-l_fp
-convertRefIDToLFP(uint32_t r)
-{
-	l_fp temp = 0;
-
-	r = ntohl(r);
-
-	// printf("%03d %08x: ", (r >> 24) & 0xFF, (r & 0x00FFFFFF) );
-
-	setlfpfrac(temp, r << 10);	/* 22 fractional bits */
-
-	r = (r >> 22) & 0x3;
-	r |= ~(r & 2) + 1;
-	setlfpuint(temp, r);
-
-	return temp;
-}
-
-
 uint32_t
 convertLFPToRefID(l_fp num)
 {


=====================================
libntp/socktoa.c
=====================================
--- a/libntp/socktoa.c
+++ b/libntp/socktoa.c
@@ -139,27 +139,3 @@ sock_hash(
 
 	return (u_short)(hashVal & USHRT_MAX);
 }
-
-
-int
-sockaddr_masktoprefixlen(
-	const sockaddr_u *	psa
-	)
-{
-	isc_netaddr_t	isc_na;
-	isc_sockaddr_t	isc_sa;
-	u_int		pfxlen;
-	bool		result;
-	int		rc;
-
-	ZERO(isc_sa);
-	memcpy(&isc_sa.type, psa,
-	       min(sizeof(isc_sa.type), sizeof(*psa)));
-	isc_netaddr_fromsockaddr(&isc_na, &isc_sa);
-	result = isc_netaddr_masktoprefixlen_bool(&isc_na, &pfxlen);
-	rc = (result)
-		 ? (int)pfxlen
-		 : -1;
-
-	return rc;
-}


=====================================
libntp/ssl_init.c
=====================================
--- a/libntp/ssl_init.c
+++ b/libntp/ssl_init.c
@@ -12,7 +12,7 @@
 #include <openssl/evp.h>
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
-void	atexit_ssl_cleanup(void);
+static void	atexit_ssl_cleanup(void);
 #endif
 
 static bool ssl_init_done;
@@ -35,7 +35,7 @@ ssl_init(void)
 
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
-void
+static void
 atexit_ssl_cleanup(void)
 {
 	if (!ssl_init_done)


=====================================
libntp/systime.c
=====================================
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -75,6 +75,8 @@ static long	sys_fuzz_nsec = 0;	/* min. time to read the clock (ns) */
  */
 static bool lamport_violated;	/* clock was stepped back */
 
+static  void	get_ostime	(struct timespec *tsp);
+
 void
 set_sys_fuzz(
 	double	fuzz_val
@@ -87,7 +89,7 @@ set_sys_fuzz(
 }
 
 
-void
+static void
 get_ostime(
 	struct timespec *	tsp
 	)


=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -23,7 +23,6 @@ def build(ctx):
         "socktoa.c",
         "ssl_init.c",
         "syssignal.c",
-        "ymd2yd.c",
     ]
 
     libntp_source_sharable = [


=====================================
libntp/ymd2yd.c deleted
=====================================
--- a/libntp/ymd2yd.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ymd2yd - compute the date in the year from y/m/d
- *
- * A thin wrapper around a more general calendar function.
- */
-
-#include "config.h"
-#include "ntp_stdlib.h"
-#include "ntp_calendar.h"
-
-int
-ymd2yd(
-	int y,
-	int m,
-	int d)
-{
-	/*
-	 * convert y/m/d to elapsed calendar units, convert that to
-	 * elapsed days since the start of the given year and convert
-	 * back to unity-based day in year.
-	 *
-	 * This does no further error checking, since the underlying
-	 * function is assumed to work out how to handle the data.
-	 */
-	return ntpcal_edate_to_yeardays(y-1, m-1, d-1) + 1;
-}


=====================================
tests/libntp/refidsmear.c
=====================================
--- a/tests/libntp/refidsmear.c
+++ b/tests/libntp/refidsmear.c
@@ -9,6 +9,26 @@
 
 #include <stdio.h>
 
+static l_fp	convertRefIDToLFP(uint32_t r) __attribute__((const));
+
+static l_fp
+convertRefIDToLFP(uint32_t r)
+{
+	l_fp temp = 0;
+
+	r = ntohl(r);
+
+	// printf("%03d %08x: ", (r >> 24) & 0xFF, (r & 0x00FFFFFF) );
+
+	setlfpfrac(temp, r << 10);	/* 22 fractional bits */
+
+	r = (r >> 22) & 0x3;
+	r |= ~(r & 2) + 1;
+	setlfpuint(temp, r);
+
+	return temp;
+}
+
 TEST_GROUP(refidsmear);
 
 TEST_SETUP(refidsmear) {init_lib();}


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -41,6 +41,7 @@ Usage: waf <command>
     configure   Configure the project
     dist        Create a release
     install     Install the project
+    loccount    Show SLOC count of the source tree
 
 ''')
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/7a0d87b5372e54f3d1af99697e21dd275c226a8d...c162ad865b680e08c1d1c8714557fd99b5346d2a

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/7a0d87b5372e54f3d1af99697e21dd275c226a8d...c162ad865b680e08c1d1c8714557fd99b5346d2a
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170522/84ec8ab3/attachment.html>


More information about the vc mailing list