[Git][NTPsec/ntpsec][master] Cleanup ...

Matt Selsky gitlab at mg.gitlab.com
Fri Sep 27 05:14:58 UTC 2019



Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
52189161 by James Browning at 2019-09-27T05:03:54Z
Cleanup ...

This also removes some functionality as the source file and line will no longer be logged as an error and affected errors will no longer be gagged after 201 lines
- - - - -


7 changed files:

- − include/isc_error.h
- − libntp/isc_error.c
- libntp/isc_interfaceiter.c
- libntp/isc_net.c
- libntp/pymodule.c
- libntp/wscript
- ntpd/ntpd.c


Changes:

=====================================
include/isc_error.h deleted
=====================================
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2004-2007, 2009  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- * Copyright 2015 by the NTPsec project contributors
- * SPDX-License-Identifier: ISC
- */
-
-#ifndef GUARD_ISC_ERROR_H
-#define GUARD_ISC_ERROR_H 1
-
-/* isc_error.h */
-
-/*
- * ISC_FORMAT_PRINTF().
- *
- * fmt is the location of the format string parameter.
- * args is the location of the first argument (or 0 for no argument checking).
- *
- * Note:
- * The first parameter is 1, not 0.
- */
-#ifdef __GNUC__
-#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args)))
-#else
-#define ISC_FORMAT_PRINTF(fmt, args)
-#endif
-
-
-/* unexpected error */
-void
-isc_error_unexpected(const char *, int, const char *, ...)
-     ISC_FORMAT_PRINTF(3, 4);
-
-/* Unexpected Error */
-#define UNEXPECTED_ERROR(fmt, ...) \
-	isc_error_unexpected(__FILE__, __LINE__, fmt, __VA_ARGS__)
-
-#endif /* GUARD_ISC_ERROR_H */


=====================================
libntp/isc_error.c deleted
=====================================
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- * Copyright 2015 by the NTPsec project contributors
- * SPDX-License-Identifier: ISC
- */
-
-/*! \file */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "ntp_config.h"
-#include "ntp_syslog.h"
-
-#include "isc_error.h"
-
-
-#define MAX_UNEXPECTED_ERRORS 100
-void
-isc_error_unexpected(const char *file, int line, const char *format, ...) {
-        va_list args;
-        char errbuf[256];
-        static int unexpected_error_cnt = 0;
-
-        if (unexpected_error_cnt >= MAX_UNEXPECTED_ERRORS) {
-                return; /* avoid clutter in log */
-}
-
-        va_start(args, format);
-
-        msyslog(LOG_ERR, "ERR: %s:%d: unexpected error:", file, line);
-        vsnprintf(errbuf, sizeof(errbuf), format, args);
-        msyslog(LOG_ERR, "%s", errbuf);
-
-        if (++unexpected_error_cnt == MAX_UNEXPECTED_ERRORS)
-                msyslog(LOG_ERR, "ERR: Too many errors.  Shutting up.");
-        va_end(args);
-}


=====================================
libntp/isc_interfaceiter.c
=====================================
@@ -24,7 +24,7 @@
 #include "isc_interfaceiter.h"
 #include "isc_netaddr.h"
 #include "isc_result.h"
-#include "isc_error.h"
+#include "ntp_stdlib.h"
 
 
 /* Must follow <isc/net.h>. */
