[Git][NTPsec/ntpsec][master] 4 commits: Merge 3 #ifdef __linux sections

Gary E. Miller gitlab at mg.gitlab.com
Thu Jun 8 01:42:54 UTC 2017


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


Commits:
c08912bc by Gary E. Miller at 2017-06-07T18:14:09-07:00
Merge 3 #ifdef __linux sections

- - - - -
4288bc13 by Gary E. Miller at 2017-06-07T18:15:39-07:00
remove some stray spaces.

- - - - -
f56636ed by Gary E. Miller at 2017-06-07T18:31:11-07:00
remove isc_mem.h and the sily macors it had.

Does free ever need 2 levls of abstraction and 3 unused parameters?

- - - - -
868d16ab by Gary E. Miller at 2017-06-07T18:40:05-07:00
Merge refidsmear.h into net_fp.h

No need for one line include files...

- - - - -


8 changed files:

- − include/isc_mem.h
- include/ntp_fp.h
- − include/refidsmear.h
- libntp/isc_interfaceiter.c
- libntp/refidsmear.c
- ntpd/ntp_io.c
- ntpd/ntp_proto.c
- tests/libntp/refidsmear.c


Changes:

=====================================
include/isc_mem.h deleted
=====================================
--- a/include/isc_mem.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * libntp local copy of isc/mem.h.
- *
- * NOTE: this assumes the system malloc is thread-safe and does
- *	 not use any normal libisc locking.
- *
- * Copyright 2015 by the NTPsec project contributors
- * SPDX-License-Identifier: ISC
- */
-
-#ifndef GUARD_ISC_MEM_H
-#define GUARD_ISC_MEM_H
-
-#include <stdio.h>
-
-#include "isc_result.h"
-
-#include "ntp_stdlib.h"
-#include "ntp_types.h"
-
-#define isc_mem_get(c, cnt)		\
-	( UNUSED_ARG(c),	emalloc(cnt) )
-
-#define isc_mem_put(c, mem, cnt)	\
-	( UNUSED_ARG(cnt),	isc_mem_free(c, (mem)) )
-
-#define isc_mem_free(c, mem)		\
-	( UNUSED_ARG(c),	free(mem) )
-
-#endif /* GUARD_ISC_MEM_H */


