[Git][NTPsec/ntpsec][master] 4 commits: Address GitLab issue #153: symlink warning...
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Nov 21 20:51:02 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
173dd106 by Eric S. Raymond at 2016-11-21T13:21:18-05:00
Address GitLab issue #153: symlink warning...
...by moving the linkmaker to a post function.
- - - - -
3d4998c5 by Eric S. Raymond at 2016-11-21T15:13:26-05:00
Information hiding and goto elimination.
- - - - -
e19e797e by Eric S. Raymond at 2016-11-21T15:25:39-05:00
Remove dead code.
- - - - -
7b7ac6c1 by Eric S. Raymond at 2016-11-21T15:50:26-05:00
Remove unnecessary union declaration.
- - - - -
5 changed files:
- − include/adjtime.h
- include/ntp_control.h
- libntp/getopt.c
- ntpd/ntp_control.c
- wscript
Changes:
=====================================
include/adjtime.h deleted
=====================================
--- a/include/adjtime.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************/
-/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */
-/* Hewlett-Packard Laboratories. */
-/* */
-/* SPDX-License-Identifier: BSD-2-clause
-/* */
-/* The author would appreciate it if any bug fixes and enhancements were */
-/* to be sent back to him for incorporation into future versions of this */
-/* software. Please send changes to tai at iag.hp.com or ken at sdd.hp.com. */
-/*************************************************************************/
-
-/* "adjtime.h,v 3.1 1993/07/06 01:04:43 jbj Exp" */
-/* adjtime.h,v
- * Revision 3.1 1993/07/06 01:04:43 jbj
- * NTP release 3.1
- *
- *
- * Revision 1.5 90/02/07 15:34:18 15:34:18 src (Source Hacker)
- * CHANGED KEY !!!
- *
- * Revision 1.4 89/02/09 12:26:35 12:26:35 tai (Tai Jin (Guest))
- * *** empty log message ***
- *
- * Revision 1.4 89/02/09 12:26:35 12:26:35 tai (Tai Jin)
- * added comment
- *
- * Revision 1.3 88/08/30 01:08:29 01:08:29 tai (Tai Jin)
- * fix copyright notice again
- *
- * Revision 1.2 88/08/30 00:51:55 00:51:55 tai (Tai Jin)
- * fix copyright notice
- *
- * Revision 1.1 88/04/02 14:56:54 14:56:54 tai (Tai Jin)
- * Initial revision
- * */
-
-#include "ntp_types.h"
-
-#define KEY 659847L
-
-typedef union {
- struct msgbuf msgp;
- struct {
- long mtype;
- int code;
- struct timeval tv;
- } msgb;
-} MsgBuf;
-
-#define MSGSIZE (sizeof(int) + sizeof(struct timeval))
-/*
- * mtype values
- */
-#define CLIENT 1L
-#define SERVER 2L
-/*
- * code values
- */
-#define DELTA1 0
-#define DELTA2 1
=====================================
include/ntp_control.h
=====================================
--- a/include/ntp_control.h
+++ b/include/ntp_control.h
@@ -4,11 +4,6 @@
#include "ntp_types.h"
-typedef union ctl_pkt_u_tag {
- uint8_t data[480 + MAX_MAC_LEN]; /* data + auth */
- uint32_t u32[(480 + MAX_MAC_LEN) / sizeof(uint32_t)];
-} ctl_pkt_u;
-
struct ntp_control {
uint8_t li_vn_mode; /* leap, version, mode */
uint8_t r_m_e_op; /* response, more, error, opcode */
@@ -17,13 +12,13 @@ struct ntp_control {
uint16_t associd; /* association ID (associd_t) */
uint16_t offset; /* offset of this batch of data */
uint16_t count; /* count of data in this packet */
- ctl_pkt_u u;
+ uint8_t data[480 + MAX_MAC_LEN]; /* data + auth */
};
/*
* Length of the control header, in octets
*/
-#define CTL_HEADER_LEN (offsetof(struct ntp_control, u))
+#define CTL_HEADER_LEN (offsetof(struct ntp_control, data))
#define CTL_MAX_DATA_LEN 468
=====================================
libntp/getopt.c
=====================================
--- a/libntp/getopt.c
+++ b/libntp/getopt.c
@@ -17,8 +17,6 @@ int ntp_optopt;
int ntp_optind = 1;
int ntp_opterr;
-static char* optcursor = NULL;
-
/* Implemented based on [1] and [2] for optional arguments.
ntp_optopt is handled FreeBSD-style, per [3].
Other GNU and FreeBSD extensions are purely accidental.
@@ -31,35 +29,46 @@ int ntp_getopt(int argc, char *const argv[], const char *optstring)
{
int optchar = -1;
const char* optdecl = NULL;
+ static char* optcursor = NULL; /* might not need to be static */
ntp_optarg = NULL;
ntp_opterr = 0;
ntp_optopt = 0;
/* Unspecified, but we need it to avoid overrunning the argv bounds. */
- if (ntp_optind >= argc)
- goto no_more_optchars;
+ if (ntp_optind >= argc) {
+ optcursor = NULL;
+ return -1;
+ }
/* If, when getopt() is called argv[ntp_optind] is a null pointer, getopt()
shall return -1 without changing ntp_optind. */
- if (argv[ntp_optind] == NULL)
- goto no_more_optchars;
+ if (argv[ntp_optind] == NULL) {
+ optcursor = NULL;
+ return -1;
+ }
+
/* If, when getopt() is called *argv[ntp_optind] is not the character '-',
getopt() shall return -1 without changing ntp_optind. */
- if (*argv[ntp_optind] != '-')
- goto no_more_optchars;
+ if (*argv[ntp_optind] != '-') {
+ optcursor = NULL;
+ return -1;
+ }
/* If, when getopt() is called argv[ntp_optind] points to the string "-",
getopt() shall return -1 without changing ntp_optind. */
- if (strcmp(argv[ntp_optind], "-") == 0)
- goto no_more_optchars;
+ if (strcmp(argv[ntp_optind], "-") == 0) {
+ optcursor = NULL;
+ return -1;
+ }
/* If, when getopt() is called argv[ntp_optind] points to the string "--",
getopt() shall return -1 after incrementing ntp_optind. */
if (strcmp(argv[ntp_optind], "--") == 0) {
++ntp_optind;
- goto no_more_optchars;
+ optcursor = NULL;
+ return -1;
}
if (optcursor == NULL || *optcursor == '\0')
@@ -127,10 +136,6 @@ int ntp_getopt(int argc, char *const argv[], const char *optstring)
++ntp_optind;
return optchar;
-
-no_more_optchars:
- optcursor = NULL;
- return -1;
}
/* Implementation based on [1].
=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -780,7 +780,7 @@ process_control(
datanotbinflag = false;
datalinelen = 0;
datasent = false;
- datapt = rpkt.u.data;
+ datapt = rpkt.data;
if ((rbufp->recv_length & 0x3) != 0)
DPRINTF(3, ("Control packet length %zd unrounded\n",
@@ -828,7 +828,7 @@ process_control(
/*
* Set up translate pointers
*/
- reqpt = (char *)pkt->u.data;
+ reqpt = (char *)pkt->data;
reqend = reqpt + req_count;
/*
@@ -936,7 +936,7 @@ ctl_flushpkt(
int totlen;
keyid_t keyid;
- dlen = datapt - rpkt.u.data;
+ dlen = datapt - rpkt.data;
if (!more && datanotbinflag && dlen + 2 < CTL_MAX_DATA_LEN) {
/*
* Big hack, output a trailing \r\n
@@ -954,7 +954,7 @@ ctl_flushpkt(
* which means Python mode 6 clients might actually see the trailing
* garbage.
*/
- memset(rpkt.u.data + sendlen, '\0', sizeof(rpkt.u.data) - sendlen);
+ memset(rpkt.data + sendlen, '\0', sizeof(rpkt.data) - sendlen);
/*
* Pad to a multiple of 32 bits
@@ -998,7 +998,7 @@ ctl_flushpkt(
*/
res_frags++;
res_offset += dlen;
- datapt = rpkt.u.data;
+ datapt = rpkt.data;
}
@@ -1014,7 +1014,7 @@ ctl_putdata(
)
{
int overhead;
- const uint8_t * dataend = &rpkt.u.data[CTL_MAX_DATA_LEN];
+ const uint8_t * dataend = &rpkt.data[CTL_MAX_DATA_LEN];
overhead = 0;
if (!bin) {
@@ -3868,12 +3868,12 @@ read_ordlist(
cpkt = (struct ntp_control *)&rbufp->recv_pkt;
qdata_octets = ntohs(cpkt->count);
if (0 == qdata_octets || (ifstatint8_ts == qdata_octets &&
- !memcmp(ifstats_s, cpkt->u.data, ifstatint8_ts))) {
+ !memcmp(ifstats_s, cpkt->data, ifstatint8_ts))) {
read_ifstats(rbufp);
return;
}
if (a_r_chars == qdata_octets &&
- !memcmp(addr_rst_s, cpkt->u.data, a_r_chars)) {
+ !memcmp(addr_rst_s, cpkt->data, a_r_chars)) {
read_addr_restrictions(rbufp);
return;
}
=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -145,7 +145,8 @@ def linkmaker(ctx):
#print "removing", path_source.abspath()
os.remove(path_source.abspath())
bldnode = ctx.bldnode.abspath()
- os.system("ln -sf %s/libntp/ntpc.so %s/pylib/ntpc.so " % (bldnode, bldnode))
+ if ctx.cmd in ('install', 'build'):
+ os.system("ln -sf %s/libntp/ntpc.so %s/pylib/ntpc.so " % (bldnode, bldnode))
def build(ctx):
ctx.load('waf', tooldir='wafhelpers/')
@@ -204,7 +205,7 @@ def build(ctx):
install_path = "${PREFIX}/bin/"
)
- linkmaker(ctx)
+ ctx.add_post_fun(linkmaker)
ctx.manpage(8, "ntpleapfetch/ntpleapfetch-man.txt")
ctx.manpage(1, "ntptrace/ntptrace-man.txt")
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/437a41466b260cf4598743a21282c45ee9c18cc1...7b7ac6c1842cfc75f137ccaa009e5853537168f9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161121/13b33519/attachment.html>
More information about the vc
mailing list