From: Martin Burnicki Date: Thu, 19 Mar 2015 15:52:05 +0000 (+0100) Subject: Use predefined function types for parse driver functions used to set up function... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0557f3caa9a5630c0ee1cddf1d93b10fa418e2d;p=thirdparty%2Fntp.git Use predefined function types for parse driver functions used to set up function pointers. Account for changed prototype of parse_inp_fnc_t functions. Cast parse conversion results to appropriate types to avoid compiler warnings. Let ioctl() for Windows accept a (void *) to avoid compiler warnings when called with pointers to different types. bk: 550af0a5RYsn8g_t3WsPB9NfRklECg --- diff --git a/ChangeLog b/ChangeLog index 3587b47b7..c35f9ca8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ --- +* Use predefined function types for parse driver functions + used to set up function pointers. + Account for changed prototype of parse_inp_fnc_t functions. + Cast parse conversion results to appropriate types to avoid + compiler warnings. + Let ioctl() for Windows accept a (void *) to avoid compiler warnings + when called with pointers to different types. * [Bug 2777] Fixed loops and decoding of Meinberg GPS satellite info. Removed non-ASCII characters from some copyright comments. Removed trailing whitespace. diff --git a/include/binio.h b/include/binio.h index d1ee94429..cf9863357 100644 --- a/include/binio.h +++ b/include/binio.h @@ -42,11 +42,21 @@ void put_lsb_short (unsigned char **, long); long get_lsb_long (unsigned char **); void put_lsb_long (unsigned char **, long); +#define get_lsb_int16( _x_ ) ((int16_t) get_lsb_short( _x_ )) +#define get_lsb_uint16( _x_ ) ((uint16_t) get_lsb_short( _x_ )) +#define get_lsb_int32( _x_ ) ((int32_t) get_lsb_long( _x_ )) +#define get_lsb_uint32( _x_ ) ((uint32_t) get_lsb_long( _x_ )) + long get_msb_short (unsigned char **); void put_msb_short (unsigned char **, long); long get_msb_long (unsigned char **); void put_msb_long (unsigned char **, long); +#define get_msb_int16( _x_ ) ((int16_t) get_msb_short( _x_ )) +#define get_msb_uint16( _x_ ) ((uint16_t) get_msb_short( _x_ )) +#define get_msb_int32( _x_ ) ((int32_t) get_msb_long( _x_ )) +#define get_msb_uint32( _x_ ) ((uint32_t) get_msb_long( _x_ )) + #endif /* * History: diff --git a/include/mbg_gps166.h b/include/mbg_gps166.h index 5bd1dadbb..b9b3d7783 100644 --- a/include/mbg_gps166.h +++ b/include/mbg_gps166.h @@ -981,7 +981,7 @@ void get_mbg_eph (unsigned char **, EPH *); void get_mbg_alm (unsigned char **, ALM *); void get_mbg_iono (unsigned char **, IONO *); -unsigned long mbg_csum (unsigned char *, unsigned int); +CSUM mbg_csum (unsigned char *, unsigned int); #endif /* diff --git a/include/parse.h b/include/parse.h index 808dea749..aa0fe4787 100644 --- a/include/parse.h +++ b/include/parse.h @@ -108,8 +108,8 @@ extern unsigned int splclock (void); * some constants useful for GPS time conversion */ #define GPSORIGIN 2524953600UL /* NTP origin - GPS origin in seconds */ -#define GPSWRAP 990 /* assume week count less than this in the previous epoch */ -#define GPSWEEKS 1024 /* number of weeks until the GPS epch rolls over */ +#define GPSWRAP 990U /* assume week count less than this in the previous epoch */ +#define GPSWEEKS 1024U /* number of weeks until the GPS epch rolls over */ /* * state flags @@ -344,15 +344,19 @@ typedef struct clocktime clocktime_t; #define SYNC_ZERO 0x00 #define SYNC_ONE 0x01 +typedef u_long parse_inp_fnc_t(parse_t *, char, timestamp_t *); +typedef u_long parse_cvt_fnc_t(unsigned char *, int, struct format *, clocktime_t *, void *); +typedef u_long parse_pps_fnc_t(parse_t *, int, timestamp_t *); + struct clockformat { /* special input protocol - implies fixed format */ - u_long (*input) (parse_t *, unsigned int, timestamp_t *); + parse_inp_fnc_t *input; /* conversion routine */ - u_long (*convert) (unsigned char *, int, struct format *, clocktime_t *, void *); + parse_cvt_fnc_t *convert; /* routine for handling RS232 sync events (time stamps) */ /* PPS input routine */ - u_long (*syncpps) (parse_t *, int, timestamp_t *); + parse_pps_fnc_t *syncpps; /* time code synthesizer */ void *data; /* local parameters */ @@ -368,7 +372,7 @@ typedef struct clockformat clockformat_t; */ extern int parse_ioinit (parse_t *); extern void parse_ioend (parse_t *); -extern int parse_ioread (parse_t *, unsigned int, timestamp_t *); +extern int parse_ioread (parse_t *, char, timestamp_t *); extern int parse_iopps (parse_t *, int, timestamp_t *); extern void parse_iodone (parse_t *); extern int parse_timecode (parsectl_t *, parse_t *); @@ -376,8 +380,8 @@ extern int parse_getfmt (parsectl_t *, parse_t *); extern int parse_setfmt (parsectl_t *, parse_t *); extern int parse_setcs (parsectl_t *, parse_t *); -extern unsigned int parse_restart (parse_t *, unsigned int); -extern unsigned int parse_addchar (parse_t *, unsigned int); +extern unsigned int parse_restart (parse_t *, char); +extern unsigned int parse_addchar (parse_t *, char); extern unsigned int parse_end (parse_t *); extern int Strok (const unsigned char *, const unsigned char *); @@ -386,9 +390,9 @@ extern int Stoi (const unsigned char *, long *, int); extern time_t parse_to_unixtime (clocktime_t *, u_long *); extern u_long updatetimeinfo (parse_t *, u_long); extern void syn_simple (parse_t *, timestamp_t *, struct format *, u_long); -extern u_long pps_simple (parse_t *, int, timestamp_t *); -extern u_long pps_one (parse_t *, int, timestamp_t *); -extern u_long pps_zero (parse_t *, int, timestamp_t *); +extern parse_pps_fnc_t pps_simple; +extern parse_pps_fnc_t pps_one; +extern parse_pps_fnc_t pps_zero; extern int parse_timedout (parse_t *, timestamp_t *, struct timeval *); #endif diff --git a/libparse/clk_computime.c b/libparse/clk_computime.c index 2f7c787cb..5026232ea 100644 --- a/libparse/clk_computime.c +++ b/libparse/clk_computime.c @@ -88,10 +88,10 @@ static struct format computime_fmt = 0 }; -static u_long cvt_computime (unsigned char *, int, struct format *, clocktime_t *, void *); -static unsigned long inp_computime (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_computime; +static parse_inp_fnc_t inp_computime; -clockformat_t clock_computime = +clockformat_t clock_computime = { inp_computime, /* Computime input handling */ cvt_computime, /* Computime conversion */ @@ -103,11 +103,11 @@ clockformat_t clock_computime = }; /* - * cvt_computime + * parse_cvt_fnc_t cvt_computime * * convert simple type format */ -static u_long +static u_long cvt_computime( unsigned char *buffer, int size, @@ -144,14 +144,14 @@ cvt_computime( } /* - * inp_computime + * parse_inp_fnc_t inp_computime * - * grep data from input stream + * grab data from input stream */ static u_long inp_computime( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/clk_dcf7000.c b/libparse/clk_dcf7000.c index 6b0692da2..f1da9ef84 100644 --- a/libparse/clk_dcf7000.c +++ b/libparse/clk_dcf7000.c @@ -64,8 +64,9 @@ static struct format dcf7000_fmt = (const unsigned char *)" - - - - - - - \r", 0 }; -static u_long cvt_dcf7000 (unsigned char *, int, struct format *, clocktime_t *, void *); -static unsigned long inp_dcf7000 (parse_t *, unsigned int, timestamp_t *); + +static parse_cvt_fnc_t cvt_dcf7000; +static parse_inp_fnc_t inp_dcf7000; clockformat_t clock_dcf7000 = { @@ -79,7 +80,7 @@ clockformat_t clock_dcf7000 = }; /* - * cvt_dcf7000 + * parse_cvt_fnc_t cvt_dcf7000 * * convert dcf7000 type format */ @@ -144,14 +145,14 @@ cvt_dcf7000( } /* - * inp_dcf700 + * parse_inp_fnc_t inp_dcf700 * - * grep data from input stream + * grab data from input stream */ static u_long inp_dcf7000( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/clk_hopf6021.c b/libparse/clk_hopf6021.c index 033d2d2ca..357ac2ec0 100644 --- a/libparse/clk_hopf6021.c +++ b/libparse/clk_hopf6021.c @@ -37,10 +37,10 @@ extern int printf (const char *, ...); #endif -/* - * hopf Funkuhr 6021 +/* + * hopf Funkuhr 6021 * used with 9600,8N1, - * UTC ueber serielle Schnittstelle + * UTC ueber serielle Schnittstelle * Sekundenvorlauf ON * ETX zum Sekundenvorlauf ON * Datenstring 6021 @@ -71,7 +71,7 @@ extern int printf (const char *, ...); * x x 0 x - Wintertime * x x 1 x - Summertime * 0 0 x x - Time/Date invalid - * 0 1 x x - Internal clock used + * 0 1 x x - Internal clock used * 1 0 x x - Radio clock * 1 1 x x - Radio clock highprecision * @@ -90,10 +90,10 @@ extern int printf (const char *, ...); #define HOPF_DSTWARN 0x01 /* DST switch warning */ #define HOPF_DST 0x02 /* DST in effect */ -#define HOPF_MODE 0x0C /* operation mode mask */ +#define HOPF_MODE 0x0C /* operation mode mask */ #define HOPF_INVALID 0x00 /* no time code available */ #define HOPF_INTERNAL 0x04 /* internal clock */ -#define HOPF_RADIO 0x08 /* radio clock */ +#define HOPF_RADIO 0x08 /* radio clock */ #define HOPF_RADIOHP 0x0C /* high precision radio clock */ #define HOPF_UTC 0x08 /* time code in UTC */ @@ -102,13 +102,13 @@ extern int printf (const char *, ...); static struct format hopf6021_fmt = { { - { 9, 2 }, {11, 2}, { 13, 2}, /* Day, Month, Year */ - { 3, 2 }, { 5, 2}, { 7, 2}, /* Hour, Minute, Second */ + { 9, 2 }, {11, 2}, { 13, 2}, /* Day, Month, Year */ + { 3, 2 }, { 5, 2}, { 7, 2}, /* Hour, Minute, Second */ { 2, 1 }, { 1, 1}, { 0, 0}, /* Weekday, Flags, Zone */ /* ... */ }, (const unsigned char *)"\002 \n\r\003", - 0 + 0 }; #define OFFS(x) format->field_offsets[(x)].offset @@ -118,8 +118,8 @@ static struct format hopf6021_fmt = ('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \ -1) -static unsigned long cvt_hopf6021 (unsigned char *, int, struct format *, clocktime_t *, void *); -static unsigned long inp_hopf6021 (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_hopf6021; +static parse_inp_fnc_t inp_hopf6021; clockformat_t clock_hopf6021 = { @@ -132,7 +132,8 @@ clockformat_t clock_hopf6021 = 0 /* private data length, no private data */ }; -static unsigned long +/* parse_cvt_fnc_t cvt_hopf6021 */ +static u_long cvt_hopf6021( unsigned char *buffer, int size, @@ -162,8 +163,8 @@ cvt_hopf6021( clock_time->usecond = 0; clock_time->utcoffset = 0; - status = hexval(buffer[OFFS(O_FLAGS)]); - weekday= hexval(buffer[OFFS(O_WDAY)]); + status = (u_char) hexval(buffer[OFFS(O_FLAGS)]); + weekday= (u_char) hexval(buffer[OFFS(O_WDAY)]); if ((status == 0xFF) || (weekday == 0xFF)) { @@ -213,21 +214,21 @@ cvt_hopf6021( } /* - * inp_hopf6021 + * parse_inp_fnc_t inp_hopf6021 * - * grep data from input stream + * grab data from input stream */ static u_long inp_hopf6021( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { unsigned int rtc; - + parseprintf(DD_PARSE, ("inp_hopf6021(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); - + switch (ch) { case ETX: diff --git a/libparse/clk_meinberg.c b/libparse/clk_meinberg.c index e42677c14..4f763fdfe 100644 --- a/libparse/clk_meinberg.c +++ b/libparse/clk_meinberg.c @@ -151,19 +151,20 @@ /* Ret val: the checksum */ /*+-------------------------------------------------------------*/ -unsigned long +CSUM mbg_csum( unsigned char *p, unsigned int n ) { - unsigned long sum = 0; + unsigned int sum = 0; unsigned int i; for ( i = 0; i < n; i++ ) sum += *p++; - return( sum ); + return (CSUM) sum; + } /* csum */ void @@ -172,10 +173,10 @@ get_mbg_header( GPS_MSG_HDR *headerp ) { - headerp->cmd = get_lsb_short(bufpp); - headerp->len = get_lsb_short(bufpp); - headerp->data_csum = get_lsb_short(bufpp); - headerp->hdr_csum = get_lsb_short(bufpp); + headerp->cmd = (GPS_CMD) get_lsb_short(bufpp); + headerp->len = get_lsb_uint16(bufpp); + headerp->data_csum = (CSUM) get_lsb_short(bufpp); + headerp->hdr_csum = (CSUM) get_lsb_short(bufpp); } static struct format meinberg_fmt[] = @@ -210,10 +211,10 @@ static struct format meinberg_fmt[] = } }; -static u_long cvt_meinberg (unsigned char *, int, struct format *, clocktime_t *, void *); -static u_long cvt_mgps (unsigned char *, int, struct format *, clocktime_t *, void *); -static u_long mbg_input (parse_t *, unsigned int, timestamp_t *); -static u_long gps_input (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_meinberg; +static parse_cvt_fnc_t cvt_mgps; +static parse_inp_fnc_t mbg_input; +static parse_inp_fnc_t gps_input; struct msg_buf { @@ -258,7 +259,7 @@ clockformat_t clock_meinberg[] = }; /* - * cvt_meinberg + * parse_cvt_fnc_t cvt_meinberg * * convert simple type format */ @@ -417,14 +418,14 @@ cvt_meinberg( /* - * mbg_input + * parse_inp_fnc_t mbg_input * - * grep data from input stream + * grab data from input stream */ static u_long mbg_input( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { @@ -456,7 +457,7 @@ mbg_input( /* - * cvt_mgps + * parse_cvt_fnc_t cvt_mgps * * convert Meinberg GPS format */ @@ -581,14 +582,14 @@ cvt_mgps( } /* - * gps_input + * parse_inp_fnc_t gps_input * * grep binary data from input stream */ static u_long gps_input( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/clk_rawdcf.c b/libparse/clk_rawdcf.c index a821cc536..3c6f9198e 100644 --- a/libparse/clk_rawdcf.c +++ b/libparse/clk_rawdcf.c @@ -101,9 +101,9 @@ * 59 - usually missing (minute indication), except for leap insertion */ -static u_long pps_rawdcf (parse_t *, int, timestamp_t *); -static u_long cvt_rawdcf (unsigned char *, int, struct format *, clocktime_t *, void *); -static u_long inp_rawdcf (parse_t *, unsigned int, timestamp_t *); +static parse_pps_fnc_t pps_rawdcf; +static parse_cvt_fnc_t cvt_rawdcf; +static parse_inp_fnc_t inp_rawdcf; typedef struct last_tcode { time_t tcode; /* last converted time code */ @@ -327,6 +327,7 @@ convert_rawdcf( } /* + * parse_cvt_fnc_t cvt_rawdcf * raw dcf input routine - needs to fix up 50 baud * characters for 1/0 decision */ @@ -379,7 +380,7 @@ cvt_rawdcf( ch >>= 1; } - *s = i; + *s = (unsigned char) i; histbuf[i]++; cutoff += i; lowmax++; @@ -509,7 +510,7 @@ cvt_rawdcf( } /* - * pps_rawdcf + * parse_pps_fnc_t pps_rawdcf * * currently a very stupid version - should be extended to decode * also ones and zeros (which is easy) @@ -555,14 +556,14 @@ snt_rawdcf( } /* - * inp_rawdcf + * parse_inp_fnc_t inp_rawdcf * * grab DCF77 data from input stream */ static u_long inp_rawdcf( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/clk_rcc8000.c b/libparse/clk_rcc8000.c index 6dca1660d..a690e588b 100644 --- a/libparse/clk_rcc8000.c +++ b/libparse/clk_rcc8000.c @@ -1,6 +1,6 @@ /* * /src/NTP/ntp4-dev/libparse/clk_rcc8000.c,v 4.9 2004/11/14 15:29:41 kardel RELEASE_20050508_A - * + * * clk_rcc8000.c,v 4.9 2004/11/14 15:29:41 kardel RELEASE_20050508_A * * Radiocode Clocks Ltd RCC 8000 Intelligent Off-Air Master Clock support @@ -49,16 +49,16 @@ extern int printf (const char *, ...); #define O_USEC O_WDAY static struct format rcc8000_fmt = -{ { { 13, 2 }, {16, 2}, { 19, 2}, /* Day, Month, Year */ - { 0, 2 }, { 3, 2}, { 6, 2}, /* Hour, Minute, Second */ +{ { { 13, 2 }, {16, 2}, { 19, 2}, /* Day, Month, Year */ + { 0, 2 }, { 3, 2}, { 6, 2}, /* Hour, Minute, Second */ { 9, 3 }, {28, 1}, { 0, 0}, /* uSec, Status (Valid,Reject,BST,Leapyear) */ }, - (const unsigned char *)" : : . / / \r\n", + (const unsigned char *)" : : . / / \r\n", /*"15:50:36.534 30/09/94 273 5 A\x0d\x0a" */ - 0 + 0 }; -static unsigned long cvt_rcc8000 (unsigned char *, int, struct format *, clocktime_t *, void *); -static unsigned long inp_rcc8000 (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_rcc8000; +static parse_inp_fnc_t inp_rcc8000; clockformat_t clock_rcc8000 = { @@ -71,7 +71,8 @@ clockformat_t clock_rcc8000 = 0 /* no private data */ }; -static unsigned long +/* parse_cvt_fnc_t cvt_rcc8000 */ +static u_long cvt_rcc8000( unsigned char *buffer, int size, @@ -121,27 +122,27 @@ cvt_rcc8000( clock_time->flags |= PARSEB_POWERUP; clock_time->flags |= PARSEB_UTC; /* British special - guess why 8-) */ - + /* other flags not used */ } return CVT_OK; } /* - * inp_rcc8000 + * parse_inp_fnc_t inp_rcc8000 * - * grep data from input stream + * grab data from input stream */ static u_long inp_rcc8000( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { unsigned int rtc; - + parseprintf(DD_PARSE, ("inp_rcc8000(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); - + switch (ch) { case '\n': @@ -150,7 +151,7 @@ inp_rcc8000( return parse_end(parseio); else return rtc; - + default: if (parseio->parse_index == 0) /* take sample at start of message */ diff --git a/libparse/clk_schmid.c b/libparse/clk_schmid.c index 85320f0be..41eae2c62 100644 --- a/libparse/clk_schmid.c +++ b/libparse/clk_schmid.c @@ -89,8 +89,8 @@ extern int printf (const char *, ...); #define WS_MEST 0x04 #define WS_LEAP 0x10 -static u_long cvt_schmid (unsigned char *, int, struct format *, clocktime_t *, void *); -static unsigned long inp_schmid (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_schmid; +static parse_inp_fnc_t inp_schmid; clockformat_t clock_schmid = { @@ -103,7 +103,7 @@ clockformat_t clock_schmid = 0, /* no private data (complete messages) */ }; - +/* parse_cvt_fnc_t */ static u_long cvt_schmid( unsigned char *buffer, @@ -192,14 +192,14 @@ cvt_schmid( } /* - * inp_schmid + * parse_inp_fnc_t inp_schmid * - * grep data from input stream + * grab data from input stream */ static u_long inp_schmid( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { @@ -207,10 +207,10 @@ inp_schmid( parseprintf(DD_PARSE, ("inp_schmid(0x%lx, 0x%x, ...)\n", (long)parseio, ch)); - switch (ch) + switch ((uint8_t)ch) { case 0xFD: /* */ - parseprintf(DD_PARSE, ("mbg_input: ETX seen\n")); + parseprintf(DD_PARSE, ("inp_schmid: 0xFD seen\n")); if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP) return parse_end(parseio); else diff --git a/libparse/clk_sel240x.c b/libparse/clk_sel240x.c index a09d3478d..b1390b4ce 100644 --- a/libparse/clk_sel240x.c +++ b/libparse/clk_sel240x.c @@ -3,7 +3,7 @@ // Schweitzer Engineering Laboratories, Inc. ////////////////////////////////////////////////////////////////////////////// -// Need to have _XOPEN_SOURCE defined for time.h to give the +// Need to have _XOPEN_SOURCE defined for time.h to give the // correct strptime signature. As per feature_test_macros(7), // define this before including any header files. @@ -51,14 +51,8 @@ // a '?'. But we are only going to call it synced when we receive a ' ' ////////////////////////////////////////////////////////////////////////////// -static unsigned long inp_sel240x( parse_t *parseio, - unsigned int ch, - timestamp_t *tstamp); -static unsigned long cvt_sel240x( unsigned char *buffer, - int size, - struct format *format, - clocktime_t *clock_time, - void *local ); +static parse_inp_fnc_t inp_sel240x; +static parse_cvt_fnc_t cvt_sel240x; // Parse clock format structure describing the message above static struct format sel240x_fmt = @@ -94,7 +88,7 @@ clockformat_t clock_sel240x = ////////////////////////////////////////////////////////////////////////////// static unsigned long inp_sel240x( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { @@ -139,7 +133,7 @@ cvt_sel240x( unsigned char *buffer, { struct tm ptime; buffer++; - buffer = (unsigned char *) strptime( + buffer = (unsigned char *) strptime( (const char *)buffer, "%Y:%j:%H:%M:%S", &ptime ); if( *(buffer+1) != '\x0d' ) { diff --git a/libparse/clk_trimtaip.c b/libparse/clk_trimtaip.c index ad3c286ed..426e897be 100644 --- a/libparse/clk_trimtaip.c +++ b/libparse/clk_trimtaip.c @@ -78,8 +78,8 @@ extern int printf (const char *, ...); 0 }; -static unsigned long cvt_trimtaip (unsigned char *, int, struct format *, clocktime_t *, void *); -static unsigned long inp_trimtaip (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_trimtaip; +static parse_inp_fnc_t inp_trimtaip; clockformat_t clock_trimtaip = { @@ -92,7 +92,8 @@ clockformat_t clock_trimtaip = 0 /* no private data */ }; -static unsigned long +/* parse_cvt_fnc_t cvt_trimtaip */ +static u_long cvt_trimtaip( unsigned char *buffer, int size, @@ -141,14 +142,14 @@ cvt_trimtaip( } /* - * inp_trimtaip + * parse_inp_fnc_t inp_trimtaip * - * grep data from input stream + * grab data from input stream */ static u_long inp_trimtaip( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/clk_trimtsip.c b/libparse/clk_trimtsip.c index 7f0ec2801..6c71d7562 100644 --- a/libparse/clk_trimtsip.c +++ b/libparse/clk_trimtsip.c @@ -116,7 +116,7 @@ struct trimble #define STATUS_UNSAFE 1 /* not enough receivers for full precision */ #define STATUS_SYNC 2 /* enough information for good operation */ -static unsigned long inp_tsip (parse_t *, unsigned int, timestamp_t *); +static unsigned long inp_tsip (parse_t *, char, timestamp_t *); static unsigned long cvt_trimtsip (unsigned char *, int, struct format *, clocktime_t *, void *); struct clockformat clock_trimtsip = @@ -136,7 +136,7 @@ struct clockformat clock_trimtsip = static unsigned long inp_tsip( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { @@ -183,7 +183,7 @@ inp_tsip( /* DLE,ETX -> end of packet */ parseio->parse_data[parseio->parse_index++] = DLE; parseio->parse_data[parseio->parse_index] = ch; - parseio->parse_ldsize = parseio->parse_index+1; + parseio->parse_ldsize = (u_short) (parseio->parse_index + 1); memcpy(parseio->parse_ldata, parseio->parse_data, parseio->parse_ldsize); parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = DLE; parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch; @@ -201,12 +201,12 @@ inp_tsip( return PARSE_INP_SKIP; } -static int +static short getshort( unsigned char *p ) { - return get_msb_short(&p); + return (short) get_msb_short(&p); } /* @@ -265,8 +265,8 @@ cvt_trimtsip( clock_time->flags = PARSEB_POWERUP; return CVT_OK; } - if (week < 990) { - week += 1024; + if (week < GPSWRAP) { + week += GPSWEEKS; } /* time OK */ @@ -348,17 +348,17 @@ cvt_trimtsip( unsigned char *lbp; /* UTC correction data - derive a leap warning */ - int tls = t->t_gpsutc = getshort((unsigned char *)&mb(12)); /* current leap correction (GPS-UTC) */ - int tlsf = t->t_gpsutcleap = getshort((unsigned char *)&mb(24)); /* new leap correction */ + int tls = t->t_gpsutc = (u_short) getshort((unsigned char *)&mb(12)); /* current leap correction (GPS-UTC) */ + int tlsf = t->t_gpsutcleap = (u_short) getshort((unsigned char *)&mb(24)); /* new leap correction */ - t->t_weekleap = getshort((unsigned char *)&mb(20)); /* week no of leap correction */ - if (t->t_weekleap < 990) - t->t_weekleap += 1024; + t->t_weekleap = (u_short) getshort((unsigned char *)&mb(20)); /* week no of leap correction */ + if (t->t_weekleap < GPSWRAP) + t->t_weekleap = (u_short)(t->t_weekleap + GPSWEEKS); - t->t_dayleap = getshort((unsigned char *)&mb(22)); /* day in week of leap correction */ - t->t_week = getshort((unsigned char *)&mb(18)); /* current week no */ - if (t->t_week < 990) - t->t_week += 1024; + t->t_dayleap = (u_short) getshort((unsigned char *)&mb(22)); /* day in week of leap correction */ + t->t_week = (u_short) getshort((unsigned char *)&mb(18)); /* current week no */ + if (t->t_week < GPSWRAP) + t->t_week = (u_short)(t->t_weekleap + GPSWEEKS); lbp = (unsigned char *)&mb(14); /* last update time */ if (fetch_ieee754(&lbp, IEEE_SINGLE, &t0t, trim_offsets) != IEEE_OK) diff --git a/libparse/clk_varitext.c b/libparse/clk_varitext.c index e7098a5d5..022549e82 100644 --- a/libparse/clk_varitext.c +++ b/libparse/clk_varitext.c @@ -105,8 +105,8 @@ static struct format varitext_fmt = 0 }; -static u_long cvt_varitext (unsigned char *, int, struct format *, clocktime_t *, void *); -static u_long inp_varitext (parse_t *, unsigned int, timestamp_t *); +static parse_cvt_fnc_t cvt_varitext; +static parse_inp_fnc_t inp_varitext; struct varitext { unsigned char start_found; @@ -128,11 +128,11 @@ clockformat_t clock_varitext = }; /* - * cvt_varitext + * parse_cvt_fnc_t cvt_varitext * * convert simple type format */ -static u_long +static u_long cvt_varitext( unsigned char *buffer, int size, @@ -184,10 +184,11 @@ cvt_varitext( } } +/* parse_inp_fnc_t inp_varitext */ static u_long inp_varitext( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/clk_wharton.c b/libparse/clk_wharton.c index 17d63bbc0..a65bc5386 100644 --- a/libparse/clk_wharton.c +++ b/libparse/clk_wharton.c @@ -74,8 +74,11 @@ extern void printf (const char *, ...); * */ +static parse_cvt_fnc_t cvt_wharton_400a; +static parse_inp_fnc_t inp_wharton_400a; + /* - * cvt_wharton_400a + * parse_cvt_fnc_t cvt_wharton_400a * * convert simple type format */ @@ -121,14 +124,14 @@ cvt_wharton_400a( } /* - * inp_wharton_400a + * parse_inp_fnc_t inp_wharton_400a * - * grep data from input stream + * grab data from input stream */ static u_long inp_wharton_400a( parse_t *parseio, - unsigned int ch, + char ch, timestamp_t *tstamp ) { diff --git a/libparse/data_mbg.c b/libparse/data_mbg.c index 472a593bb..0b3808c8b 100644 --- a/libparse/data_mbg.c +++ b/libparse/data_mbg.c @@ -76,7 +76,7 @@ get_mbg_sw_rev( SW_REV *sw_revp ) { - sw_revp->code = get_lsb_short(bufpp); + sw_revp->code = get_lsb_uint16(bufpp); memcpy(sw_revp->name, *bufpp, sizeof(sw_revp->name)); *bufpp += sizeof(sw_revp->name); } @@ -87,8 +87,8 @@ get_mbg_ascii_msg( ASCII_MSG *ascii_msgp ) { - ascii_msgp->csum = get_lsb_short(bufpp); - ascii_msgp->valid = get_lsb_short(bufpp); + ascii_msgp->csum = (CSUM) get_lsb_short(bufpp); + ascii_msgp->valid = get_lsb_int16(bufpp); memcpy(ascii_msgp->s, *bufpp, sizeof(ascii_msgp->s)); *bufpp += sizeof(ascii_msgp->s); } @@ -99,7 +99,7 @@ get_mbg_svno( SVNO *svnop ) { - *svnop = get_lsb_short(bufpp); + *svnop = (SVNO) get_lsb_short(bufpp); } void @@ -108,7 +108,7 @@ get_mbg_health( HEALTH *healthp ) { - *healthp = get_lsb_short(bufpp); + *healthp = (HEALTH) get_lsb_short(bufpp); } void @@ -117,7 +117,7 @@ get_mbg_cfg( CFG *cfgp ) { - *cfgp = get_lsb_short(bufpp); + *cfgp = (CFG) get_lsb_short(bufpp); } void @@ -126,7 +126,7 @@ get_mbg_tgps( T_GPS *tgpsp ) { - tgpsp->wn = get_lsb_short(bufpp); + tgpsp->wn = get_lsb_uint16(bufpp); tgpsp->sec = get_lsb_long(bufpp); tgpsp->tick = get_lsb_long(bufpp); } @@ -137,17 +137,17 @@ get_mbg_tm( TM_GPS *tmp ) { - tmp->year = get_lsb_short(buffpp); + tmp->year = get_lsb_int16(buffpp); tmp->month = *(*buffpp)++; tmp->mday = *(*buffpp)++; - tmp->yday = get_lsb_short(buffpp); + tmp->yday = get_lsb_int16(buffpp); tmp->wday = *(*buffpp)++; tmp->hour = *(*buffpp)++; tmp->min = *(*buffpp)++; tmp->sec = *(*buffpp)++; tmp->frac = get_lsb_long(buffpp); tmp->offs_from_utc = get_lsb_long(buffpp); - tmp->status= get_lsb_short(buffpp); + tmp->status = get_lsb_uint16(buffpp); } void @@ -156,7 +156,7 @@ get_mbg_ttm( TTM *ttmp ) { - ttmp->channel = get_lsb_short(buffpp); + ttmp->channel = get_lsb_int16(buffpp); get_mbg_tgps(buffpp, &ttmp->t); get_mbg_tm(buffpp, &ttmp->tm); } @@ -167,9 +167,9 @@ get_mbg_synth( SYNTH *synthp ) { - synthp->freq = get_lsb_short(buffpp); - synthp->range = get_lsb_short(buffpp); - synthp->phase = get_lsb_short(buffpp); + synthp->freq = get_lsb_int16(buffpp); + synthp->range = get_lsb_int16(buffpp); + synthp->phase = get_lsb_int16(buffpp); } static void @@ -202,7 +202,7 @@ get_mbg_antinfo( ANT_INFO *antinfop ) { - antinfop->status = get_lsb_short(buffpp); + antinfop->status = get_lsb_int16(buffpp); get_mbg_tm(buffpp, &antinfop->tm_disconn); get_mbg_tm(buffpp, &antinfop->tm_reconn); antinfop->delta_t = get_lsb_long(buffpp); @@ -297,8 +297,8 @@ get_mbg_cfgh( { int i; - cfghp->csum = get_lsb_short(buffpp); - cfghp->valid = get_lsb_short(buffpp); + cfghp->csum = (CSUM) get_lsb_short(buffpp); + cfghp->valid = get_lsb_int16(buffpp); get_mbg_tgps(buffpp, &cfghp->tot_51); get_mbg_tgps(buffpp, &cfghp->tot_63); get_mbg_tgps(buffpp, &cfghp->t0a); @@ -320,8 +320,8 @@ get_mbg_utc( UTC *utcp ) { - utcp->csum = get_lsb_short(buffpp); - utcp->valid = get_lsb_short(buffpp); + utcp->csum = (CSUM) get_lsb_short(buffpp); + utcp->valid = get_lsb_int16(buffpp); get_mbg_tgps(buffpp, &utcp->t0t); @@ -335,8 +335,8 @@ get_mbg_utc( L_CLR(&utcp->A1); } - utcp->WNlsf = get_lsb_short(buffpp); - utcp->DNt = get_lsb_short(buffpp); + utcp->WNlsf = get_lsb_uint16(buffpp); + utcp->DNt = get_lsb_int16(buffpp); utcp->delta_tls = *(*buffpp)++; utcp->delta_tlsf = *(*buffpp)++; } @@ -393,7 +393,7 @@ get_mbg_comparam( { comparamp->framing[i] = *(*buffpp)++; } - comparamp->handshake = get_lsb_short(buffpp); + comparamp->handshake = get_lsb_int16(buffpp); } void @@ -426,13 +426,13 @@ get_mbg_eph( EPH *ephp ) { - ephp->csum = get_lsb_short(buffpp); - ephp->valid = get_lsb_short(buffpp); + ephp->csum = (CSUM) get_lsb_short(buffpp); + ephp->valid = get_lsb_int16(buffpp); - ephp->health = get_lsb_short(buffpp); - ephp->IODC = get_lsb_short(buffpp); - ephp->IODE2 = get_lsb_short(buffpp); - ephp->IODE3 = get_lsb_short(buffpp); + ephp->health = (HEALTH) get_lsb_short(buffpp); + ephp->IODC = (IOD) get_lsb_short(buffpp); + ephp->IODE2 = (IOD) get_lsb_short(buffpp); + ephp->IODE3 = (IOD) get_lsb_short(buffpp); get_mbg_tgps(buffpp, &ephp->tt); get_mbg_tgps(buffpp, &ephp->t0c); @@ -459,7 +459,7 @@ get_mbg_eph( FETCH_DOUBLE(buffpp, &ephp->af2); FETCH_DOUBLE(buffpp, &ephp->tgd); - ephp->URA = get_lsb_short(buffpp); + ephp->URA = get_lsb_uint16(buffpp); ephp->L2code = *(*buffpp)++; ephp->L2flag = *(*buffpp)++; @@ -471,10 +471,10 @@ get_mbg_alm( ALM *almp ) { - almp->csum = get_lsb_short(buffpp); - almp->valid = get_lsb_short(buffpp); + almp->csum = (CSUM) get_lsb_short(buffpp); + almp->valid = get_lsb_int16(buffpp); - almp->health = get_lsb_short(buffpp); + almp->health = (HEALTH) get_lsb_short(buffpp); get_mbg_tgps(buffpp, &almp->t0a); @@ -496,8 +496,8 @@ get_mbg_iono( IONO *ionop ) { - ionop->csum = get_lsb_short(buffpp); - ionop->valid = get_lsb_short(buffpp); + ionop->csum = (CSUM) get_lsb_short(buffpp); + ionop->valid = get_lsb_int16(buffpp); FETCH_DOUBLE(buffpp, &ionop->alpha_0); FETCH_DOUBLE(buffpp, &ionop->alpha_1); diff --git a/libparse/gpstolfp.c b/libparse/gpstolfp.c index f26c8cf4d..c162429ed 100644 --- a/libparse/gpstolfp.c +++ b/libparse/gpstolfp.c @@ -50,7 +50,7 @@ gpstolfp( weeks += GPSWEEKS; } - lfp->l_ui = weeks * SECSPERWEEK + days * SECSPERDAY + seconds + GPSORIGIN; /* convert to NTP time */ + lfp->l_ui = (uint32_t)(weeks * SECSPERWEEK + days * SECSPERDAY + seconds + GPSORIGIN); /* convert to NTP time */ lfp->l_uf = 0; } diff --git a/libparse/parse.c b/libparse/parse.c index 4b8bc20d9..50781796c 100644 --- a/libparse/parse.c +++ b/libparse/parse.c @@ -188,7 +188,7 @@ parse_ioend( unsigned int parse_restart( parse_t *parseio, - unsigned int ch + char ch ) { unsigned int updated = PARSE_INP_SKIP; @@ -218,7 +218,7 @@ parse_restart( unsigned int parse_addchar( parse_t *parseio, - unsigned int ch + char ch ) { /* @@ -260,11 +260,11 @@ parse_end( int parse_ioread( register parse_t *parseio, - register unsigned int ch, + register char ch, register timestamp_t *tstamp ) { - register unsigned updated = CVT_NONE; + register u_int updated = CVT_NONE; /* * within STREAMS CSx (x < 8) chars still have the upper bits set * so we normalize the characters by masking unecessary bits off. @@ -284,7 +284,7 @@ parse_ioread( break; case PARSE_IO_CS8: - ch &= 0xFF; + ch &= (char) 0xFF; break; } @@ -309,7 +309,7 @@ parse_ioread( if (input_status & PARSE_INP_TIME) /* time sample is available */ { - updated = timepacket(parseio); + updated = (u_int) timepacket(parseio); } if (input_status & PARSE_INP_DATA) /* got additional data */ @@ -353,7 +353,7 @@ parse_iopps( register timestamp_t *ptime ) { - register unsigned updated = CVT_NONE; + register u_int updated = CVT_NONE; /* * PPS pulse information will only be delivered to ONE clock format @@ -364,7 +364,7 @@ parse_iopps( if (clockformats[parseio->parse_lformat]->syncpps) { - updated = clockformats[parseio->parse_lformat]->syncpps(parseio, status == SYNC_ONE, ptime); + updated = (u_int) clockformats[parseio->parse_lformat]->syncpps(parseio, status == SYNC_ONE, ptime); parseprintf(DD_PARSE, ("parse_iopps: updated = 0x%x\n", updated)); } @@ -614,7 +614,7 @@ syn_simple( } /* - * pps_simple + * parse_pps_fnc_t pps_simple * * handle a pps time stamp */ @@ -633,7 +633,7 @@ pps_simple( } /* - * pps_one + * parse_pps_fnc_t pps_one * * handle a pps time stamp in ONE edge */ @@ -652,7 +652,7 @@ pps_one( } /* - * pps_zero + * parse_pps_fnc_t pps_zero * * handle a pps time stamp in ZERO edge */ @@ -732,7 +732,7 @@ timepacket( parseio->parse_dtime.parse_time.tv.tv_sec = t; parseio->parse_dtime.parse_time.tv.tv_usec = clock_time.usecond; #else - parseio->parse_dtime.parse_time.fp.l_ui = t + JAN_1970; + parseio->parse_dtime.parse_time.fp.l_ui = (uint32_t) (t + JAN_1970); TVUTOTSF(clock_time.usecond, parseio->parse_dtime.parse_time.fp.l_uf); #endif @@ -852,7 +852,7 @@ parse_getfmt( if (dct->parseformat.parse_format < nformats && Strlen(clockformats[dct->parseformat.parse_format]->name) <= PARSE_TCMAX) { - dct->parseformat.parse_count = Strlen(clockformats[dct->parseformat.parse_format]->name)+1; + dct->parseformat.parse_count = (unsigned short) (Strlen(clockformats[dct->parseformat.parse_format]->name) + 1); memcpy(dct->parseformat.parse_buffer, clockformats[dct->parseformat.parse_format]->name, dct->parseformat.parse_count); return 1; } @@ -870,7 +870,7 @@ parse_setcs( ) { parse->parse_ioflags &= ~PARSE_IO_CSIZE; - parse->parse_ioflags |= dct->parsesetcs.parse_cs & PARSE_IO_CSIZE; + parse->parse_ioflags |= (int) (dct->parsesetcs.parse_cs & PARSE_IO_CSIZE); return 1; } diff --git a/ntpd/refclock_parse.c b/ntpd/refclock_parse.c index 01827907f..3117332ac 100644 --- a/ntpd/refclock_parse.c +++ b/ntpd/refclock_parse.c @@ -158,8 +158,8 @@ # endif #endif -#define BUFFER_SIZE(_BUF, _PTR) ((_BUF) + sizeof(_BUF) - (_PTR)) -#define BUFFER_SIZES(_BUF, _PTR, _SZ) ((_BUF) + (_SZ) - (_PTR)) +# define BUFFER_SIZE(_BUF, _PTR) ((int)((_BUF) + sizeof(_BUF) - (_PTR))) +# define BUFFER_SIZES(_BUF, _PTR, _SZ) ((int)((_BUF) + (_SZ) - (_PTR))) /* * document type of PPS interfacing - copy of ifdef mechanism in local_input() @@ -2246,9 +2246,9 @@ local_input( else pts = pps_info.assert_timestamp; - parse->parseio.parse_dtime.parse_ptime.fp.l_ui = pts.tv_sec + JAN_1970; + parse->parseio.parse_dtime.parse_ptime.fp.l_ui = (uint32_t) (pts.tv_sec + JAN_1970); - dtemp = pts.tv_nsec / 1e9; + dtemp = (double) pts.tv_nsec / 1e9; if (dtemp < 0.) { dtemp += 1; parse->parseio.parse_dtime.parse_ptime.fp.l_ui--; @@ -2257,9 +2257,9 @@ local_input( dtemp -= 1; parse->parseio.parse_dtime.parse_ptime.fp.l_ui++; } - parse->parseio.parse_dtime.parse_ptime.fp.l_uf = dtemp * FRAC; + parse->parseio.parse_dtime.parse_ptime.fp.l_uf = (uint32_t)(dtemp * FRAC); - parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS; + parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS; #ifdef DEBUG if (debug > 3) { @@ -2899,7 +2899,7 @@ parse_ppsapi( int cap, mode_ppsoffset; const char *cp; - parse->flags &= ~PARSE_PPSCLOCK; + parse->flags &= (u_char) (~PARSE_PPSCLOCK); /* * collect PPSAPI offset capability - should move into generic handling @@ -2941,16 +2941,16 @@ parse_ppsapi( CLK_UNIT(parse->peer), cp, cap); mode_ppsoffset = 0; } else { - if (mode_ppsoffset == PPS_OFFSETCLEAR) - { - parse->atom.pps_params.clear_offset.tv_sec = -parse->ppsphaseadjust; - parse->atom.pps_params.clear_offset.tv_nsec = -1e9*(parse->ppsphaseadjust - (long)parse->ppsphaseadjust); + if (mode_ppsoffset == PPS_OFFSETCLEAR) + { + parse->atom.pps_params.clear_offset.tv_sec = (time_t)(-parse->ppsphaseadjust); + parse->atom.pps_params.clear_offset.tv_nsec = (long)(-1e9*(parse->ppsphaseadjust - (double)(long)parse->ppsphaseadjust)); } if (mode_ppsoffset == PPS_OFFSETASSERT) - { - parse->atom.pps_params.assert_offset.tv_sec = -parse->ppsphaseadjust; - parse->atom.pps_params.assert_offset.tv_nsec = -1e9*(parse->ppsphaseadjust - (long)parse->ppsphaseadjust); + { + parse->atom.pps_params.assert_offset.tv_sec = (time_t)(-parse->ppsphaseadjust); + parse->atom.pps_params.assert_offset.tv_nsec = (long)(-1e9*(parse->ppsphaseadjust - (double)(long)parse->ppsphaseadjust)); } } @@ -3124,15 +3124,15 @@ parse_start( } #endif - tio.c_cflag = parse_clockinfo[type].cl_cflag; - tio.c_iflag = parse_clockinfo[type].cl_iflag; - tio.c_oflag = parse_clockinfo[type].cl_oflag; - tio.c_lflag = parse_clockinfo[type].cl_lflag; + tio.c_cflag = (tcflag_t) parse_clockinfo[type].cl_cflag; + tio.c_iflag = (tcflag_t) parse_clockinfo[type].cl_iflag; + tio.c_oflag = (tcflag_t) parse_clockinfo[type].cl_oflag; + tio.c_lflag = (tcflag_t) parse_clockinfo[type].cl_lflag; #ifdef HAVE_TERMIOS - if ((cfsetospeed(&tio, parse_clockinfo[type].cl_speed) == -1) || - (cfsetispeed(&tio, parse_clockinfo[type].cl_speed) == -1)) + if ((cfsetospeed(&tio, (speed_t) parse_clockinfo[type].cl_speed) == -1) || + (cfsetispeed(&tio, (speed_t) parse_clockinfo[type].cl_speed) == -1)) { msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcset{i,o}speed(&tio, speed): %m", unit); parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */ @@ -3279,7 +3279,7 @@ parse_start( } strlcpy(tmp_ctl.parseformat.parse_buffer, parse->parse_type->cl_format, sizeof(tmp_ctl.parseformat.parse_buffer)); - tmp_ctl.parseformat.parse_count = strlen(tmp_ctl.parseformat.parse_buffer); + tmp_ctl.parseformat.parse_count = (u_short) strlen(tmp_ctl.parseformat.parse_buffer); if (!PARSE_SETFMT(parse, &tmp_ctl)) { @@ -3379,8 +3379,8 @@ parse_ctl( { if (in->haveflags & (CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4)) { - parse->flags = (parse->flags & ~(CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4)) | - (in->flags & (CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4)); + u_char mask = CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4; + parse->flags = (parse->flags & (u_char)(~mask)) | (in->flags & mask); #if defined(HAVE_PPSAPI) if (CLK_PPS(parse->peer)) { @@ -3663,7 +3663,7 @@ parse_control( clockstatus((unsigned int)i), l_mktime(s_time), (int)(percent / 100), (int)(percent % 100)); - if ((count = strlen(item)) < (LEN_STATES - 40 - (tt - start))) + if ((count = (int) strlen(item)) < (LEN_STATES - 40 - (tt - start))) { tt = ap(start, LEN_STATES, tt, "%s", item); @@ -3695,7 +3695,7 @@ parse_control( } } - out->lencode = strlen(outstatus); + out->lencode = (u_short) strlen(outstatus); out->p_lastcode = outstatus; } } @@ -4349,7 +4349,7 @@ gps16x_message( char buffer[512]; char *p, *b; - status = get_lsb_short(&bufp); + status = (BVAR_STAT) get_lsb_short(&bufp); p = b = buffer; p = ap(buffer, sizeof(buffer), p, "meinberg_gps_status=\"[0x%04x] ", @@ -4631,7 +4631,8 @@ gps16x_message( } else { - msyslog(LOG_DEBUG, "PARSE receiver #%d: gps16x_message: message checksum error: hdr_csum = 0x%x (expected 0x%lx), data_len = %d, data_csum = 0x%x (expected 0x%lx)", + msyslog(LOG_DEBUG, "PARSE receiver #%d: gps16x_message: message checksum error: hdr_csum = 0x%x (expected 0x%x), " + "data_len = %d, data_csum = 0x%x (expected 0x%x)", CLK_UNIT(parse->peer), header.hdr_csum, mbg_csum(parsetime->parse_msg + 1, 6), header.len, @@ -4702,7 +4703,7 @@ gps16x_poll( } #endif - rtc = write(parse->generic->io.fd, cmd_buffer, (unsigned long)(outp - cmd_buffer)); + rtc = (int) write(parse->generic->io.fd, cmd_buffer, (unsigned long)(outp - cmd_buffer)); if (rtc < 0) { @@ -4765,11 +4766,11 @@ poll_dpoll( struct parseunit *parse ) { - int rtc; + long rtc; const char *ps = ((poll_info_t *)parse->parse_type->cl_data)->string; - int ct = ((poll_info_t *)parse->parse_type->cl_data)->count; + long ct = ((poll_info_t *)parse->parse_type->cl_data)->count; - rtc = write(parse->generic->io.fd, ps, (unsigned long)ct); + rtc = write(parse->generic->io.fd, ps, ct); if (rtc < 0) { ERR(ERR_BADIO) @@ -4779,7 +4780,7 @@ poll_dpoll( if (rtc != ct) { ERR(ERR_BADIO) - msyslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%d of %d bytes sent)", CLK_UNIT(parse->peer), rtc, ct); + msyslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%ld of %ld bytes sent)", CLK_UNIT(parse->peer), rtc, ct); } clear_err(parse, ERR_BADIO); } @@ -4885,7 +4886,7 @@ trimbletaip_event( iv = taipinit; while (*iv) { - int rtc = write(parse->generic->io.fd, *iv, strlen(*iv)); + int rtc = (int) write(parse->generic->io.fd, *iv, strlen(*iv)); if (rtc < 0) { msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_event: failed to send cmd to clock: %m", CLK_UNIT(parse->peer)); @@ -5105,7 +5106,7 @@ sendflt( int i; union uval uval; - uval.fv = a; + uval.fv = (float) a; #ifdef WORDS_BIGENDIAN for (i=0; i<=3; i++) #else @@ -5399,7 +5400,7 @@ getshort( unsigned char *p ) { - return get_msb_short(&p); + return (int) get_msb_short(&p); } /*-------------------------------------------------- @@ -5438,7 +5439,7 @@ trimbletsip_message( } else { - int var_flag; + u_short var_flag; trimble_t *tr = parse->localdata; unsigned int cmd = buffer[1]; char pbuffer[200]; @@ -5473,7 +5474,7 @@ trimbletsip_message( return; } - var_flag = s->varmode; + var_flag = (u_short) s->varmode; switch(cmd) { @@ -5622,11 +5623,11 @@ trimbletsip_message( case CMD_RUTCPARAM: { float t0t = getflt((unsigned char *)&mb(14)); - short wnt = getshort((unsigned char *)&mb(18)); - short dtls = getshort((unsigned char *)&mb(12)); - short wnlsf = getshort((unsigned char *)&mb(20)); - short dn = getshort((unsigned char *)&mb(22)); - short dtlsf = getshort((unsigned char *)&mb(24)); + short wnt = (short) getshort((unsigned char *)&mb(18)); + short dtls = (short) getshort((unsigned char *)&mb(12)); + short wnlsf = (short) getshort((unsigned char *)&mb(20)); + short dn = (short) getshort((unsigned char *)&mb(22)); + short dtlsf = (short) getshort((unsigned char *)&mb(24)); if ((int)t0t != 0) { @@ -5762,7 +5763,7 @@ trimbletsip_message( if (getflt((unsigned char *)&mb(4)) < 0.0) { t = ap(pbuffer, sizeof(pbuffer), t, ""); - var_flag &= ~DEF; + var_flag &= (u_short)(~DEF); } else { @@ -5775,7 +5776,7 @@ trimbletsip_message( getflt((unsigned char *)&mb(16)) * RTOD); if (mb(20)) { - var_flag &= ~DEF; + var_flag &= (u_short)(~DEF); t = ap(pbuffer, sizeof(pbuffer), t, ", OLD"); } if (mb(22)) @@ -5797,7 +5798,7 @@ trimbletsip_message( break; } - t = ap(pbuffer, sizeof(pbuffer), t,"\""); + t = ap(pbuffer, sizeof(pbuffer), t, "\""); set_var(&parse->kv, pbuffer, sizeof(pbuffer), var_flag); } } diff --git a/ports/winnt/include/termios.h b/ports/winnt/include/termios.h index 9c1cc625c..94331afca 100644 --- a/ports/winnt/include/termios.h +++ b/ports/winnt/include/termios.h @@ -205,7 +205,7 @@ struct termios #define cfsetispeed(dcb, spd) (0) extern int closeserial (int); -extern int ioctl (int, int, int *); +extern int ioctl (int, int, void *); extern int tcsetattr (int, int, const struct termios *); extern int tcgetattr (int, struct termios *); extern int tcflush (int, int); diff --git a/ports/winnt/libntp/termios.c b/ports/winnt/libntp/termios.c index 3fe4e4859..5ac017dcd 100644 --- a/ports/winnt/libntp/termios.c +++ b/ports/winnt/libntp/termios.c @@ -468,12 +468,13 @@ int ioctl( int fd, int op, - int *pi + void *pv ) { HANDLE h; int result; int modctl; + int *pi = (int *) pv; h = (HANDLE)_get_osfhandle(fd);