[ntpsec commit] Remove unused buftvtots.c code.

Eric S. Raymond esr at ntpsec.org
Fri Oct 23 10:13:37 UTC 2015


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

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Fri Oct 23 06:11:52 2015 -0400

Remove unused buftvtots.c code.

This had a use when the suite used line disciplines and STREAMS.  Now
it doesn't, abd thise aren't coming back because of portability and
security issues.

---

 include/ntp_fp.h                                 |  1 -
 libntp/buftvtots.c                               | 38 -------------
 libntp/wscript                                   |  1 -
 ports/winnt/vs2005/libntp.vcproj                 |  4 --
 ports/winnt/vs2008/libntp/libntp.vcproj          |  4 --
 ports/winnt/vs2013/libntp/libntp.vcxproj         |  1 -
 ports/winnt/vs2013/libntp/libntp.vcxproj.filters |  3 -
 tests/libntp/buftvtots.cpp                       | 72 ------------------------
 8 files changed, 124 deletions(-)

diff --git a/include/ntp_fp.h b/include/ntp_fp.h
index 28012f7..9d5da8c 100644
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -339,7 +339,6 @@ extern	char *	dofptoa		(u_fp, int, short, int);
 extern	char *	dolfptoa	(uint32_t, uint32_t, int, short, int);
 
 extern	bool	atolfp		(const char *, l_fp *);
-extern	int	buftvtots	(const char *, l_fp *);
 extern	char *	fptoa		(s_fp, short);
 extern	char *	fptoms		(s_fp, short);
 extern	bool	hextolfp	(const char *, l_fp *);
diff --git a/libntp/buftvtots.c b/libntp/buftvtots.c
deleted file mode 100644
index b798176..0000000
--- a/libntp/buftvtots.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * buftvtots - pull a Unix-format (struct timeval) time stamp out of
- *	       an octet stream and convert it to a l_fp time stamp.
- *	       This is useful when using the clock line discipline.
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include "ntp_fp.h"
-#include "timevalops.h"
-
-#ifndef SYS_WINNT
-int
-buftvtots(
-	const char *bufp,
-	l_fp *ts
-	)
-{
-	struct timeval tv;
-
-	/*
-	 * copy to adhere to alignment restrictions
-	 */
-	memcpy(&tv, bufp, sizeof(tv));
-
-	/*
-	 * and use it
-	 */
-	if (tv.tv_usec > MICROSECONDS - 1)
-		return false;
-
-	*ts = tval_stamp_to_lfp(tv);
-
-	return true;
-}
-#endif	/* !SYS_WINNT */
diff --git a/libntp/wscript b/libntp/wscript
index 4c6a1ed..a0eb6de 100644
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -7,7 +7,6 @@ def build(ctx):
 		"authkeys.c",
 		"authreadkeys.c",
 		"authusekey.c",
-		"buftvtots.c",
 		"caljulian.c",
 		"caltontp.c",
 		"calyearstart.c",
diff --git a/ports/winnt/vs2005/libntp.vcproj b/ports/winnt/vs2005/libntp.vcproj
index c0306f0..3782c6e 100644
--- a/ports/winnt/vs2005/libntp.vcproj
+++ b/ports/winnt/vs2005/libntp.vcproj
@@ -217,10 +217,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\libntp\buftvtots.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\..\libntp\caljulian.c"
 				>
 			</File>
diff --git a/ports/winnt/vs2008/libntp/libntp.vcproj b/ports/winnt/vs2008/libntp/libntp.vcproj
index d38242b..a682a62 100644
--- a/ports/winnt/vs2008/libntp/libntp.vcproj
+++ b/ports/winnt/vs2008/libntp/libntp.vcproj
@@ -320,10 +320,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\..\libntp\buftvtots.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\..\..\libntp\caljulian.c"
 				>
 			</File>
