[Git][NTPsec/ntpsec][master] Simplify signatures of functions in libntp/dolfptoa.c. Pure refactoring.
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Dec 26 17:28:32 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
44ef62f9 by Eric S. Raymond at 2016-12-26T12:26:06-05:00
Simplify signatures of functions in libntp/dolfptoa.c. Pure refactoring.
Whar we're doing here is actually treating l_fp as a unitary type rather
than something that has to be passed around as a pair of scalar components.
- - - - -
12 changed files:
- include/ntp_fp.h
- include/ntp_stdlib.h
- libntp/dolfptoa.c
- libparse/mfp_mul.c
- ntpd/ntp_refclock.c
- ntpd/ntp_util.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- tests/libntp/lfptest.h
- tests/libntp/lfptostr.c
- tests/libntp/refidsmear.c
- tests/libntp/timespecops.c
Changes:
=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -209,7 +209,7 @@ typedef uint32_t u_fp;
/*
* Operations on the long fp format
- * FIXME: Using lfpuint(x) as rvalue, this will fail when rpresentation changes
+ * FIXME: Using lfpuint(x) as rvalue, this will fail when representation changes.
*/
#define L_ADD(r, a) M_ADD(lfpuint(*r), lfpfrac(*r), lfpuint(*a), lfpfrac(*a))
#define L_SUB(r, a) M_SUB(lfpuint(*r), lfpfrac(*r), lfpuint(*a), lfpfrac(*a))
@@ -319,7 +319,9 @@ typedef uint32_t u_fp;
* Prototypes
*/
extern char * dofptoa (u_fp, bool, short, bool);
-extern char * dolfptoa (uint32_t, uint32_t, bool, short, bool);
+extern char * dolfptoa (l_fp, bool, short, bool);
+extern char * mfptoa (l_fp, short);
+extern char * mfptoms (l_fp, short);
extern bool atolfp (const char *, l_fp *);
extern char * fptoa (s_fp, short);
@@ -340,14 +342,14 @@ extern void get_systime (l_fp *);
extern bool step_systime (double, int (*settime)(struct timespec *));
extern bool adj_systime (double, int (*adjtime)(const struct timeval *, struct timeval *));
-#define lfptoa(fpv, ndec) mfptoa(lfpuint(*fpv), lfpfrac(*fpv), (ndec))
-#define lfptoms(fpv, ndec) mfptoms(lfpuint(*fpv), lfpfrac(*fpv), (ndec))
+#define lfptoa(fpv, ndec) mfptoa((fpv), (ndec))
+#define lfptoms(fpv, ndec) mfptoms((fpv), (ndec))
#define ufptoa(fpv, ndec) dofptoa((fpv), false, (ndec), false)
#define ufptoms(fpv, ndec) dofptoa((fpv), false, (ndec), true)
-#define ulfptoa(fpv, ndec) dolfptoa(lfpuint(*fpv), lfpfrac(*fpv), 0, (ndec), 0)
-#define ulfptoms(fpv, ndec) dolfptoa(lfpuint(*fpv), lfpfrac(*fpv), 0, (ndec), 1)
-#define umfptoa(fpi, fpf, ndec) dolfptoa((fpi), (fpf), 0, (ndec), 0)
+#define ulfptoa(fpv, ndec) dolfptoa(fpv, 0, (ndec), 0)
+#define ulfptoms(fpv, ndec) dolfptoa(fpv, 0, (ndec), 1)
+#define umfptoa(lfp, ndec) dolfptoa((lfp), 0, (ndec), 0)
/*
* Optional callback from libntp step_systime() to ntpd. Optional
=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -139,8 +139,6 @@ extern char * estrdup_impl(const char *, const char *, int);
extern const char * humanlogtime (void);
extern const char * humantime (time_t);
-extern char * mfptoa (uint32_t, uint32_t, short);
-extern char * mfptoms (uint32_t, uint32_t, short);
extern const char * eventstr (int);
extern const char * ceventstr (int);
extern const char * res_match_flags(unsigned short);
=====================================
libntp/dolfptoa.c
=====================================
--- a/libntp/dolfptoa.c
+++ b/libntp/dolfptoa.c
@@ -16,13 +16,14 @@
char *
dolfptoa(
- uint32_t fpi,
- uint32_t fpv,
+ l_fp lfp,
bool neg,
short ndec,
bool msec
)
{
+ uint32_t fpi = lfpuint(lfp);
+ uint32_t fpv = lfpfrac(lfp);
uint8_t *cp, *cpend, *cpdec;
int dec;
uint8_t cbuf[24];
@@ -143,37 +144,33 @@ dolfptoa(
char *
mfptoa(
- uint32_t fpi,
- uint32_t fpf,
+ l_fp lfp,
short ndec
)
{
- bool isneg;
+ bool isneg = L_ISNEG(&lfp);
- isneg = M_ISNEG(fpi);
if (isneg) {
- M_NEG(fpi, fpf);
+ L_NEG(&lfp);
}
- return dolfptoa(fpi, fpf, isneg, ndec, false);
+ return dolfptoa(lfp, isneg, ndec, false);
}
char *
mfptoms(
- uint32_t fpi,
- uint32_t fpf,
+ l_fp lfp,
short ndec
)
{
- bool isneg;
+ bool isneg = L_ISNEG(&lfp);
- isneg = M_ISNEG(fpi);
if (isneg) {
- M_NEG(fpi, fpf);
+ L_NEG(&lfp);
}
- return dolfptoa(fpi, fpf, isneg, ndec, true);
+ return dolfptoa(lfp, isneg, ndec, true);
}
=====================================
libparse/mfp_mul.c
=====================================
--- a/libparse/mfp_mul.c
+++ b/libparse/mfp_mul.c
@@ -135,11 +135,13 @@ mfp_mul(
setlfpfrac(out, f);
#ifdef DEBUG
- if (debug > 6)
+ if (debug > 6) {
+ l_fp b;
+ setlfpsint(b, b_i);
+ setlfpfrac(b, b_f);
printf("mfp_mul: %s * %s => %s\n",
- mfptoa((unsigned long)a_i, a_f, 6),
- mfptoa((unsigned long)b_i, b_f, 6),
- mfptoa((unsigned long)i, f, 6));
+ mfptoa(a_op, 6), mfptoa(b, 6), mfptoa(out, 6));
+ }
#endif
return out;
}
=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -596,7 +596,7 @@ refclock_gtlin(
*dp = '\0';
*tsptr = rbufp->recv_time;
DPRINTF(2, ("refclock_gtlin: fd %d time %s timecode %d %s\n",
- rbufp->fd, ulfptoa(&rbufp->recv_time, 6), dlen,
+ rbufp->fd, ulfptoa(rbufp->recv_time, 6), dlen,
(dlen != 0)
? lineptr
: ""));
@@ -637,7 +637,7 @@ refclock_gtraw(
*tsptr = rbufp->recv_time;
DPRINTF(2, ("refclock_gtraw: fd %d time %s timecode %zd %s\n",
- rbufp->fd, ulfptoa(&rbufp->recv_time, 6), bmax,
+ rbufp->fd, ulfptoa(rbufp->recv_time, 6), bmax,
lineptr));
return (bmax);
}
=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -387,7 +387,7 @@ record_peer_stats(
if (peerstats.fp != NULL) {
fprintf(peerstats.fp,
"%lu %s %s %x %.9f %.9f %.9f %.9f\n", day,
- ulfptoa(&now, 3), socktoa(&peer->srcadr), status, peer->offset,
+ ulfptoa(now, 3), socktoa(&peer->srcadr), status, peer->offset,
peer->delay, peer->disp, peer->jitter);
fflush(peerstats.fp);
}
@@ -437,7 +437,7 @@ record_loop_stats(
lfpuint(now) %= 86400;
if (loopstats.fp != NULL) {
fprintf(loopstats.fp, "%lu %s %.9f %.3f %.9f %.6f %d\n",
- day, ulfptoa(&now, 3), offset, freq * 1e6, jitter,
+ day, ulfptoa(now, 3), offset, freq * 1e6, jitter,
wander * 1e6, spoll);
fflush(loopstats.fp);
}
@@ -471,7 +471,7 @@ record_clock_stats(
lfpuint(now) %= 86400;
if (clockstats.fp != NULL) {
fprintf(clockstats.fp, "%lu %s %s %s\n", day,
- ulfptoa(&now, 3), peerlabel(peer), text);
+ ulfptoa(now, 3), peerlabel(peer), text);
fflush(clockstats.fp);
}
}
@@ -544,10 +544,10 @@ record_raw_stats(
lfpuint(now) %= 86400;
if (rawstats.fp != NULL) {
fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s %d\n",
- day, ulfptoa(&now, 3),
+ day, ulfptoa(now, 3),
socktoa(srcadr), dstadr ? socktoa(dstadr) : "-",
- ulfptoa(t1, 9), ulfptoa(t2, 9),
- ulfptoa(t3, 9), ulfptoa(t4, 9),
+ ulfptoa(*t1, 9), ulfptoa(*t2, 9),
+ ulfptoa(*t3, 9), ulfptoa(*t4, 9),
leap, version, mode, stratum, ppoll, precision,
root_delay, root_dispersion, refid_str(refid, stratum),
outcount);
@@ -590,7 +590,7 @@ record_sys_stats(void)
if (sysstats.fp != NULL) {
fprintf(sysstats.fp,
"%lu %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
- day, ulfptoa(&now, 3), current_time - sys_stattime,
+ day, ulfptoa(now, 3), current_time - sys_stattime,
sys_received, sys_processed, sys_newversion,
sys_oldversion, sys_restricted, sys_badlength,
sys_badauth, sys_declined, sys_limitrejected,
@@ -637,7 +637,7 @@ void record_use_stats(void)
stime += usage.ru_stime.tv_sec - oldusage.ru_stime.tv_sec;
fprintf(usestats.fp,
"%lu %s %lu %.3f %.3f %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
- day, ulfptoa(&now, 3), current_time - use_stattime,
+ day, ulfptoa(now, 3), current_time - use_stattime,
utime, stime,
usage.ru_minflt - oldusage.ru_minflt,
usage.ru_majflt - oldusage.ru_majflt,
@@ -681,7 +681,7 @@ record_proto_stats(
lfpuint(now) %= 86400;
if (protostats.fp != NULL) {
fprintf(protostats.fp, "%lu %s %s\n", day,
- ulfptoa(&now, 3), str);
+ ulfptoa(now, 3), str);
fflush(protostats.fp);
}
}
@@ -712,7 +712,7 @@ record_timing_stats(
day = lfpuint(now) / 86400 + MJD_1900;
lfpuint(now) %= 86400;
if (timingstats.fp != NULL) {
- fprintf(timingstats.fp, "%lu %s %s\n", day, lfptoa(&now,
+ fprintf(timingstats.fp, "%lu %s %s\n", day, lfptoa(now,
3), text);
if (++flshcnt % 100 == 0)
fflush(timingstats.fp);
=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -1871,7 +1871,7 @@ local_input(
"parse: local_receive: fd %d PPSAPI seq %ld - PPS %s\n",
rbufp->fd,
(long)pps_info.assert_sequence + (long)pps_info.clear_sequence,
- lfptoa(&parse->parseio.parse_dtime.parse_ptime.fp, 6));
+ lfptoa(parse->parseio.parse_dtime.parse_ptime.fp, 6));
}
#endif
}
@@ -3039,7 +3039,7 @@ parse_control(
off = parse->timedata.parse_stime.fp;
L_SUB(&off, &parse->timedata.parse_ptime.fp); /* true offset */
tt = add_var(&out->kv_list, 80, RO);
- snprintf(tt, 80, "refclock_ppsskew=%s", lfptoms(&off, 6));
+ snprintf(tt, 80, "refclock_ppsskew=%s", lfptoms(off, 6));
}
}
@@ -3477,7 +3477,7 @@ parse_process(
parse->peer->refclkunit,
prettydate(&reftime),
prettydate(&rectime),
- lfptoa(&off,6));
+ lfptoa(off,6));
#endif
}
@@ -3585,7 +3585,7 @@ parse_process(
parse->peer->refclkunit,
prettydate(&reftime),
prettydate(&rectime),
- lfptoa(&off,6));
+ lfptoa(off,6));
#endif
@@ -3880,9 +3880,9 @@ gps16x_message(
get_mbg_xyz(&bufp, xyz);
snprintf(buffer, sizeof(buffer), "gps_position(XYZ)=\"%s m, %s m, %s m\"",
- mfptoa(lfpuint(xyz[XP]), lfpfrac(xyz[XP]), 1),
- mfptoa(lfpuint(xyz[YP]), lfpfrac(xyz[YP]), 1),
- mfptoa(lfpuint(xyz[ZP]), lfpfrac(xyz[ZP]), 1));
+ mfptoa(xyz[XP], 1),
+ mfptoa(xyz[YP], 1),
+ mfptoa(xyz[ZP], 1));
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
@@ -3896,9 +3896,9 @@ gps16x_message(
get_mbg_lla(&bufp, lla);
snprintf(buffer, sizeof(buffer), "gps_position(LLA)=\"%s deg, %s deg, %s m\"",
- mfptoa(lfpuint(lla[LAT]), lfpfrac(lla[LAT]), 4),
- mfptoa(lfpuint(lla[LON]), lfpfrac(lla[LON]), 4),
- mfptoa(lfpuint(lla[ALT]), lfpfrac(lla[ALT]), 1));
+ mfptoa(lla[LAT], 4),
+ mfptoa(lla[LON], 4),
+ mfptoa(lla[ALT], 1));
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -1727,7 +1727,7 @@ gpsd_parse(
const char * clsid;
DPRINTF(2, ("%s: gpsd_parse: time %s '%.*s'\n",
- up->logname, ulfptoa(rtime, 6),
+ up->logname, ulfptoa(*rtime, 6),
up->buflen, up->buffer));
/* See if we can grab anything potentially useful. JSMN does not
=====================================
tests/libntp/lfptest.h
=====================================
--- a/tests/libntp/lfptest.h
+++ b/tests/libntp/lfptest.h
@@ -7,7 +7,7 @@ static bool IsEqual(const l_fp *expected, const l_fp *actual) {
if (L_ISEQU(expected, actual)) {
return true;
} else {
- printf("Expected: %s (%d.%d) but was: %s (%d.%d)\n", lfptoa(expected, FRACTION_PREC), lfpuint(*expected), lfpfrac(*expected), lfptoa(actual, FRACTION_PREC), lfpuint(*actual), lfpfrac(*actual));
+ printf("Expected: %s (%d.%d) but was: %s (%d.%d)\n", lfptoa(*expected, FRACTION_PREC), lfpuint(*expected), lfpfrac(*expected), lfptoa(*actual, FRACTION_PREC), lfpuint(*actual), lfpfrac(*actual));
return false;
}
}
=====================================
tests/libntp/lfptostr.c
=====================================
--- a/tests/libntp/lfptostr.c
+++ b/tests/libntp/lfptostr.c
@@ -32,75 +32,75 @@ static const int HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005
TEST(lfptostr, PositiveInteger) {
l_fp test = {{200}, 0}; // exact 200.0000000000
- TEST_ASSERT_EQUAL_STRING("200.0000000000", mfptoa(lfpuint(test), lfpfrac(test), LFP_MAX_PRECISION));
- TEST_ASSERT_EQUAL_STRING("200000.0000000", mfptoms(lfpuint(test), lfpfrac(test), LFP_MAX_PRECISION_MS));
+ TEST_ASSERT_EQUAL_STRING("200.0000000000", mfptoa(test, LFP_MAX_PRECISION));
+ TEST_ASSERT_EQUAL_STRING("200000.0000000", mfptoms(test, LFP_MAX_PRECISION_MS));
}
TEST(lfptostr, NegativeInteger) {
l_fp test = {{-100}, 0}; // -100
- TEST_ASSERT_EQUAL_STRING("-100.0000000000", lfptoa(&test, LFP_MAX_PRECISION));
- TEST_ASSERT_EQUAL_STRING("-100000.0000000", lfptoms(&test, LFP_MAX_PRECISION_MS));
+ TEST_ASSERT_EQUAL_STRING("-100.0000000000", lfptoa(test, LFP_MAX_PRECISION));
+ TEST_ASSERT_EQUAL_STRING("-100000.0000000", lfptoms(test, LFP_MAX_PRECISION_MS));
}
TEST(lfptostr, PositiveIntegerWithFraction) {
l_fp test = {{200}, ONE_FOURTH}; // 200.25
- TEST_ASSERT_EQUAL_STRING("200.2500000000", lfptoa(&test, LFP_MAX_PRECISION));
- TEST_ASSERT_EQUAL_STRING("200250.0000000", lfptoms(&test, LFP_MAX_PRECISION_MS));
+ TEST_ASSERT_EQUAL_STRING("200.2500000000", lfptoa(test, LFP_MAX_PRECISION));
+ TEST_ASSERT_EQUAL_STRING("200250.0000000", lfptoms(test, LFP_MAX_PRECISION_MS));
}
TEST(lfptostr, NegativeIntegerWithFraction) {
l_fp test = {{-100}, ONE_FOURTH}; // -99.75
- TEST_ASSERT_EQUAL_STRING("-99.7500000000", lfptoa(&test, LFP_MAX_PRECISION));
- TEST_ASSERT_EQUAL_STRING("-99750.0000000", lfptoms(&test, LFP_MAX_PRECISION_MS));
+ TEST_ASSERT_EQUAL_STRING("-99.7500000000", lfptoa(test, LFP_MAX_PRECISION));
+ TEST_ASSERT_EQUAL_STRING("-99750.0000000", lfptoms(test, LFP_MAX_PRECISION_MS));
}
TEST(lfptostr, RoundingDownToInteger) {
l_fp test = {{10}, ONE_FOURTH}; // 10.25
- TEST_ASSERT_EQUAL_STRING("10", lfptoa(&test, 0));
- TEST_ASSERT_EQUAL_STRING("10250", lfptoms(&test, 0));
+ TEST_ASSERT_EQUAL_STRING("10", lfptoa(test, 0));
+ TEST_ASSERT_EQUAL_STRING("10250", lfptoms(test, 0));
}
TEST(lfptostr, RoundingMiddleToInteger) {
l_fp test = {{10}, HALF}; // 10.5
- TEST_ASSERT_EQUAL_STRING("11", lfptoa(&test, 0));
- TEST_ASSERT_EQUAL_STRING("10500", lfptoms(&test, 0));
+ TEST_ASSERT_EQUAL_STRING("11", lfptoa(test, 0));
+ TEST_ASSERT_EQUAL_STRING("10500", lfptoms(test, 0));
}
TEST(lfptostr, RoundingUpToInteger) {
l_fp test = {{5}, THREE_FOURTH}; // 5.75
- TEST_ASSERT_EQUAL_STRING("6", lfptoa(&test, 0));
- TEST_ASSERT_EQUAL_STRING("5750", lfptoms(&test, 0));
+ TEST_ASSERT_EQUAL_STRING("6", lfptoa(test, 0));
+ TEST_ASSERT_EQUAL_STRING("5750", lfptoms(test, 0));
}
TEST(lfptostr, SingleDecimal) {
l_fp test = {{8}, ONE_FOURTH}; // 8.25
- TEST_ASSERT_EQUAL_STRING("8.3", lfptoa(&test, 1));
- TEST_ASSERT_EQUAL_STRING("8250.0", lfptoms(&test, 1));
+ TEST_ASSERT_EQUAL_STRING("8.3", lfptoa(test, 1));
+ TEST_ASSERT_EQUAL_STRING("8250.0", lfptoms(test, 1));
}
TEST(lfptostr, MillisecondsRoundingUp) {
l_fp test = {{1}, HALF_PROMILLE_UP}; //slightly more than 1.0005
- TEST_ASSERT_EQUAL_STRING("1.0", lfptoa(&test, 1));
+ TEST_ASSERT_EQUAL_STRING("1.0", lfptoa(test, 1));
- TEST_ASSERT_EQUAL_STRING("1000.5", lfptoms(&test, 1));
- TEST_ASSERT_EQUAL_STRING("1001", lfptoms(&test, 0));
+ TEST_ASSERT_EQUAL_STRING("1000.5", lfptoms(test, 1));
+ TEST_ASSERT_EQUAL_STRING("1001", lfptoms(test, 0));
}
TEST(lfptostr, MillisecondsRoundingDown) {
l_fp test = {{1}, HALF_PROMILLE_DOWN}; // slightly less than 1.0005
- TEST_ASSERT_EQUAL_STRING("1.0", lfptoa(&test, 1));
+ TEST_ASSERT_EQUAL_STRING("1.0", lfptoa(test, 1));
- TEST_ASSERT_EQUAL_STRING("1000.5", lfptoms(&test, 1));
- TEST_ASSERT_EQUAL_STRING("1000", lfptoms(&test, 0));
+ TEST_ASSERT_EQUAL_STRING("1000.5", lfptoms(test, 1));
+ TEST_ASSERT_EQUAL_STRING("1000", lfptoms(test, 0));
}
TEST(lfptostr, UnsignedInteger) {
@@ -116,19 +116,19 @@ TEST(lfptostr, UnsignedInteger) {
l_fp test8b = {{1444359386UL}, 0x2E0C7583};
l_fp test9 = {{3660323067UL}, 0x1CD3101C};
- TEST_ASSERT_EQUAL_STRING("3000000000.0", ulfptoa(&test1, 1));
- TEST_ASSERT_EQUAL_STRING("3000000000.000000", ulfptoa(&test1, 6));
- TEST_ASSERT_EQUAL_STRING("3000000.5", ulfptoa(&test2, 1));
- TEST_ASSERT_EQUAL_STRING("3000000.500", ulfptoa(&test2, 3));
- TEST_ASSERT_EQUAL_STRING("13.750000", ulfptoa(&test3, 6));
- TEST_ASSERT_EQUAL_STRING("13.010000", ulfptoa(&test4, 6));
-
- TEST_ASSERT_EQUAL_STRING("4212665562.2360215127", ulfptoa(&test5, 10));
- TEST_ASSERT_EQUAL_STRING("4212665562.2114585943", ulfptoa(&test6, 10));
- TEST_ASSERT_EQUAL_STRING("4212665562.739245376", ulfptoa(&test7, 9));
- TEST_ASSERT_EQUAL_STRING("1444359386.1798776095", ulfptoa(&test8a, 10));
- TEST_ASSERT_EQUAL_STRING("1444359386.1798776097", ulfptoa(&test8b, 10));
- TEST_ASSERT_EQUAL_STRING("3660323067.1125955647", ulfptoa(&test9, 10));
+ TEST_ASSERT_EQUAL_STRING("3000000000.0", ulfptoa(test1, 1));
+ TEST_ASSERT_EQUAL_STRING("3000000000.000000", ulfptoa(test1, 6));
+ TEST_ASSERT_EQUAL_STRING("3000000.5", ulfptoa(test2, 1));
+ TEST_ASSERT_EQUAL_STRING("3000000.500", ulfptoa(test2, 3));
+ TEST_ASSERT_EQUAL_STRING("13.750000", ulfptoa(test3, 6));
+ TEST_ASSERT_EQUAL_STRING("13.010000", ulfptoa(test4, 6));
+
+ TEST_ASSERT_EQUAL_STRING("4212665562.2360215127", ulfptoa(test5, 10));
+ TEST_ASSERT_EQUAL_STRING("4212665562.2114585943", ulfptoa(test6, 10));
+ TEST_ASSERT_EQUAL_STRING("4212665562.739245376", ulfptoa(test7, 9));
+ TEST_ASSERT_EQUAL_STRING("1444359386.1798776095", ulfptoa(test8a, 10));
+ TEST_ASSERT_EQUAL_STRING("1444359386.1798776097", ulfptoa(test8b, 10));
+ TEST_ASSERT_EQUAL_STRING("3660323067.1125955647", ulfptoa(test9, 10));
}
TEST_GROUP_RUNNER(lfptostr) {
=====================================
tests/libntp/refidsmear.c
=====================================
--- a/tests/libntp/refidsmear.c
+++ b/tests/libntp/refidsmear.c
@@ -44,7 +44,7 @@ rtol(uint32_t r, const char *es)
snprintf(msg, 100, "rtol was called with r=%#.8x, es=%s", r, es);
l = convertRefIDToLFP(htonl(r));
- as = lfptoa(&l, 8);
+ as = lfptoa(l, 8);
//printf("refid %#x, smear %s\n", r, as);
@@ -67,7 +67,7 @@ rtoltor(uint32_t er, const char *es)
snprintf(msg, 100, "rtoltor was called with er=%#.8x, es=%s", er, es);
l = convertRefIDToLFP(htonl(er));
- as = lfptoa(&l, 8);
+ as = lfptoa(l, 8);
ar = convertLFPToRefID(l);
=====================================
tests/libntp/timespecops.c
=====================================
--- a/tests/libntp/timespecops.c
+++ b/tests/libntp/timespecops.c
@@ -83,7 +83,7 @@ static bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit)
return true;
}
else {
- printf("m_expr which is %s \nand\nn_expr which is %s\nare not close; diff=%susec\n", lfptoa(&m, 10), lfptoa(&n, 10), lfptoa(&diff, 10));
+ printf("m_expr which is %s \nand\nn_expr which is %s\nare not close; diff=%susec\n", lfptoa(m, 10), lfptoa(n, 10), lfptoa(diff, 10));
return false;
}
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/44ef62f993ca2bb27e31a3aa9ab83e565a686b29
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161226/c3685e7f/attachment.html>
More information about the vc
mailing list