[Git][NTPsec/ntpsec][master] 15 commits: libntp: make auth_moremem() static.
Gary E. Miller
gitlab at mg.gitlab.com
Tue May 23 01:42:43 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
a248760e by Gary E. Miller at 2017-05-22T17:59:15-07:00
libntp: make auth_moremem() static.
- - - - -
e3ebd009 by Gary E. Miller at 2017-05-22T18:09:10-07:00
libntp: move atolfp() to a static in tests.
atolfp() was only used by the tests.
Done looking for unused/static in libntp. About 130 LOC removed.
- - - - -
77965091 by Gary E. Miller at 2017-05-22T18:15:03-07:00
libparse: remove unused get_mbg_svno()
- - - - -
902df09c by Gary E. Miller at 2017-05-22T18:17:02-07:00
libparse: make get_mbg_health() static
- - - - -
eedcb8e2 by Gary E. Miller at 2017-05-22T18:19:01-07:00
libparse: make get_mbg_cfg() static.
- - - - -
b1038739 by Gary E. Miller at 2017-05-22T18:21:49-07:00
libparse: make get_mbg_tgps() static.
- - - - -
8efc4de1 by Gary E. Miller at 2017-05-22T18:23:49-07:00
libparse: make get_mbg_tm(0 static
- - - - -
58cd0a3c by Gary E. Miller at 2017-05-22T18:25:30-07:00
libparse: remopve unused get_mbg_ttm()
- - - - -
91beb09a by Gary E. Miller at 2017-05-22T18:27:34-07:00
libparse: remove unused get_mbg_synth()
- - - - -
23de1952 by Gary E. Miller at 2017-05-22T18:29:18-07:00
libparse: remove unused get_mbg_tzdl()
- - - - -
16443514 by Gary E. Miller at 2017-05-22T18:33:40-07:00
libparse: add missing prototype for get_mbg_comparam().
- - - - -
ab0fb812 by Gary E. Miller at 2017-05-22T18:35:15-07:00
libparse: remove unused get_mbg_tzname()
- - - - -
88e7c9ee by Gary E. Miller at 2017-05-22T18:38:19-07:00
libparse: remove unused get_mbg_portparam()
- - - - -
07366a9f by Gary E. Miller at 2017-05-22T18:39:46-07:00
libparse: remove unused get_mbg_comparam()
- - - - -
20500641 by Gary E. Miller at 2017-05-22T18:41:59-07:00
libparse; remove unused -get_mbg_eph()
- - - - -
8 changed files:
- include/mbg_gps166.h
- include/ntp_fp.h
- include/ntp_stdlib.h
- − libntp/atolfp.c
- libntp/authkeys.c
- libntp/wscript
- libparse/data_mbg.c
- tests/libntp/strtolfp.c
Changes:
=====================================
include/mbg_gps166.h
=====================================
--- a/include/mbg_gps166.h
+++ b/include/mbg_gps166.h
@@ -926,21 +926,11 @@ void get_mbg_header (unsigned char **, GPS_MSG_HDR *);
void put_mbg_header (unsigned char **, GPS_MSG_HDR *);
void get_mbg_sw_rev (unsigned char **, SW_REV *);
void get_mbg_ascii_msg (unsigned char **, ASCII_MSG *);
-void get_mbg_svno (unsigned char **, SVNO *);
-void get_mbg_health (unsigned char **, HEALTH *);
-void get_mbg_cfg (unsigned char **, CFG *);
-void get_mbg_tgps (unsigned char **, T_GPS *);
-void get_mbg_tm (unsigned char **, TM_GPS *);
-void get_mbg_ttm (unsigned char **, TTM *);
-void get_mbg_synth (unsigned char **, SYNTH *);
-void get_mbg_tzdl (unsigned char **, TZDL *);
void get_mbg_antinfo (unsigned char **, ANT_INFO *);
void get_mbg_cfgh (unsigned char **, CFGH *);
void get_mbg_utc (unsigned char **, UTC *);
void get_mbg_lla (unsigned char **, LLA);
void get_mbg_xyz (unsigned char **, XYZ);
-void get_mbg_portparam (unsigned char **, PORT_PARM *);
-void get_mbg_eph (unsigned char **, EPH *);
void get_mbg_alm (unsigned char **, ALM *);
void get_mbg_iono (unsigned char **, IONO *);
=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -188,7 +188,6 @@ 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 bool hextolfp (const char *, l_fp *);
extern void gpstolfp (int, int, unsigned long, l_fp *);
extern char * prettydate (const l_fp);
=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -52,7 +52,6 @@ extern int clocktime (int, int, int, int, int, uint32_t, uint32_t *, uint32_t *)
extern void init_auth (void);
extern void init_lib (void);
extern void init_network (void);
-extern void auth_moremem (int);
extern void auth_prealloc_symkeys(int);
extern int ymd2yd (int, int, int);
=====================================
libntp/atolfp.c deleted
=====================================
--- a/libntp/atolfp.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * atolfp - convert an ascii string to an l_fp number
- */
-#include "config.h"
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-#include "ntp_fp.h"
-#include "ntp_assert.h"
-
-/*
- * Powers of 10
- */
-static unsigned long ten_to_the_n[10] = {
- 0,
- 10,
- 100,
- 1000,
- 10000,
- 100000,
- 1000000,
- 10000000,
- 100000000,
- 1000000000,
-};
-
-
-bool
-atolfp(
- const char *str,
- l_fp *lfp
- )
-{
- register const char *cp;
- register unsigned long dec_i;
- register unsigned long dec_f;
- char *ind;
- int ndec;
- bool isneg;
- static const char *digits = "0123456789";
-
- NTP_REQUIRE(str != NULL);
-
- isneg = false;
- dec_i = dec_f = 0;
- ndec = 0;
- cp = str;
-
- /*
- * We understand numbers of the form:
- *
- * [spaces][-|+][digits][.][digits][spaces|\n|\0]
- */
- while (isspace((unsigned char)*cp))
- cp++;
-
- if (*cp == '-') {
- cp++;
- isneg = true;
- }
-
- if (*cp == '+')
- cp++;
-
- if (*cp != '.' && !isdigit((unsigned char)*cp))
- return false;
-
- while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
- dec_i = (dec_i << 3) + (dec_i << 1); /* multiply by 10 */
- dec_i += (unsigned long)(ind - digits);
- cp++;
- }
-
- if (*cp != '\0' && !isspace((unsigned char)*cp)) {
- if (*cp++ != '.')
- return false;
-
- while (ndec < 9 && *cp != '\0'
- && (ind = strchr(digits, *cp)) != NULL) {
- ndec++;
- dec_f = (dec_f << 3) + (dec_f << 1); /* *10 */
- dec_f += (unsigned long)(ind - digits);
- cp++;
- }
-
- while (isdigit((unsigned char)*cp))
- cp++;
-
- if (*cp != '\0' && !isspace((unsigned char)*cp))
- return false;
- }
-
- if (ndec > 0) {
- register unsigned long tmp;
- register unsigned long bit;
- register unsigned long ten_fact;
-
- ten_fact = ten_to_the_n[ndec];
-
- tmp = 0;
- bit = 0x80000000;
- while (bit != 0) {
- dec_f <<= 1;
- if (dec_f >= ten_fact) {
- tmp |= bit;
- dec_f -= ten_fact;
- }
- bit >>= 1;
- }
- if ((dec_f << 1) > ten_fact)
- tmp++;
- dec_f = tmp;
- }
-
- if (isneg)
- {
- (dec_f) = ~(dec_f) + 1u;
- (dec_i) = ~(dec_i) + ((dec_f) == 0);
- }
-
- *lfp = lfpinit_u(dec_i, dec_f);
- return true;
-}
=====================================
libntp/authkeys.c
=====================================
--- a/libntp/authkeys.c
+++ b/libntp/authkeys.c
@@ -45,6 +45,7 @@ symkey_alloc * authallocs;
#endif /* DEBUG */
static inline unsigned short auth_log2(double x);
+static void auth_moremem (int);
static void auth_resize_hashtable(void);
static void allocsymkey(symkey **, keyid_t, unsigned short,
unsigned short, unsigned short, uint8_t *);
@@ -147,7 +148,7 @@ free_auth_mem(void)
/*
* auth_moremem - get some more free key structures
*/
-void
+static void
auth_moremem(
int keycount
)
=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -2,7 +2,6 @@ def build(ctx):
srcnode = ctx.srcnode.abspath()
libntp_source = [
- "atolfp.c",
"authkeys.c",
"authreadkeys.c",
"clocktime.c",
=====================================
libparse/data_mbg.c
=====================================
--- a/libparse/data_mbg.c
+++ b/libparse/data_mbg.c
@@ -16,7 +16,10 @@
#include "binio.h"
#include "ieee754io.h"
-static void get_mbg_tzname (unsigned char **, char *);
+static void get_mbg_cfg (unsigned char **, CFG *);
+static void get_mbg_health (unsigned char **, HEALTH *);
+static void get_mbg_tgps (unsigned char **, T_GPS *);
+static void get_mbg_tm (unsigned char **, TM_GPS *);
static void mbg_time_status_str (char **, unsigned int, size_t);
#if 0 /* no actual floats on Meinberg binary interface */
@@ -61,16 +64,7 @@ get_mbg_ascii_msg(
*bufpp += sizeof(ascii_msgp->s);
}
-void
-get_mbg_svno(
- unsigned char **bufpp,
- SVNO *svnop
- )
-{
- *svnop = (SVNO) get_lsb_uint16(bufpp);
-}
-
-void
+static void
get_mbg_health(
unsigned char **bufpp,
HEALTH *healthp
@@ -79,7 +73,7 @@ get_mbg_health(
*healthp = (HEALTH) get_lsb_uint16(bufpp);
}
-void
+static void
get_mbg_cfg(
unsigned char **bufpp,
CFG *cfgp
@@ -88,7 +82,7 @@ get_mbg_cfg(
*cfgp = (CFG) get_lsb_uint16(bufpp);
}
-void
+static void
get_mbg_tgps(
unsigned char **bufpp,
T_GPS *tgpsp
@@ -99,7 +93,7 @@ get_mbg_tgps(
tgpsp->tick = get_lsb_uint32(bufpp);
}
-void
+static void
get_mbg_tm(
unsigned char **buffpp,
TM_GPS *tmp
@@ -119,52 +113,6 @@ get_mbg_tm(
}
void
-get_mbg_ttm(
- unsigned char **buffpp,
- TTM *ttmp
- )
-{
- ttmp->channel = get_lsb_int16(buffpp);
- get_mbg_tgps(buffpp, &ttmp->t);
- get_mbg_tm(buffpp, &ttmp->tm);
-}
-
-void
-get_mbg_synth(
- unsigned char **buffpp,
- SYNTH *synthp
- )
-{
- synthp->freq = get_lsb_int16(buffpp);
- synthp->range = get_lsb_int16(buffpp);
- synthp->phase = get_lsb_int16(buffpp);
-}
-
-static void
-get_mbg_tzname(
- unsigned char **buffpp,
- char *tznamep
- )
-{
- strlcpy(tznamep, (char *)*buffpp, sizeof(TZ_NAME));
- *buffpp += sizeof(TZ_NAME);
-}
-
-void
-get_mbg_tzdl(
- unsigned char **buffpp,
- TZDL *tzdlp
- )
-{
- tzdlp->offs = get_lsb_int32(buffpp);
- tzdlp->offs_dl = get_lsb_int32(buffpp);
- get_mbg_tm(buffpp, &tzdlp->tm_on);
- get_mbg_tm(buffpp, &tzdlp->tm_off);
- get_mbg_tzname(buffpp, (char *)tzdlp->name[0]);
- get_mbg_tzname(buffpp, (char *)tzdlp->name[1]);
-}
-
-void
get_mbg_antinfo(
unsigned char **buffpp,
ANT_INFO *antinfop
@@ -347,40 +295,6 @@ get_mbg_xyz(
}
}
-static void
-get_mbg_comparam(
- unsigned char **buffpp,
- COM_PARM *comparamp
- )
-{
- size_t i;
-
- comparamp->baud_rate = get_lsb_int32(buffpp);
- for (i = 0; i < sizeof(comparamp->framing); i++)
- {
- comparamp->framing[i] = (char)(*(*buffpp)++);
- }
- comparamp->handshake = get_lsb_int16(buffpp);
-}
-
-void
-get_mbg_portparam(
- unsigned char **buffpp,
- PORT_PARM *portparamp
- )
-{
- int i;
-
- for (i = 0; i < DEFAULT_N_COM; i++)
- {
- get_mbg_comparam(buffpp, &portparamp->com[i]);
- }
- for (i = 0; i < DEFAULT_N_COM; i++)
- {
- portparamp->mode[i] = *(*buffpp)++;
- }
-}
-
#define FETCH_DOUBLE(src, addr) \
if (fetch_ieee754(src, IEEE_DOUBLE, addr, mbg_double) != IEEE_OK) \
{ \
@@ -388,51 +302,6 @@ get_mbg_portparam(
}
void
-get_mbg_eph(
- unsigned char ** buffpp,
- EPH *ephp
- )
-{
- ephp->csum = (CSUM) get_lsb_uint16(buffpp);
- ephp->valid = get_lsb_int16(buffpp);
-
- ephp->health = (HEALTH) get_lsb_uint16(buffpp);
- ephp->IODC = (IOD) get_lsb_uint16(buffpp);
- ephp->IODE2 = (IOD) get_lsb_uint16(buffpp);
- ephp->IODE3 = (IOD) get_lsb_uint16(buffpp);
-
- get_mbg_tgps(buffpp, &ephp->tt);
- get_mbg_tgps(buffpp, &ephp->t0c);
- get_mbg_tgps(buffpp, &ephp->t0e);
-
- FETCH_DOUBLE(buffpp, &ephp->sqrt_A);
- FETCH_DOUBLE(buffpp, &ephp->e);
- FETCH_DOUBLE(buffpp, &ephp->M0);
- FETCH_DOUBLE(buffpp, &ephp->omega);
- FETCH_DOUBLE(buffpp, &ephp->OMEGA0);
- FETCH_DOUBLE(buffpp, &ephp->OMEGADOT);
- FETCH_DOUBLE(buffpp, &ephp->deltan);
- FETCH_DOUBLE(buffpp, &ephp->i0);
- FETCH_DOUBLE(buffpp, &ephp->idot);
- FETCH_DOUBLE(buffpp, &ephp->crc);
- FETCH_DOUBLE(buffpp, &ephp->crs);
- FETCH_DOUBLE(buffpp, &ephp->cuc);
- FETCH_DOUBLE(buffpp, &ephp->cus);
- FETCH_DOUBLE(buffpp, &ephp->cic);
- FETCH_DOUBLE(buffpp, &ephp->cis);
-
- FETCH_DOUBLE(buffpp, &ephp->af0);
- FETCH_DOUBLE(buffpp, &ephp->af1);
- FETCH_DOUBLE(buffpp, &ephp->af2);
- FETCH_DOUBLE(buffpp, &ephp->tgd);
-
- ephp->URA = get_lsb_uint16(buffpp);
-
- ephp->L2code = *(*buffpp)++;
- ephp->L2flag = *(*buffpp)++;
-}
-
-void
get_mbg_alm(
unsigned char **buffpp,
ALM *almp
=====================================
tests/libntp/strtolfp.c
=====================================
--- a/tests/libntp/strtolfp.c
+++ b/tests/libntp/strtolfp.c
@@ -3,11 +3,131 @@
#include "ntp_fp.h"
#include <stdio.h>
#include <ctype.h>
+#include <string.h>
+#include "ntp_assert.h"
#include "unity.h"
#include "unity_fixture.h"
static bool mstolfp (const char *, l_fp *);
+static bool atolfp (const char *, l_fp *);
+
+/*
+ * atolfp - convert an ascii string to an l_fp number
+ */
+/*
+ * Powers of 10
+ */
+static unsigned long ten_to_the_n[10] = {
+ 0,
+ 10,
+ 100,
+ 1000,
+ 10000,
+ 100000,
+ 1000000,
+ 10000000,
+ 100000000,
+ 1000000000,
+};
+
+
+static bool
+atolfp(
+ const char *str,
+ l_fp *lfp
+ )
+{
+ register const char *cp;
+ register unsigned long dec_i;
+ register unsigned long dec_f;
+ char *ind;
+ int ndec;
+ bool isneg;
+ static const char *digits = "0123456789";
+
+ NTP_REQUIRE(str != NULL);
+
+ isneg = false;
+ dec_i = dec_f = 0;
+ ndec = 0;
+ cp = str;
+
+ /*
+ * We understand numbers of the form:
+ *
+ * [spaces][-|+][digits][.][digits][spaces|\n|\0]
+ */
+ while (isspace((unsigned char)*cp))
+ cp++;
+
+ if (*cp == '-') {
+ cp++;
+ isneg = true;
+ }
+
+ if (*cp == '+')
+ cp++;
+
+ if (*cp != '.' && !isdigit((unsigned char)*cp))
+ return false;
+
+ while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
+ dec_i = (dec_i << 3) + (dec_i << 1); /* multiply by 10 */
+ dec_i += (unsigned long)(ind - digits);
+ cp++;
+ }
+
+ if (*cp != '\0' && !isspace((unsigned char)*cp)) {
+ if (*cp++ != '.')
+ return false;
+
+ while (ndec < 9 && *cp != '\0'
+ && (ind = strchr(digits, *cp)) != NULL) {
+ ndec++;
+ dec_f = (dec_f << 3) + (dec_f << 1); /* *10 */
+ dec_f += (unsigned long)(ind - digits);
+ cp++;
+ }
+
+ while (isdigit((unsigned char)*cp))
+ cp++;
+
+ if (*cp != '\0' && !isspace((unsigned char)*cp))
+ return false;
+ }
+
+ if (ndec > 0) {
+ register unsigned long tmp;
+ register unsigned long bit;
+ register unsigned long ten_fact;
+
+ ten_fact = ten_to_the_n[ndec];
+
+ tmp = 0;
+ bit = 0x80000000;
+ while (bit != 0) {
+ dec_f <<= 1;
+ if (dec_f >= ten_fact) {
+ tmp |= bit;
+ dec_f -= ten_fact;
+ }
+ bit >>= 1;
+ }
+ if ((dec_f << 1) > ten_fact)
+ tmp++;
+ dec_f = tmp;
+ }
+
+ if (isneg)
+ {
+ (dec_f) = ~(dec_f) + 1u;
+ (dec_i) = ~(dec_i) + ((dec_f) == 0);
+ }
+
+ *lfp = lfpinit_u(dec_i, dec_f);
+ return true;
+}
/*
* mstolfp - convert an ascii string in milliseconds to an l_fp number
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/c25143342a93538fcbab825fc3aae002cec4e450...2050064186514db793e6b5bfa32dd675ba2fc8cc
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/c25143342a93538fcbab825fc3aae002cec4e450...2050064186514db793e6b5bfa32dd675ba2fc8cc
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/20170523/c6997c51/attachment.html>
More information about the vc
mailing list