Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9f754f8
Add forward declaration of yyparse()
he32 Nov 30, 2015
d360955
Fix a signedness comparison by adding a cast to size_t
he32 Nov 30, 2015
b969a5f
For type compatibility, make "i" a size_t
he32 Nov 30, 2015
48d5915
Fix a signedness comparison by adding a cast
he32 Nov 30, 2015
2af172a
Reshuffle to use a literal format string, and one signedness fix
he32 Nov 30, 2015
e4fc851
Fixes for const, signedness and prototypes
he32 Nov 30, 2015
2590a8f
Avoid signedness comparison warnings
he32 Nov 30, 2015
b7ec42a
Avoid a signed/unsigned comparison warning by adding a cast
he32 Nov 30, 2015
9915c5b
Signedness fixes, use literal format, fix islower() usage
he32 Nov 30, 2015
ccbdf6e
Add some constness
he32 Nov 30, 2015
63de1c0
Remove some un-needed casts, add one const qualification
he32 Nov 30, 2015
2a1afb4
Use VOIDP instead of a (char*) cast
he32 Nov 30, 2015
d699c14
Use VOIDP(), remove one useless cast
he32 Nov 30, 2015
abb0c98
Remove a useless cast
he32 Nov 30, 2015
255ff0a
Add casts for args to tolower / toupper for safe value range
he32 Nov 30, 2015
921f53a
Avoid casting away constness by using a helper variable
he32 Nov 30, 2015
089cfa8
Avoid casts inside the strtoul and strtol wrappers
he32 Nov 30, 2015
a1724ef
Remove needless cast, pzArg has right type already
he32 Nov 30, 2015
4495b55
Use VOIDP() instead of cast via (void**)
he32 Nov 30, 2015
1dde023
Add a required const qualification
he32 Nov 30, 2015
3377059
Make "week" unsigned
he32 Nov 30, 2015
a62aa38
Avoid signed/unsigned comparison by using a helper variable
he32 Nov 30, 2015
ccadc29
Fix indentation
he32 Nov 30, 2015
e1402a5
Fix indentation
he32 Nov 30, 2015
740213a
Actually, no need to cast args to strncmp()
he32 Nov 30, 2015
3bc1fa1
Fix missing * in declaration (human copy/paste error)
he32 Nov 30, 2015
bfd9007
Replace casts to void** with use of VOIDP()
he32 Nov 30, 2015
4361be2
Make a loop counter unsigned to avoid warning
he32 Nov 30, 2015
874210b
Make a loop counter unsigned to avoid -Wstrict-overflow warning
he32 Nov 30, 2015
b1962ce
Typo correction
he32 Nov 30, 2015
6622a6a
Another cast for arg to iscntrl()
he32 Nov 30, 2015
495ea4c
Avoid -Wstrict-overflow warning by converting a var to u_int
he32 Nov 30, 2015
1ee4072
Fix memory allocation to fit string, but still use a literal format
he32 Dec 1, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libparse/clk_trimtsip.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ cvt_trimtsip(
case CMD_RCURTIME:
{ /* GPS time */
l_fp secs;
int week = getshort((unsigned char *)&mb(4));
unsigned int week = getshort((unsigned char *)&mb(4));
l_fp utcoffset;
l_fp gpstime;

Expand Down
3 changes: 2 additions & 1 deletion libparse/gpstolfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@

void
gpstolfp(
int weeks,
int sweeks,
int days,
unsigned long seconds,
l_fp * lfp
)
{
unsigned int weeks = sweeks;
if (weeks < GPSWRAP)
{
weeks += GPSWEEKS;
Expand Down
2 changes: 2 additions & 0 deletions ntpd/ntp_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#include "ntp_parser.h"
#include "ntpd-opts.h"

int yyparse(void);

/* Bug 2817 */
#if defined(HAVE_SYS_MMAN_H)
# include <sys/mman.h>
Expand Down
2 changes: 1 addition & 1 deletion ntpd/ntp_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ read_refclock_packet(
/* TALOS-CAN-0064: avoid signed/unsigned clashes that can lead
* to buffer overrun and memory corruption
*/
if (rp->datalen <= 0 || rp->datalen > sizeof(rb->recv_space))
if (rp->datalen <= 0 || (size_t)rp->datalen > sizeof(rb->recv_space))
read_count = sizeof(rb->recv_space);
else
read_count = (u_int)rp->datalen;
Expand Down
7 changes: 4 additions & 3 deletions ntpd/ntp_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,7 @@ clock_select(void)
{
struct peer *peer;
int i, j, k, n;
u_int l;
int nlist, nl2;
int allow;
int speer;
Expand Down Expand Up @@ -2831,10 +2832,10 @@ clock_select(void)
/*
* Mark the candidates at this point as truechimers.
*/
for (i = 0; i < nlist; i++) {
peers[i].peer->new_status = CTL_PST_SEL_SELCAND;
for (l = 0; l < nlist; l++) {
peers[l].peer->new_status = CTL_PST_SEL_SELCAND;
DPRINTF(2, ("select: survivor %s %f\n",
stoa(&peers[i].peer->srcadr), peers[i].synch));
stoa(&peers[l].peer->srcadr), peers[l].synch));
}

/*
Expand Down
2 changes: 1 addition & 1 deletion ntpd/ntp_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ int
yylex(void)
{
static follby followedby = FOLLBY_TOKEN;
int i;
size_t i;
int instring;
int yylval_was_set;
int converted;
Expand Down
2 changes: 1 addition & 1 deletion ntpd/ntp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ check_leapsec(
sys_tai = lsdata.tai_offs;
} else {
#ifdef AUTOKEY
update_autokey = (sys_tai != lsdata.tai_offs);
update_autokey = (sys_tai != (u_int)lsdata.tai_offs);
#endif
lsprox = lsdata.proximity;
sys_tai = lsdata.tai_offs;
Expand Down
9 changes: 5 additions & 4 deletions ntpd/refclock_chu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ chu_a(
int val; /* distance */
int temp;
int i, j, k;
u_int l;

pp = peer->procptr;
up = pp->unitptr;
Expand Down Expand Up @@ -1259,13 +1260,13 @@ chu_a(
up->second = pp->second = 30 + temp;
offset.l_ui = 30 + temp;
offset.l_uf = 0;
i = 0;
l = 0;
if (k < 0)
offset = up->charstamp;
else if (k > 0)
i = 1;
for (; i < nchar && i < k + 10; i++) {
up->tstamp[up->ntstamp] = up->cstamp[i];
l = 1;
for (; l < nchar && l < k + 10; l++) {
up->tstamp[up->ntstamp] = up->cstamp[l];
L_SUB(&up->tstamp[up->ntstamp], &offset);
L_ADD(&offset, &up->charstamp);
if (up->ntstamp < MAXSTAGE - 1)
Expand Down
27 changes: 12 additions & 15 deletions ntpd/refclock_gpsdjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,6 @@ static int16_t clamped_precision(int rawprec);
* local / static stuff
*/

/* The logon string is actually the ?WATCH command of GPSD, using JSON
* data and selecting the GPS device name we created from our unit
* number. We have an old a newer version that request PPS (and TOFF)
* transmission.
* Note: These are actually format strings!
*/
static const char * const s_req_watch[2] = {
"?WATCH={\"device\":\"%s\",\"enable\":true,\"json\":true};\r\n",
"?WATCH={\"device\":\"%s\",\"enable\":true,\"json\":true,\"pps\":true};\r\n"
};

static const char * const s_req_version =
"?VERSION;\r\n";

Expand Down Expand Up @@ -1145,9 +1134,11 @@ strtojint(
static tok_ref
json_token_skip(
const json_ctx * ctx,
tok_ref tid)
tok_ref stid)
{
if (tid >= 0 && tid < ctx->ntok) {
u_int tid = stid;

if (tid < ctx->ntok) {
int len = ctx->tok[tid].size;
/* For arrays and objects, the size is the number of
* ITEMS in the compound. Thats the number of objects in
Expand Down Expand Up @@ -1200,7 +1191,7 @@ json_object_lookup(
tid = json_token_skip(ctx, tid); /* skip val */
} else if (strcmp(key, ctx->buf + ctx->tok[tid].start)) {
tid = json_token_skip(ctx, tid+1); /* skip key+val */
} else if (what < 0 || what == ctx->tok[tid+1].type) {
} else if (what < 0 || (unsigned)what == ctx->tok[tid+1].type) {
return tid + 1;
} else {
break;
Expand Down Expand Up @@ -1513,8 +1504,14 @@ process_version(
if (up->fl_watch)
return;

/* The logon string is actually the ?WATCH command of GPSD, using JSON
* data and selecting the GPS device name we created from our unit
* number. We have an old a newer version that request PPS (and TOFF)
* transmission.
*/
snprintf(up->buffer, sizeof(up->buffer),
s_req_watch[up->pf_toff != 0], up->device);
"?WATCH={\"device\":\"%s\",\"enable\":true,\"json\":true%s};\r\n",
up->device, up->pf_toff ? ",\"pps\":true" : "");
buf = up->buffer;
len = strlen(buf);
log_data(peer, "send", buf, len);
Expand Down
40 changes: 21 additions & 19 deletions ntpd/refclock_jjy.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
*/

struct jjyRawDataBreak {
char *pString ;
const char *pString ;
int iLength ;
} ;

Expand Down Expand Up @@ -588,7 +588,7 @@ jjy_receive ( struct recvbuf *rbufp )
l_fp tRecvTimestamp; /* arrival timestamp */
int rc ;
char *pBuf, sLogText [ MAX_LOGTEXT ] ;
int iLen, iCopyLen ;
size_t iLen, iCopyLen ;
int i, j, iReadRawBuf, iBreakPosition ;

/*
Expand Down Expand Up @@ -627,7 +627,7 @@ jjy_receive ( struct recvbuf *rbufp )
#ifdef DEBUG
printf( "\nrefclock_jjy.c : %s : Len=%d ", sFunctionName, pp->lencode ) ;
for ( i = 0 ; i < pp->lencode ; i ++ ) {
if ( iscntrl( pp->a_lastcode[i] & 0x7F ) ) {
if ( iscntrl( (unsigned char)pp->a_lastcode[i] & 0x7F ) ) {
printf( "<x%02X>", pp->a_lastcode[i] & 0xFF ) ;
} else {
printf( "%c", pp->a_lastcode[i] ) ;
Expand Down Expand Up @@ -702,7 +702,7 @@ jjy_receive ( struct recvbuf *rbufp )
up->iLineBufLen ++ ;

/* Copy printable characters */
if ( ! iscntrl( up->sRawBuf[i] ) ) {
if ( ! iscntrl( (unsigned char)up->sRawBuf[i] ) ) {
up->sTextBuf[up->iTextBufLen] = up->sRawBuf[i] ;
up->iTextBufLen ++ ;
}
Expand Down Expand Up @@ -2576,7 +2576,7 @@ static int teljjy_bye_ignore ( struct peer *peer, struct refclockproc *, struct
static int teljjy_bye_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ;
static int teljjy_bye_modem ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ;

static int ( *pTeljjyHandler [ ] [ 5 ] ) ( ) =
static int ( *pTeljjyHandler [ ] [ 5 ] ) ( struct peer *, struct refclockproc *, struct jjyunit *) =
{ /*STATE_IDLE STATE_DAILOUT STATE_LOGIN STATE_CONNECT STATE_BYE */
/* NULL */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore },
/* START */ { teljjy_idle_dialout, teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore },
Expand Down Expand Up @@ -2682,8 +2682,9 @@ jjy_start_telephone ( int unit, struct peer *peer, struct jjyunit *up )
{

char sLog [ 80 ], sFirstThreeDigits [ 4 ] ;
int i, iNumberOfDigitsOfPhoneNumber, iCommaCount, iCommaPosition ;
int iFirstThreeDigitsCount ;
int iNumberOfDigitsOfPhoneNumber, iCommaCount, iCommaPosition ;
size_t i ;
size_t iFirstThreeDigitsCount ;

jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: Telephone JJY" ) ;

Expand Down Expand Up @@ -2715,7 +2716,7 @@ jjy_start_telephone ( int unit, struct peer *peer, struct jjyunit *up )

iNumberOfDigitsOfPhoneNumber = iCommaCount = iCommaPosition = iFirstThreeDigitsCount = 0 ;
for ( i = 0 ; i < strlen( sys_phone[0] ) ; i ++ ) {
if ( isdigit( *(sys_phone[0]+i) ) ) {
if ( isdigit( (unsigned char)*(sys_phone[0]+i) ) ) {
if ( iFirstThreeDigitsCount < sizeof(sFirstThreeDigits)-1 ) {
sFirstThreeDigits[iFirstThreeDigitsCount++] = *(sys_phone[0]+i) ;
}
Expand Down Expand Up @@ -3213,7 +3214,7 @@ static int
teljjy_login_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
{

char *pCmd ;
const char *pCmd ;
int iCmdLen ;

DEBUG_TELJJY_PRINTF( "teljjy_login_login" ) ;
Expand Down Expand Up @@ -3665,7 +3666,7 @@ static int modem_esc_data ( struct peer *, struct refclockproc *, struct jjyu
static int modem_esc_silent ( struct peer *, struct refclockproc *, struct jjyunit * ) ;
static int modem_esc_disc ( struct peer *, struct refclockproc *, struct jjyunit * ) ;

static int ( *pModemHandler [ ] [ 5 ] ) ( ) =
static int ( *pModemHandler [ ] [ 5 ] ) ( struct peer *, struct refclockproc *, struct jjyunit * ) =
{ /*STATE_DISCONNECT STATE_INITIALIZE STATE_DAILING STATE_CONNECT STATE_ESCAPE */
/* NULL */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_ignore },
/* INITIALIZE */ { modem_disc_init , modem_init_start , modem_dial_ignore , modem_conn_ignore, modem_esc_ignore },
Expand Down Expand Up @@ -3817,7 +3818,7 @@ modem_receive ( struct recvbuf *rbufp )
struct jjyunit *up;
struct refclockproc *pp;
char *pBuf ;
int iLen ;
size_t iLen ;

#ifdef DEBUG
static const char *sFunctionName = "modem_receive" ;
Expand Down Expand Up @@ -3851,11 +3852,11 @@ modem_receive ( struct recvbuf *rbufp )
#ifdef DEBUG
if ( debug ) {
char sResp [ 40 ] ;
int iCopyLen ;
size_t iCopyLen ;
iCopyLen = ( iLen <= sizeof(sResp)-1 ? iLen : sizeof(sResp)-1 ) ;
strncpy( sResp, pBuf, iLen <= sizeof(sResp)-1 ? iLen : sizeof(sResp)-1 ) ;
sResp[iCopyLen] = 0 ;
printf ( "refclock_jjy.c : modem_receive : iLen=%d pBuf=[%s] iModemEvent=%d\n", iCopyLen, sResp, up->iModemEvent ) ;
printf ( "refclock_jjy.c : modem_receive : iLen=%zu pBuf=[%s] iModemEvent=%d\n", iCopyLen, sResp, up->iModemEvent ) ;
}
#endif
modem_control ( peer, pp, up ) ;
Expand Down Expand Up @@ -3993,7 +3994,8 @@ static int
modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
{

char *pCmd, cBuf [ 46 ] ;
const char *pCmd ;
char cBuf [ 46 ] ;
int iCmdLen ;
int iErrorCorrection, iSpeakerSwitch, iSpeakerVolume ;
int iNextModemState = STAY_MODEM_STATE ;
Expand Down Expand Up @@ -4031,7 +4033,7 @@ modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *
}

pCmd = cBuf ;
snprintf( pCmd, sizeof(cBuf), "ATM%dL%d\r\n", iSpeakerSwitch, iSpeakerVolume ) ;
snprintf( cBuf, sizeof(cBuf), "ATM%dL%d\r\n", iSpeakerSwitch, iSpeakerVolume ) ;
break ;

case 3 :
Expand Down Expand Up @@ -4060,7 +4062,7 @@ modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *
}

pCmd = cBuf ;
snprintf( pCmd, sizeof(cBuf), "AT\\N%d\r\n", iErrorCorrection ) ;
snprintf( cBuf, sizeof(cBuf), "AT\\N%d\r\n", iErrorCorrection ) ;
break ;

case 7 :
Expand Down Expand Up @@ -4251,7 +4253,7 @@ static int
modem_esc_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
{

char *pCmd ;
const char *pCmd ;
int iCmdLen ;

DEBUG_MODEM_PRINTF( "modem_esc_escape" ) ;
Expand Down Expand Up @@ -4317,7 +4319,7 @@ static int
modem_esc_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
{

char *pCmd ;
const char *pCmd ;
int iCmdLen ;

DEBUG_MODEM_PRINTF( "modem_esc_disc" ) ;
Expand Down Expand Up @@ -4350,7 +4352,7 @@ jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData )
{

char sLog [ 100 ] ;
char *pMark ;
const char *pMark ;
int iMarkLen, iDataLen ;

switch ( iMark ) {
Expand Down
7 changes: 5 additions & 2 deletions ntpd/refclock_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -4227,14 +4227,17 @@ parse_process(
static void
mk_utcinfo(
char *t, // pointer to the output string buffer
int wnt,
int wnlsf,
int swnt,
int swnlsf,
int dn,
int dtls,
int dtlsf,
int size // size of the output string buffer
)
{
unsigned int wnt = swnt;
unsigned int wnlsf = swnlsf;

/*
* The week number transmitted by the GPS satellites for the leap date
* is truncated to 8 bits only. If the nearest leap second date is off
Expand Down
2 changes: 1 addition & 1 deletion ntpd/refclock_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ shm_timer(
cd.year, cd.month, cd.monthday,
cd.hour, cd.minute, cd.second,
(long)shm_stat.tvt.tv_nsec);
pp->lencode = (c < sizeof(pp->a_lastcode)) ? c : 0;
pp->lencode = ((size_t)c < sizeof(pp->a_lastcode)) ? c : 0;

/* check 1: age control of local time stamp */
tt = shm_stat.tvc.tv_sec - shm_stat.tvr.tv_sec;
Expand Down
Loading