@@ -278,7 +278,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         }
         if (ret < 0) {
 		IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
-                UNEXPECTED_ERROR("getting interface addresses: getifaddrs: %s",
+                msyslog(LOG_ERR, "getting interface addresses: getifaddrs: %s",
                                  strbuf);
                 result = ISC_R_UNEXPECTED;
                 goto failure;
@@ -526,7 +526,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         bufsize = 0;
         if (sysctl(mib, 6, NULL, &bufsize, NULL, (size_t) 0) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("getting interface list size: sysctl: %s",
+                msyslog(LOG_ERR, "getting interface list size: sysctl: %s",
                                  strbuf);
                 result = ISC_R_UNEXPECTED;
                 goto failure;
@@ -542,7 +542,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         bufused = bufsize;
         if (sysctl(mib, 6, iter->buf, &bufused, NULL, (size_t) 0) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("getting interface list: sysctl: %s",
+                msyslog(LOG_ERR, "getting interface list: sysctl: %s",
                                  strbuf);
                 result = ISC_R_UNEXPECTED;
                 goto failure;
@@ -849,7 +849,7 @@ getbuf4(isc_interfaceiter_t *iter) {
                     == -1) {
                         if (errno != EINVAL) {
                                 strerror_r(errno, strbuf, sizeof(strbuf));
-                                UNEXPECTED_ERROR("get interface "
+                                msyslog(LOG_ERR, "get interface "
                                                  "configuration: %s",
                                                  strbuf);
                                 goto unexpected;
@@ -872,7 +872,7 @@ getbuf4(isc_interfaceiter_t *iter) {
                                 break;
                 }
                 if (iter->bufsize >= IFCONF_BUFSIZE_MAX) {
-                        UNEXPECTED_ERROR("get interface configuration: "
+                        msyslog(LOG_ERR, "get interface configuration: "
                                          "maximum buffer size exceeded");
                         goto unexpected;
                 }
@@ -919,7 +919,7 @@ getbuf6(isc_interfaceiter_t *iter) {
                     == -1) {
                         if (errno != EINVAL) {
                                 strerror_r(errno, strbuf, sizeof(strbuf));
-                                UNEXPECTED_ERROR("get interface "
+                                msyslog(LOG_ERR, "get interface "
                                                  "configuration: %s",
                                                  strbuf);
                                 result = ISC_R_UNEXPECTED;
@@ -943,7 +943,7 @@ getbuf6(isc_interfaceiter_t *iter) {
                                 break;
                 }
                 if (iter->bufsize6 >= IFCONF_BUFSIZE_MAX) {
-                        UNEXPECTED_ERROR("get interface configuration: "
+                        msyslog(LOG_ERR, "get interface configuration: "
                                          "maximum buffer size exceeded");
                         result = ISC_R_UNEXPECTED;
                         goto cleanup;
@@ -1005,7 +1005,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
                  */
                 if ((iter->socket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
                         strerror_r(errno, strbuf, sizeof(strbuf));
-                        UNEXPECTED_ERROR("making interface scan socket: %s",
+                        msyslog(LOG_ERR, "making interface scan socket: %s",
                                          strbuf);
                         result = ISC_R_UNEXPECTED;
                         goto socket6_failure;
@@ -1017,7 +1017,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
 #endif
         if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("making interface scan socket: %s",
+                msyslog(LOG_ERR, "making interface scan socket: %s",
                                  strbuf);
                 result = ISC_R_UNEXPECTED;
                 goto socket_failure;
@@ -1140,7 +1140,7 @@ internal_current4(isc_interfaceiter_t *iter) {
          */
         if (isc_ioctl(iter->socket, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("%s: getting interface flags: %s",
+                msyslog(LOG_ERR, "%s: getting interface flags: %s",
                                  ifreq.ifr_name, strbuf);
                 return (ISC_R_IGNORE);
         }
@@ -1175,7 +1175,7 @@ internal_current4(isc_interfaceiter_t *iter) {
 
         if (isc_ioctl(iter->socket, SIOCGLIFADDR, &lifreq) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("%s: getting interface address: %s",
+                msyslog(LOG_ERR, "%s: getting interface address: %s",
                                  ifreq.ifr_name, strbuf);
                 return (ISC_R_IGNORE);
         }
@@ -1214,7 +1214,7 @@ internal_current4(isc_interfaceiter_t *iter) {
                 if (isc_ioctl(iter->socket, SIOCGIFDSTADDR, (char *)&ifreq)
                     < 0) {
                         strerror_r(errno, strbuf, sizeof(strbuf));
-                        UNEXPECTED_ERROR("%s: getting destination address: %s",
+                        msyslog(LOG_ERR, "%s: getting destination address: %s",
                                          ifreq.ifr_name, strbuf);
                         return (ISC_R_IGNORE);
                 }
@@ -1232,7 +1232,7 @@ internal_current4(isc_interfaceiter_t *iter) {
                 if (isc_ioctl(iter->socket, SIOCGIFBRDADDR, (char *)&ifreq)
                     < 0) {
                         strerror_r(errno, strbuf, sizeof(strbuf));
-                        UNEXPECTED_ERROR("%s: getting broadcast address: %s",
+                        msyslog(LOG_ERR, "%s: getting broadcast address: %s",
                                          ifreq.ifr_name, strbuf);
                         return (ISC_R_IGNORE);
                 }
@@ -1252,7 +1252,7 @@ internal_current4(isc_interfaceiter_t *iter) {
          */
         if (isc_ioctl(iter->socket, SIOCGIFNETMASK, (char *)&ifreq) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("%s: getting netmask: %s",
+                msyslog(LOG_ERR, "%s: getting netmask: %s",
                                  ifreq.ifr_name, strbuf);
                 return (ISC_R_IGNORE);
         }
@@ -1332,7 +1332,7 @@ internal_current6(isc_interfaceiter_t *iter) {
          */
         if (isc_ioctl(fd, SIOCGLIFFLAGS, (char *) &lifreq) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("%s: getting interface flags: %s",
+                msyslog(LOG_ERR, "%s: getting interface flags: %s",
                                  lifreq.lifr_name, strbuf);
                 return (ISC_R_IGNORE);
         }
@@ -1371,7 +1371,7 @@ internal_current6(isc_interfaceiter_t *iter) {
                 if (isc_ioctl(fd, SIOCGLIFDSTADDR, (char *)&lifreq)
                     < 0) {
                         strerror_r(errno, strbuf, sizeof(strbuf));
-                        UNEXPECTED_ERROR("%s: getting destination address: %s",
+                        msyslog(LOG_ERR, "%s: getting destination address: %s",
                                          lifreq.lifr_name, strbuf);
                         return (ISC_R_IGNORE);
                 }
@@ -1391,7 +1391,7 @@ internal_current6(isc_interfaceiter_t *iter) {
                 if (isc_ioctl(iter->socket, SIOCGLIFBRDADDR, (char *)&lifreq)
                     < 0) {
                         strerror_r(errno, strbuf, sizeof(strbuf));
-                        UNEXPECTED_ERROR("%s: getting broadcast address: %s",
+                        msyslog(LOG_ERR, "%s: getting broadcast address: %s",
                                          lifreq.lifr_name, strbuf);
                         return (ISC_R_IGNORE);
                 }
@@ -1435,7 +1435,7 @@ internal_current6(isc_interfaceiter_t *iter) {
          */
         if (isc_ioctl(fd, SIOCGLIFNETMASK, (char *)&lifreq) < 0) {
                 strerror_r(errno, strbuf, sizeof(strbuf));
-                UNEXPECTED_ERROR("%s: getting netmask: %s",
+                msyslog(LOG_ERR, "%s: getting netmask: %s",
                                  lifreq.lifr_name, strbuf);
                 return (ISC_R_IGNORE);
         }


=====================================
libntp/isc_net.c
=====================================
@@ -26,7 +26,7 @@
 #include <netinet/in.h>                /* Contractual promise. */
 
 #include "isc_netaddr.h"
-#include "isc_error.h"
+#include "ntp_stdlib.h"
 #include "isc_result.h"
 
 static isc_result_t	ipv4_result = ISC_R_NOTFOUND;
@@ -54,7 +54,7 @@ try_proto(int domain) {
 			return (ISC_R_NOTFOUND);
 		default:
 			IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
-			UNEXPECTED_ERROR("socket() failed: %s", strbuf);
+			msyslog(LOG_ERR, "socket() failed: %s", strbuf);
 			return (ISC_R_UNEXPECTED);
 		}
 	}
@@ -157,7 +157,7 @@ initialize_ipv6only(void) {
 	s = socket(PF_INET6, SOCK_STREAM, 0);
 	if (s == -1) {
 		IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
-		UNEXPECTED_ERROR("socket() failed: %s", strbuf);
+		msyslog(LOG_ERR, "socket() failed: %s", strbuf);
 		ipv6only_result = ISC_R_UNEXPECTED;
 		return;
 	}
@@ -174,7 +174,7 @@ initialize_ipv6only(void) {
 	s = socket(PF_INET6, SOCK_DGRAM, 0);
 	if (s == -1) {
 	    IGNORE(strerror_r(errno, strbuf, sizeof(strbuf)));
-		UNEXPECTED_ERROR("socket() failed: %s", strbuf);
+		msyslog(LOG_ERR, "socket() failed: %s", strbuf);
 		ipv6only_result = ISC_R_UNEXPECTED;
 		return;
 	}


=====================================
libntp/pymodule.c
=====================================
@@ -18,7 +18,6 @@
 
 #include "ntp_config.h"
 #include "ntp_assert.h"
-#include "isc_error.h"
 
 #include "ntp_control.h"
 


=====================================
libntp/wscript
=====================================
@@ -1,7 +1,6 @@
 def build(ctx):
 
     libntp_source = [
-	#"aes_siv.c",
         "authkeys.c",
         "authreadkeys.c",
         "clocktime.c",
@@ -9,7 +8,6 @@ def build(ctx):
         "dolfptoa.c",
         "getopt.c",
         "initnetwork.c",
-        "isc_error.c",
         "isc_interfaceiter.c",
         "isc_net.c",
         "macencrypt.c",


=====================================
ntpd/ntpd.c
=====================================
@@ -14,7 +14,6 @@
 #include "ntp_assert.h"
 #include "ntp_auth.h"
 #include "ntp_dns.h"
-#include "isc_error.h"
 
 #include <unistd.h>
 #include <sys/stat.h>



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/52189161371a74eb4b047ee4d011e044ca378213

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/52189161371a74eb4b047ee4d011e044ca378213
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/20190927/5849a593/attachment-0001.htm>


More information about the vc mailing list