[Git][NTPsec/ntpsec][master] 2 commits: Generate ntpd version string with autorevision.
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Dec 19 04:39:18 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
256569ae by Eric S. Raymond at 2016-12-18T23:36:58-05:00
Generate ntpd version string with autorevision.
- - - - -
1c4775d2 by Eric S. Raymond at 2016-12-18T23:36:58-05:00
Fix Coverity defect CID 155061: Incorrect expression (ASSERT_SIDE_EFFECT)
- - - - -
11 changed files:
- .gitignore
- include/ntp_stdlib.h
- include/ntp_types.h
- libntp/ntp_calendar.c
- ntpd/ntp_config.c
- ntpd/ntp_control.c
- ntpd/ntpd.c
- ntpd/wscript
- pylib/util.py
- wafhelpers/waf.py
- wscript
Changes:
=====================================
.gitignore
=====================================
--- a/.gitignore
+++ b/.gitignore
@@ -6,5 +6,6 @@ wafhelpers/.autorevision-cache
.lock-waf*
.waf*
*.pyc
+ntpd/version.h
build
=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -22,8 +22,7 @@
#define NTP_PRINTF(fmt, args)
#endif
-extern const char *Version;
-extern const char *VVersion;
+extern const char *ntpd_version(void);
extern int mprintf(const char *, ...) NTP_PRINTF(1, 2);
extern int mfprintf(FILE *, const char *, ...) NTP_PRINTF(2, 3);
=====================================
include/ntp_types.h
=====================================
--- a/include/ntp_types.h
+++ b/include/ntp_types.h
@@ -55,7 +55,7 @@ typedef uint64_t time64_t;
#define settime64s(n,v) (n) = ((int64_t)(v))
#define time64u(n) (n)
#define settime64u(n,v) (n) = (v)
-#define negtime64(n) (n = ((uint64_t)((((int64_t)(n)) * -1))))
+#define negtime64(n) ((uint64_t)((((int64_t)(n)) * -1)))
typedef uint16_t associd_t; /* association ID */
#define ASSOCID_MAX USHRT_MAX
=====================================
libntp/ntp_calendar.c
=====================================
--- a/libntp/ntp_calendar.c
+++ b/libntp/ntp_calendar.c
@@ -64,7 +64,7 @@ time_to_time64(
settime64u(res, 0);
if (tt < 0) {
settime64lo(res, (uint32_t)-tt);
- negtime64(res);
+ res = negtime64(res);
} else {
settime64lo(res, (uint32_t)tt);
}
=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -3313,8 +3313,7 @@ void readconfig(const char *config_file)
/*
* install a non default variable with this daemon version
*/
- snprintf(line, sizeof(line),
- "daemon_version=\"ntpd %s\"", Version);
+ snprintf(line, sizeof(line), "daemon_version=\"%s\"", ntpd_version());
set_sys_var(line, strlen(line) + 1, RO);
init_syntax_tree(&cfgt);
=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -1514,9 +1514,8 @@ ctl_putsys(
break;
case CS_VERSION:
- snprintf(str, sizeof(str), "%s %s",
- "ntpd", Version);
- ctl_putstr(sys_var[CS_VERSION].text, str, strlen(str));
+ ss = ntpd_version();
+ ctl_putstr(sys_var[CS_VERSION].text, ss, strlen(ss));
break;
case CS_STABIL:
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -31,6 +31,8 @@
#include "recvbuff.h"
+#include "version.h"
+
extern bool sandbox(const bool droproot,
const char *user, const char *group,
const char *chrootdir,
@@ -376,18 +378,7 @@ parse_cmdline_opts(
}
break;
case 'V':
- sawV++;
- switch (sawV) {
- case 1:
- printf("ntpd %s\n", Version);
- break;
- case 2:
- printf("ntpd %s\n", VVersion);
- break;
- default:
- printf("ntpd no-more\n");
- break;
- }
+ printf("%s\n", ntpd_version());
break;
case 'w':
wait_sync = strtod(ntp_optarg, NULL);
@@ -496,6 +487,14 @@ set_process_priority(void)
msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
}
+const char *ntpd_version(void)
+{
+ static char versionbuf[32];
+ snprintf(versionbuf, sizeof(versionbuf),
+ "%s-%s-%d", VCS_BASENAME, VERSION, VCS_TICK);
+ return versionbuf;
+}
+
/*
* Main program. Initialize us, disconnect us from the tty if necessary,
* and loop waiting for I/O and/or timer expiries.
@@ -549,7 +548,7 @@ ntpdmain(
char buf[1024]; /* Secret knowledge of msyslog buf length */
char *cp = buf;
- msyslog(LOG_NOTICE, "ntpd %s: Starting", Version);
+ msyslog(LOG_NOTICE, "ntpd %s: Starting", ntpd_version());
/* Note that every arg has an initial space character */
snprintf(cp, sizeof(buf), "Command line:");
=====================================
ntpd/wscript
=====================================
--- a/ntpd/wscript
+++ b/ntpd/wscript
@@ -2,6 +2,8 @@
def build(ctx):
srcnode = ctx.srcnode.abspath()
bldnode = ctx.bldnode.abspath()
+ target3 = ctx.srcnode.make_node('ntpd/version.h')
+ target4 = ctx.srcnode.make_node('wafhelpers/.autorevision-cache')
if ctx.variant == "host":
bison_source = [
@@ -18,7 +20,14 @@ def build(ctx):
]
)
- ctx.add_group() # Generate Bison files first.
+ ctx(
+ cwd = srcnode,
+ rule = 'VCS_EXTRA=`cat ${SRC[0]}` wafhelpers/autorevision.sh -o ${TGT[1].abspath()} -e VERSION -t c >${TGT[0].abspath()}',
+ source = ["../VERSION", '../wafhelpers/autorevision.sh'] ,
+ target = [target3, target4],
+ )
+
+ ctx.add_group() # Generate Bison and version.h files first.
keyword_gen_source = [
"keyword-gen.c",
@@ -127,7 +136,7 @@ def build(ctx):
ctx(
target = "ntpd",
- features = "c rtems_trace cprogram bld_include src_include libisc_include libisc_pthread_include ntp_version",
+ features = "c rtems_trace cprogram bld_include src_include libisc_include libisc_pthread_include",
source = ntpd_source,
use = "libntpd_obj isc ntp sodium M parse RT CAP SECCOMP PTHREAD CRYPTO DNS_SD DNS_SD_INCLUDES %s" % use_refclock,
includes = [
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -30,8 +30,10 @@ OLD_CTL_PST_SEL_SYNCCAND = 2
OLD_CTL_PST_SEL_SYSPEER = 3
def stdversion():
- return "%s-%s-%s %s" % (ntp.version.VERSION, ntp.version.VCS_TICK,
- ntp.version.VCS_BASENAME, ntp.version.VCS_DATE)
+ return "%s-%s-%s %s" % (ntp.version.VCS_BASENAME,
+ ntp.version.VERSION,
+ ntp.version.VCS_TICK,
+ ntp.version.VCS_DATE)
def rfc3339(t):
"RFC 3339 string from Unix time, including fractional second."
=====================================
wafhelpers/waf.py
=====================================
--- a/wafhelpers/waf.py
+++ b/wafhelpers/waf.py
@@ -30,27 +30,6 @@ def insert_libiscpthreaddir(self):
self.includes += ["%s/libisc/pthreads/include/" % srcnode]
-# Create version.c
-class version(Task):
- vars = ['NTPSEC_VERSION_STRING', 'TARGET']
-
- def run(self):
- self.outputs[0].write("""
-const char *Version = "%s " __DATE__ " " __TIME__;
-const char *VVersion = "CFLAGS=%s LDFLAGS=%s";
-""" % (self.env.NTPSEC_VERSION_STRING, "Need-CFLAGS", "Need-LDFLAGS"))
-
-# Use in features= to generate a version.c for that target.
-# This uses the target name for the version string.
- at before_method('process_source')
- at feature('ntp_version')
-def ntp_version(self):
- n = self.path.find_or_declare('version.c')
- tsk = self.create_task('version', [], [n])
- tsk.env.TARGET = self.target
- self.source.extend([n])
-
-
def manpage_subst_fun(task, text):
return text.replace("include::../docs/", "include::../../../docs/")
=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -115,7 +115,7 @@ def afterparty(ctx):
# Also, they need to be able to see the Python extension
# module built in libntp.
if ctx.cmd == 'clean':
- ctx.exec_command("rm -f wafhelpers/*.pyc pylib/__pycache__/*.pyc wafhelpers/__pycache__/*.pyc")
+ ctx.exec_command("rm -f wafhelpers/*.pyc pylib/__pycache__/*.pyc wafhelpers/__pycache__/*.pyc ntpd/version.h")
for x in ("ntpclients",): # List used to be longer...
path_build = ctx.bldnode.make_node("pylib")
path_source = ctx.srcnode.make_node(x + "/ntp")
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/d690cb89d92e455d563e50e7fce942d91660d3bb...1c4775d20f683253ec56bc10b88ee887ce61b98f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161219/122e0e9c/attachment.html>
More information about the vc
mailing list