=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -188,4 +188,6 @@ extern	bool	adj_systime	(double, int (*adjtime)(const struct timeval *, struct t
 typedef void (*time_stepped_callback)(void);
 extern time_stepped_callback	step_callback;
 
+extern uint32_t	convertLFPToRefID(l_fp num) __attribute__((const));
+
 #endif /* GUARD_NTP_FP_H */


=====================================
include/refidsmear.h deleted
=====================================
--- a/include/refidsmear.h
+++ /dev/null
@@ -1,2 +0,0 @@
-
-extern uint32_t	convertLFPToRefID(l_fp num) __attribute__((const));


=====================================
libntp/isc_interfaceiter.c
=====================================
--- a/libntp/isc_interfaceiter.c
+++ b/libntp/isc_interfaceiter.c
@@ -20,8 +20,8 @@
 #include <netinet/in.h>                /* Contractual promise. */
 
 #include "ntp_assert.h"
+#include "ntp_stdlib.h"
 #include "isc_interfaceiter.h"
-#include "isc_mem.h"
 #include "isc_netaddr.h"
 #include "isc_result.h"
 #include "isc_error.h"
@@ -156,6 +156,17 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
 static isc_result_t linux_if_inet6_next(isc_interfaceiter_t *);
 static isc_result_t linux_if_inet6_current(isc_interfaceiter_t *);
 static void linux_if_inet6_first(isc_interfaceiter_t *iter);
+static bool seenv6 = false;
+
+/* IF_NAMESIZE usually defined in net/if.h */
+# ifndef IF_NAMESIZE
+#  ifdef IFNAMSIZ
+#   define IF_NAMESIZE  IFNAMSIZ
+#  else
+#   define IF_NAMESIZE 16
+#  endif
+# endif
+
 #endif
 
 
@@ -203,10 +214,6 @@ isc_interfaceiter_current_bool(isc_interfaceiter_t *iter,
 /*% Valid Iterator */
 #define VALID_IFITER(t)         ISC_MAGIC_VALID(t, IFITER_MAGIC)
 
-#ifdef __linux
-static bool seenv6 = false;
-#endif
-
 /*% Iterator structure */
 struct isc_interfaceiter {
         unsigned int            magic;          /*%< Magic number. */
@@ -217,7 +224,7 @@ struct isc_interfaceiter {
         struct ifaddrs          *pos;           /*%< Ptr to current ifaddr */
         isc_interface_t         current;        /*%< Current interface data. */
         isc_result_t            result;         /*%< Last result code. */
-#ifdef  __linux
+#ifdef __linux
         FILE *                  proc;
         char                    entry[ISC_IF_INET6_SZ];
         isc_result_t            valid;
@@ -235,7 +242,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         REQUIRE(iterp != NULL);
         REQUIRE(*iterp == NULL);
 
-        iter = isc_mem_get(mctx, sizeof(*iter));
+        iter = emalloc(sizeof(*iter));
         if (iter == NULL)
                 return (ISC_R_NOMEMORY);
 
@@ -295,7 +302,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
 #endif
         if (iter->ifaddrs != NULL) /* just in case */
                 freeifaddrs(iter->ifaddrs);
-        isc_mem_put(mctx, iter, sizeof(*iter));
+        free(iter);
         return (result);
 }
 
@@ -506,7 +513,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         REQUIRE(iterp != NULL);
         REQUIRE(*iterp == NULL);
 
-        iter = isc_mem_get(mctx, sizeof(*iter));
+        iter = emalloc(sizeof(*iter));
         if (iter == NULL)
                 return (ISC_R_NOMEMORY);
 
@@ -526,7 +533,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         }
         iter->bufsize = bufsize;
 
-        iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
+        iter->buf = emalloc(iter->bufsize);
         if (iter->buf == NULL) {
                 result = ISC_R_NOMEMORY;
                 goto failure;
@@ -556,8 +563,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
 
  failure:
         if (iter->buf != NULL)
-                isc_mem_put(mctx, iter->buf, iter->bufsize);
-        isc_mem_put(mctx, iter, sizeof(*iter));
+                free(iter->buf);
+        free(iter);
         return (result);
 }
 
@@ -784,7 +791,7 @@ struct isc_interfaceiter {
         isc_result_t            result6;        /* Last result code. */
         bool            first6;
 #endif
-#ifdef  __linux
+#ifdef __linux
         FILE *                  proc;
         char                    entry[ISC_IF_INET6_SZ];
         isc_result_t            valid;
@@ -800,16 +807,6 @@ struct isc_interfaceiter {
 #define IFCONF_BUFSIZE_INITIAL  4096
 #define IFCONF_BUFSIZE_MAX      1048576
 
-#ifdef __linux
-#ifndef IF_NAMESIZE
-# ifdef IFNAMSIZ
-#  define IF_NAMESIZE  IFNAMSIZ
-# else
-#  define IF_NAMESIZE 16
-# endif
-#endif
-#endif
-
 static int
 isc_ioctl(int fildes, int req, char *arg);
 
@@ -835,7 +832,7 @@ getbuf4(isc_interfaceiter_t *iter) {
         iter->bufsize = IFCONF_BUFSIZE_INITIAL;
 
         for (;;) {
-                iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
+                iter->buf = emalloc(iter->bufsize);
                 if (iter->buf == NULL)
                         return (ISC_R_NOMEMORY);
 
@@ -878,14 +875,14 @@ getbuf4(isc_interfaceiter_t *iter) {
                                          "maximum buffer size exceeded");
                         goto unexpected;
                 }
-                isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+                free(iter->buf);
 
                 iter->bufsize *= 2;
         }
         return (ISC_R_SUCCESS);
 
  unexpected:
-        isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+        free(iter->buf);
         iter->buf = NULL;
         return (ISC_R_UNEXPECTED);
 }
@@ -899,7 +896,7 @@ getbuf6(isc_interfaceiter_t *iter) {
         iter->bufsize6 = IFCONF_BUFSIZE_INITIAL;
 
         for (;;) {
-                iter->buf6 = isc_mem_get(iter->mctx, iter->bufsize6);
+                iter->buf6 = emalloc(iter->bufsize6);
                 if (iter->buf6 == NULL)
                         return (ISC_R_NOMEMORY);
 
@@ -950,7 +947,7 @@ getbuf6(isc_interfaceiter_t *iter) {
                         result = ISC_R_UNEXPECTED;
                         goto cleanup;
                 }
-                isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
+                free(iter->buf6);
 
                 iter->bufsize6 *= 2;
         }
@@ -960,7 +957,7 @@ getbuf6(isc_interfaceiter_t *iter) {
         return (ISC_R_SUCCESS);
 
  cleanup:
-        isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
+        free(iter->buf6);
         iter->buf6 = NULL;
         return (result);
 }
@@ -976,7 +973,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         REQUIRE(iterp != NULL);
         REQUIRE(*iterp == NULL);
 
-        iter = isc_mem_get(mctx, sizeof(*iter));
+        iter = emalloc(sizeof(*iter));
         if (iter == NULL)
                 return (ISC_R_NOMEMORY);
 
@@ -1044,20 +1041,20 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
 
  ioctl_failure:
         if (iter->buf != NULL)
-                isc_mem_put(mctx, iter->buf, iter->bufsize);
+                free(iter->buf);
         (void) close(iter->socket);
 
  socket_failure:
 #if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
         if (iter->buf6 != NULL)
-                isc_mem_put(mctx, iter->buf6, iter->bufsize6);
+                free(iter->buf6);
   ioctl6_failure:
         if (iter->socket6 != -1)
                 (void) close(iter->socket6);
   socket6_failure:
 #endif
 
-        isc_mem_put(mctx, iter, sizeof(*iter));
+        free(iter);
         return (result);
 }
 
@@ -1546,7 +1543,7 @@ internal_destroy(isc_interfaceiter_t *iter) {
         if (iter->socket6 != -1)
                 (void) close(iter->socket6);
         if (iter->buf6 != NULL) {
-                isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
+                free(iter->buf6);
         }
 #endif
 #ifdef __linux
@@ -1759,9 +1756,9 @@ isc_interfaceiter_destroy(isc_interfaceiter_t **iterp)
 
         internal_destroy(iter);
         if (iter->buf != NULL)
-                isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+                free(iter->buf);
 
         iter->magic = 0;
-        isc_mem_put(iter->mctx, iter, sizeof(*iter));
+        free(iter);
         *iterp = NULL;
 }


=====================================
libntp/refidsmear.c
=====================================
--- a/libntp/refidsmear.c
+++ b/libntp/refidsmear.c
@@ -2,7 +2,6 @@
 
 #include "ntp.h"
 #include "ntp_fp.h"
-#include "refidsmear.h"
 
 /*
  * we want to test a refid format of:


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -22,7 +22,6 @@
 #include "ntp_dns.h"
 #include "timespecops.h"
 
-#include "isc_mem.h"
 #include "isc_interfaceiter.h"
 #include "isc_netaddr.h"
 


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -9,7 +9,6 @@
 #include "ntp_stdlib.h"
 #include "ntp_leapsec.h"
 #include "ntp_dns.h"
-#include "refidsmear.h"
 #include "timespecops.h"
 
 #include <string.h>


=====================================
tests/libntp/refidsmear.c
=====================================
--- a/tests/libntp/refidsmear.c
+++ b/tests/libntp/refidsmear.c
@@ -2,7 +2,6 @@
 
 #include "ntp.h"
 #include "ntp_fp.h"
-#include "refidsmear.h"
 
 #include "unity.h"
 #include "unity_fixture.h"



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b4461e57699f1f39b59cd90b3972c44f1fe1a307...868d16ab87769b32d717f689fa6d520f164f2cb6

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b4461e57699f1f39b59cd90b3972c44f1fe1a307...868d16ab87769b32d717f689fa6d520f164f2cb6
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/20170608/4adea2eb/attachment.html>


More information about the vc mailing list