[Git][NTPsec/ntpsec][master] 2 commits: Remove unused code.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Nov 22 21:32:09 UTC 2017


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


Commits:
a70e3d00 by Eric S. Raymond at 2017-11-22T15:13:51-05:00
Remove unused code.

- - - - -
9f6bdd3d by Eric S. Raymond at 2017-11-22T15:13:51-05:00
Remove utmpx logging of timesteps.

- - - - -


6 changed files:

- libntp/systime.c
- − tests/common/file_handling.c
- − tests/common/file_handling.h
- tests/wscript
- wafhelpers/options.py
- wscript


Changes:

=====================================
libntp/systime.c
=====================================
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -12,10 +12,6 @@
 #include "timespecops.h"
 #include "ntp_calendar.h"
 
-#ifdef HAVE_UTMPX_H
-#include <utmpx.h>
-#endif
-
 #ifndef USE_COMPILETIME_PIVOT
 # define USE_COMPILETIME_PIVOT 1
 #endif
@@ -321,7 +317,7 @@ step_systime(
 	)
 {
 	time_t pivot; /* for ntp era unfolding */
-	struct timespec timets, tslast, tsdiff;
+	struct timespec timets;
 	struct calendar jd;
 	l_fp fp_ofs, fp_sys; /* offset and target system time in FP */
 
@@ -393,77 +389,9 @@ step_systime(
 
 	msyslog(LOG_WARNING, "CLOCK: time stepped by %Lf", step);
 
-	/* only used for utmp/wtmpx time-step recording */
-	tslast.tv_sec = timets.tv_sec;
-	tslast.tv_nsec = timets.tv_nsec;
-
 	sys_residual = 0;
 	lamport_violated = (step < 0);
 	if (step_callback)
 		(*step_callback)();
-
-	/*
-	 * FreeBSD, for example, has:
-	 * struct utmp {
-	 *	   char    ut_line[UT_LINESIZE];
-	 *	   char    ut_name[UT_NAMESIZE];
-	 *	   char    ut_host[UT_HOSTSIZE];
-	 *	   long    ut_time;
-	 * };
-	 * and appends line="|", name="date", host="", time for the OLD
-	 * and appends line="{", name="date", host="", time for the NEW
-	 * to _PATH_WTMP .
-	 *
-	 * Some OSes have utmp, some have utmpx. POSIX.1-2001 standardizes
-	 * utmpx, so we'll support that.
-	 */
-
-	/*
-	 * Write old and new time entries in utmp and wtmp if step
-	 * adjustment is greater than one second.
-	 *
-	 * This might become even uglier...
-	 */
-	tsdiff = abs_tspec(sub_tspec(timets, tslast));
-	if (tsdiff.tv_sec > 0) {
-#ifdef HAVE_UTMPX_H
-# ifdef OVERRIDE_OTIME_MSG
-#  define OTIME_MSG OVERRIDE_OTIME_MSG
-# else
-/* Already defined on NetBSD */
-#  ifndef OTIME_MSG
-#   define OTIME_MSG	"Old NTP time"
-#  endif
-# endif
-# ifdef OVERRIDE_NTIME_MSG
-#  define NTIME_MSG OVERRIDE_NTIME_MSG
-# else
-#  ifndef NTIME_MSG
-#   define NTIME_MSG	"New NTP time"
-#  endif
-# endif
-		struct utmpx utx;
-
-		ZERO(utx);
-
-		/* UTMPX - this is POSIX-conformant */
-		utx.ut_type = OLD_TIME;
-		strlcpy(utx.ut_line, OTIME_MSG, sizeof(utx.ut_line));
-		utx.ut_tv.tv_sec = tslast.tv_sec;
-		utx.ut_tv.tv_usec = (tslast.tv_nsec + 500) / 1000;
-		setutxent();
-		pututxline(&utx);
-		utx.ut_type = NEW_TIME;
-		strlcpy(utx.ut_line, NTIME_MSG, sizeof(utx.ut_line));
-		utx.ut_tv.tv_sec = timets.tv_sec;
-		utx.ut_tv.tv_usec = (timets.tv_nsec + 500) / 1000;
-		setutxent();
-		pututxline(&utx);
-		endutxent();
-
-# undef OTIME_MSG
-# undef NTIME_MSG
-#endif
-	}
 	return true;
 }


=====================================
tests/common/file_handling.c deleted
=====================================
--- a/tests/common/file_handling.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <stdio.h>
-#include "tests_main.h"
-#include "file_handling.h"
-
-const char* CreatePath(const char* filename, DirectoryType argument) {
-	const char* argpath = tests_main_args(argument);
-	char* path;
-	size_t len = 0;
-
-	if (argpath != NULL) {
-		len = strlen(argpath);
-		if (argpath[strlen(argpath) - 1] != DIR_SEP)
-			++len;
-	}
-
-	len += strlen(filename) + 1;
-
-    	path = malloc(len);
-	if (path != NULL) {
-		if (argpath != NULL) {
-			strncpy(path, argpath, len - 1);
-			if (argpath[strlen(argpath) - 1] != DIR_SEP) {
-				char ds[2] = { DIR_SEP, '\0'};
-				strncat(path, ds, len - 1);
-			}
-		}
-		strncat(path, filename, len - 1);
-	}
-
-	return path;
-}
-
-ssize_t GetFileSize(FILE* file) {
-	ssize_t size = -1;
-	off_t initial = ftello(file);
-	if (initial != (off_t) -1) {
-		if (fseek(file, 0, SEEK_END) == 0) {
-			size = (ssize_t) ftello(file);
-			if (fseek(file, initial, SEEK_CUR) != 0) {
-				size = -1;
-			}
-		}
-	}
-	return size;
-}
-
-
-void CompareFileContent(FILE* expected, FILE* actual) {
-	while (!feof(expected) && !feof(actual)) {
-		char e_line[256];
-		char a_line[256];
-		TEST_ASSERT_FALSE(ferror(expected));
-		TEST_ASSERT_FALSE(ferror(actual));
-		if (fgets(e_line, sizeof(e_line), expected) != NULL &&
-		    fgets(a_line, sizeof(a_line), actual) != NULL) {
-			TEST_ASSERT_EQUAL_STRING(e_line, a_line);
-		}
-	}
-}
-
-void ClearFile(const char* filename) {
-	FILE* f = fopen(filename, "wb");
-	TEST_ASSERT_NULL(f);
-	TEST_ASSERT_TRUE(fclose(f));
-}


=====================================
tests/common/file_handling.h deleted
=====================================
--- a/tests/common/file_handling.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef GUARD_FILE_HANDLING_TEST_H
-#define GUARD_FILE_HANDLING_TEST_H
-
-//#include "ntpdigtest.h"
-
-typedef enum {
-	INPUT_DIR = 0,
-	OUTPUT_DIR = 1
-}  DirectoryType;
-
-const char* CreatePath(const char* filename, DirectoryType argument);
-ssize_t GetFileSize(FILE* file);
-void CompareFileContent(FILE* expected, FILE* actual);
-void ClearFile(const char* filename);
-
-#endif // GUARD_FILE_HANDLING_TEST_H


=====================================
tests/wscript
=====================================
--- a/tests/wscript
+++ b/tests/wscript
@@ -26,7 +26,6 @@ def build(ctx):
         "common/tests_main.c",
         "common/caltime.c",
         "common/sockaddrtest.c",
-        "common/file_handling.c"
     ]
 
     # libntp/