diff --git a/ports/winnt/vs2013/libntp/libntp.vcxproj b/ports/winnt/vs2013/libntp/libntp.vcxproj
index 690d3e1..20531e8 100644
--- a/ports/winnt/vs2013/libntp/libntp.vcxproj
+++ b/ports/winnt/vs2013/libntp/libntp.vcxproj
@@ -219,7 +219,6 @@
     <ClCompile Include="..\..\..\..\libntp\authreadkeys.c" />
     <ClCompile Include="..\..\..\..\libntp\authusekey.c" />
     <ClCompile Include="..\..\..\..\libntp\a_md5encrypt.c" />
-    <ClCompile Include="..\..\..\..\libntp\buftvtots.c" />
     <ClCompile Include="..\..\..\..\libntp\caljulian.c" />
     <ClCompile Include="..\..\..\..\libntp\caltontp.c" />
     <ClCompile Include="..\..\..\..\libntp\calyearstart.c" />
diff --git a/ports/winnt/vs2013/libntp/libntp.vcxproj.filters b/ports/winnt/vs2013/libntp/libntp.vcxproj.filters
index c807a40..296010d 100644
--- a/ports/winnt/vs2013/libntp/libntp.vcxproj.filters
+++ b/ports/winnt/vs2013/libntp/libntp.vcxproj.filters
@@ -53,9 +53,6 @@
     <ClCompile Include="..\..\..\..\lib\isc\buffer.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\..\libntp\buftvtots.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\..\..\libntp\caljulian.c">
       <Filter>Source Files</Filter>
     </ClCompile>
diff --git a/tests/libntp/buftvtots.cpp b/tests/libntp/buftvtots.cpp
deleted file mode 100644
index 0f3cf5a..0000000
--- a/tests/libntp/buftvtots.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-extern "C" {
-#include "unity.h"
-#include "unity_fixture.h"
-}
-
-TEST_GROUP(buftvtots);
-
-TEST_SETUP(buftvtots) {}
-
-TEST_TEAR_DOWN(buftvtots) {}
-
-#include "lfptest.h"
-
-extern "C" {
-#include "ntp_unixtime.h"
-};
-
-// Required for Solaris.
-#include <math.h>
-
-class buftvtotsTest : public lfptest {
-};
-
-#ifndef SYS_WINNT
-TEST(buftvtots, ZeroBuffer) {
-	const timeval input = {0, 0};
-	const l_fp expected = {0 + JAN_1970, 0};
-
-	l_fp actual;
-
-	TEST_ASSERT_TRUE(buftvtots((const char*)(&input), &actual));
-	TEST_ASSERT_TRUE(IsEqual(expected, actual));
-}
-
-TEST(buftvtots, IntegerAndFractionalBuffer) {
-	const timeval input = {5, 500000}; // 5.5
-	const l_fp expected = {5 + JAN_1970, HALF};
-
-	l_fp actual;
-
-	TEST_ASSERT_TRUE(buftvtots((const char*)(&input), &actual));
-
-	// Compare the fractional part with an absolute error given.
-	TEST_ASSERT_EQUAL(expected.l_ui, actual.l_ui);
-
-	double expectedDouble, actualDouble;
-	M_LFPTOD(0, expected.l_uf, expectedDouble);
-	M_LFPTOD(0, actual.l_uf, actualDouble);
-
-	// The error should be less than 0.5 us
-	TEST_ASSERT_FLOAT_WITHIN(0.0000005, expectedDouble, actualDouble);
-}
-
-TEST(buftvtots, IllegalMicroseconds) {
-	const timeval input = {0, 1100000}; // > 999 999 microseconds.
-
-	l_fp actual;
-
-	TEST_ASSERT_FALSE(buftvtots((const char*)(&input), &actual));
-}
-
-#else
-TEST(buftvtots, AlwaysFalseOnWindows) {
-	/*
-	 * Under Windows, buftvtots will just return
-	 * 0 (false).
-	 */
-	l_fp actual;
-	TEST_ASSERT_FALSE(buftvtots("", &actual));
-}
-
-#endif



More information about the vc mailing list