=====================================
wafhelpers/options.py
=====================================
--- a/wafhelpers/options.py
+++ b/wafhelpers/options.py
@@ -10,8 +10,6 @@ def options_cmd(ctx, config):
     grp = ctx.add_option_group("NTP configure options")
     grp.add_option('--enable-debug', action='store_true',
                    default=False, help="Enable debugging code")
-    grp.add_option('--disable-debug', action='store_true',
-                   default=False, help="(ignored)")
     grp.add_option('--enable-debug-gdb', action='store_true',
                    default=False, help="Enable GDB debugging symbols")
     grp.add_option('--disable-droproot', action='store_true',
@@ -23,8 +21,6 @@ def options_cmd(ctx, config):
                    default=False, help="Enable seccomp (restricts syscalls).")
     grp.add_option('--disable-dns-lookup', action='store_true',
                    default=False, help="Disable DNS lookups.")
-    grp.add_option('--disable-dns-retry', action='store_true',
-                   default=False, help="Disable retrying DNS lookups.")
     grp.add_option('--disable-kernel-pll', action='store_true',
                    default=False, help="Disable kernel PLL.")
     grp.add_option('--disable-mdns-registration', action='store_true',


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -708,7 +708,6 @@ int main(int argc, char **argv) {
         ("sys/sysctl.h", ["sys/types.h"]),
         ("timepps.h", ["inttypes.h"]),
         ("sys/timepps.h", ["inttypes.h", "sys/time.h"]),
-        "utmpx.h",       # missing on RTEMS and OpenBSD
         ("sys/timex.h", ["sys/time.h"]),
     )
     for hdr in optional_headers:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/ea280f89a4efb4fb44175e64716d8857a5bd111e...9f6bdd3d3c4311a1de2a6a28a83cb735739ba4a4

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/ea280f89a4efb4fb44175e64716d8857a5bd111e...9f6bdd3d3c4311a1de2a6a28a83cb735739ba4a4
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/20171122/bf8978b7/attachment.html>


More information about the vc mailing list