[Git][NTPsec/ntpsec][master] 2 commits: Change explicit cast to implicit casts.
Gary E. Miller
gitlab at mg.gitlab.com
Mon Apr 3 21:30:11 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
4327b17a by Gary E. Miller at 2017-04-03T13:47:32-07:00
Change explicit cast to implicit casts.
- - - - -
6815c873 by Gary E. Miller at 2017-04-03T14:28:58-07:00
ref_generic: Change imlicit casts to explicit.
- - - - -
2 changed files:
- ntpd/refclock_generic.c
- ntpd/refclock_jjy.c
Changes:
=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -96,8 +96,8 @@
# include <linux/serial.h>
#endif
-# define BUFFER_SIZE(_BUF, _PTR) ((int)((_BUF) + sizeof(_BUF) - (_PTR)))
-# define BUFFER_SIZES(_BUF, _PTR, _SZ) ((int)((_BUF) + (_SZ) - (_PTR)))
+#define BUFFER_SIZE(_BUF, _PTR) ((size_t)((_BUF) + sizeof(_BUF) - (_PTR)))
+#define BUFFER_SIZES(_BUF, _PTR, _SZ) ((int)((_BUF) + (_SZ) - (_PTR)))
/*
* COND_DEF can be conditionally defined as DEF or 0. If defined as DEF
@@ -1819,7 +1819,7 @@ local_input(
while (count--)
{
- if (parse_ioread(&parse->parseio, (unsigned int)(*s++), &ts))
+ if (parse_ioread(&parse->parseio, (char)(*s++), &ts))
{
struct recvbuf *buf;
@@ -2545,7 +2545,7 @@ parse_start(
peer->refclkunit = peer->refclkunit & 0x03;
#endif /* ENABLE_CLASSIC_MODE */
- type = CLK_TYPE(peer);
+ type = (u_int)CLK_TYPE(peer);
unit = peer->refclkunit;
if ((type == (u_int)~0) || (parse_clockinfo[type].cl_description == (char *)0))
@@ -2691,11 +2691,11 @@ parse_start(
if (ioctl(parse->ppsfd, TIOCGSERIAL, &ss) < 0 ||
(
#ifdef ASYNC_LOW_LATENCY
- ss.flags |= ASYNC_LOW_LATENCY,
+ ss.flags |= (int)ASYNC_LOW_LATENCY,
#endif
#ifndef HAVE_PPSAPI
#ifdef ASYNC_PPS_CD_NEG
- ss.flags |= ASYNC_PPS_CD_NEG,
+ ss.flags |= (int)ASYNC_PPS_CD_NEG,
#endif
#endif
ioctl(parse->ppsfd, TIOCSSERIAL, &ss)) < 0) {
@@ -3525,17 +3525,22 @@ parse_process(
if (parse->parse_type->cl_flags & PARSE_F_PPSONSECOND)
{
- reftime = off = offset;
- if (lfpfrac(reftime) & 0x80000000)
- bumplfpuint(reftime, 1);
- setlfpfrac(reftime, 0);
-
-
- /*
- * implied on second offset
- */
- setlfpfrac(off, ~lfpfrac(off)); /* map [0.5..1[ -> [-0.5..0[ */
- setlfpsint(off, (lfpfrac(off) & 0x80000000) ? -1 : 0); /* sign extend */
+ reftime = off = offset;
+ if (lfpfrac(reftime) & 0x80000000)
+ bumplfpuint(reftime, 1);
+ setlfpfrac(reftime, 0);
+
+
+ /*
+ * implied on second offset
+ */
+ /* map [0.5..1[ -> [-0.5..0[ */
+ setlfpfrac(off, ~lfpfrac(off));
+ /* sign extend */
+ setlfpuint(off,
+ (unsigned long int)(
+ (lfpfrac(off) & 0x80000000) ?
+ -1 : 0));
}
else
{
@@ -3566,8 +3571,11 @@ parse_process(
/*
* implied on second offset
*/
- setlfpfrac(off, ~lfpfrac(off)); /* map [0.5..1[ -> [-0.5..0[ */
- setlfpsint(off, (lfpfrac(off) & 0x80000000) ? -1 : 0); /* sign extend */
+ /* map [0.5..1[ -> [-0.5..0[ */
+ setlfpfrac(off, ~lfpfrac(off));
+ /* sign extend */
+ setlfpuint(off, ((lfpfrac(off) & 0x80000000) ?
+ (unsigned long int)-1 : 0));
}
}
else
@@ -3746,9 +3754,9 @@ mk_utcinfo(
if (wnt < GPSWRAP)
wnt += GPSWEEKS;
- t_ls = (time_t) wnlsf * SECSPERWEEK
- + (time_t) dn * SECSPERDAY
- + GPS_SEC_BIAS - 1;
+ t_ls = (time_t)(wnlsf * SECSPERWEEK +
+ dn * SECSPERDAY +
+ (int)GPS_SEC_BIAS - 1);
tm = gmtime_r( &t_ls, &tmbuf );
if (tm == NULL) // gmtime_r() failed
@@ -4186,7 +4194,7 @@ gps16x_poll(
put_mbg_header(&outp, header);
outp = cmd_buffer + 1;
- header->hdr_csum = (short)mbg_csum(outp, 6);
+ header->hdr_csum = (CSUM)mbg_csum(outp, 6);
put_mbg_header(&outp, header);
#ifdef DEBUG
@@ -4268,7 +4276,7 @@ poll_dpoll(
{
long rtc;
const char *ps = ((poll_info_t *)parse->parse_type->cl_data)->string;
- long ct = ((poll_info_t *)parse->parse_type->cl_data)->count;
+ long ct = (long)(((poll_info_t *)parse->parse_type->cl_data)->count);
rtc = write(parse->generic->io.fd, ps, (size_t)ct);
if (rtc < 0)
@@ -4571,7 +4579,8 @@ sendetx(
{
char buffer[256];
- mkreadable(buffer, sizeof(buffer), (char *)buf->txt, (unsigned)buf->idx, 1);
+ mkreadable(buffer, sizeof(buffer), (char *)buf->txt,
+ (u_long)buf->idx, 1);
printf("PARSE receiver #%d: transmitted message (%d bytes) >%s<\n",
parse->peer->refclkunit,
buf->idx, buffer);
@@ -4709,13 +4718,13 @@ trimble_check(
int i;
for (i = 0; oldsats; i++) {
- if (oldsats & (1 << i))
+ if (oldsats & (1U << i))
{
sendcmd(&buf, CMD_CSTATTRACK);
sendbyte(&buf, i+1); /* old sat */
sendetx(&buf, parse);
}
- oldsats &= ~(1 << i);
+ oldsats &= ~(1U << i);
}
}
@@ -5239,7 +5248,7 @@ trimbletsip_message(
{
t = ap(pbuffer, sizeof(pbuffer), t, "%s%02d", i ? ", " : "", mb(17+i));
if (tr)
- tr->ctrack |= (1 << (mb(17+i)-1));
+ tr->ctrack |= (1U << (mb(17+i)-1));
}
if (tr)
=====================================
ntpd/refclock_jjy.c
=====================================
--- a/ntpd/refclock_jjy.c
+++ b/ntpd/refclock_jjy.c
@@ -480,7 +480,8 @@ jjy_start ( int unit, struct peer *peer )
}
/* Open the device */
- fd = refclock_open ( sDeviceName, up->linespeed, up->linediscipline ) ;
+ fd = refclock_open ( sDeviceName, (u_int)up->linespeed,
+ (u_int)up->linediscipline ) ;
if ( fd <= 0 ) {
free ( (void*) up ) ;
/* coverity[leaked_handle] */
@@ -812,8 +813,8 @@ getRawDataBreakPosition ( struct jjyunit *up, int iStart )
if ( i + up->pRawBreak[j].iLength <= up->iRawBufLen ) {
if ( strncmp( up->sRawBuf + i,
- up->pRawBreak[j].pString,
- up->pRawBreak[j].iLength ) == 0 ) {
+ up->pRawBreak[j].pString,
+ (size_t)up->pRawBreak[j].iLength ) == 0 ) {
#ifdef DEBUG
printf( "refclock_jjy.c : getRawDataBreakPosition : iStart=%d return=%d\n",
@@ -1305,7 +1306,7 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
pCmd = tristate_jjy01_command_sequence[up->iCommandSeq].command ;
iCmdLen = tristate_jjy01_command_sequence[up->iCommandSeq].commandLength ;
- if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write ( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report ( peer, CEVNT_FAULT ) ;
}
@@ -1360,7 +1361,7 @@ jjy_poll_tristate_jjy01 ( int unit, struct peer *peer )
pCmd = tristate_jjy01_command_sequence[up->iCommandSeq].command ;
iCmdLen = tristate_jjy01_command_sequence[up->iCommandSeq].commandLength ;
- if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write ( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report ( peer, CEVNT_FAULT ) ;
}
@@ -1707,14 +1708,16 @@ jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp )
}
if (up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ) {
- /* Switch from mode 2 to mode 1 in order to restraint of useless time stamp. */
+ /* Switch from mode 2 to mode 1 in order to restraint of
+ * useless time stamp.
+ */
+ iLen = strlen( ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND ) ;
+ if ( write ( pp->io.fd, ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND,
+ (size_t)iLen ) != iLen ) {
+ refclock_report ( peer, CEVNT_FAULT ) ;
+ }
- iLen = strlen( ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND ) ;
- if ( write ( pp->io.fd, ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND, iLen ) != iLen ) {
- refclock_report ( peer, CEVNT_FAULT ) ;
- }
-
- jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_SEND, ECHOKEISOKUKI_LT2000_COMMAND_REQUEST_SEND ) ;
}
@@ -2197,7 +2200,7 @@ jjy_receive_tristate_gpsclock01 ( struct recvbuf *rbufp )
pCmd = tristate_gps01_command_sequence[up->iCommandSeq].command ;
iCmdLen = tristate_gps01_command_sequence[up->iCommandSeq].commandLength ;
- if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write ( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report ( peer, CEVNT_FAULT ) ;
}
@@ -2251,7 +2254,7 @@ jjy_poll_tristate_gpsclock01 ( int unit, struct peer *peer )
pCmd = tristate_gps01_command_sequence[up->iCommandSeq].command ;
iCmdLen = tristate_gps01_command_sequence[up->iCommandSeq].commandLength ;
- if ( write ( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write ( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report ( peer, CEVNT_FAULT ) ;
}
@@ -2822,10 +2825,10 @@ jjy_receive_telephone ( struct recvbuf *rbufp )
if ( up->linediscipline == LDISC_RAW ) {
pBuf = up->sTextBuf ;
- iLen = up->iTextBufLen ;
+ iLen = (size_t)up->iTextBufLen ;
} else {
pBuf = pp->a_lastcode ;
- iLen = pp->lencode ;
+ iLen = (size_t)pp->lencode ;
}
up->iTeljjySilentTimer = 0 ;
@@ -3021,7 +3024,7 @@ teljjy_getDelay ( struct peer *peer, struct jjyunit *up )
int i ;
int minIndex = 0, maxIndex = 0, iAverCount = 0 ;
int iThresholdSecond, iThresholdMicroSecond ;
- int iPercent ;
+ unsigned int iPercent ;
minTime.tv_sec = minTime.tv_nsec = 0 ;
maxTime.tv_sec = maxTime.tv_nsec = 0 ;
@@ -3243,7 +3246,7 @@ teljjy_login_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit
/* Send login ID */
iCmdLen = strlen( pCmd ) ;
- if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report( peer, CEVNT_FAULT ) ;
}
@@ -3368,7 +3371,7 @@ teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
if ( pCmd != NULL ) {
- if ( write( pp->io.fd, pCmd, iLen ) != iLen ) {
+ if ( write( pp->io.fd, pCmd, (size_t)iLen ) != iLen ) {
refclock_report( peer, CEVNT_FAULT ) ;
}
@@ -3434,7 +3437,9 @@ teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
up->iLoopbackCount ++ ;
} else if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength == iLen
- && strncmp( pBuf, teljjy_command_sequence[up->iClockCommandSeq].command, iLen ) == 0 ) {
+ && strncmp( pBuf,
+ teljjy_command_sequence[up->iClockCommandSeq].command,
+ (size_t) iLen ) == 0 ) {
/* Maybe echoback */
jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_INFORMATION, JJY_CLOCKSTATS_MESSAGE_ECHOBACK ) ;
@@ -3899,7 +3904,8 @@ modem_receive ( struct recvbuf *rbufp )
if ( debug ) {
char sResp [ 40 ] ;
size_t iCopyLen ;
- iCopyLen = ( iLen <= (int)sizeof(sResp)-1 ? iLen : (int)sizeof(sResp)-1 ) ;
+ iCopyLen = iLen <= (int)sizeof(sResp)-1 ?
+ (size_t)iLen : sizeof(sResp) - 1U;
strlcpy( sResp, pBuf, sizeof(sResp) ) ;
printf ( "refclock_jjy.c : modem_receive : iLen=%zd pBuf=[%s] iModemEvent=%d\n", iCopyLen, sResp, up->iModemEvent ) ;
}
@@ -4142,7 +4148,7 @@ modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *
if ( pCmd != NULL ) {
iCmdLen = strlen( pCmd ) ;
- if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report( peer, CEVNT_FAULT ) ;
}
@@ -4224,7 +4230,7 @@ modem_dial_dialout ( struct peer *peer, struct refclockproc *pp, struct jjyunit
/* Send command */
iCmdLen = strlen( sCmd ) ;
- if ( write( pp->io.fd, sCmd, iCmdLen ) != iCmdLen ) {
+ if ( write( pp->io.fd, sCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report( peer, CEVNT_FAULT ) ;
}
@@ -4340,7 +4346,7 @@ modem_esc_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
/* Send command */
iCmdLen = strlen( pCmd ) ;
- if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report( peer, CEVNT_FAULT ) ;
}
@@ -4409,7 +4415,7 @@ modem_esc_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up
/* Send command */
iCmdLen = strlen( pCmd ) ;
- if ( write( pp->io.fd, pCmd, iCmdLen ) != iCmdLen ) {
+ if ( write( pp->io.fd, pCmd, (size_t)iCmdLen ) != iCmdLen ) {
refclock_report( peer, CEVNT_FAULT ) ;
}
@@ -4465,7 +4471,8 @@ jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData )
iDataLen = strlen( pData ) ;
iMarkLen = strlen( pMark ) ;
strlcpy( sLog, pMark, sizeof( sLog )) ;
- printableString( sLog+iMarkLen, sizeof(sLog)-iMarkLen, pData, iDataLen ) ;
+ printableString( sLog+iMarkLen, (int)sizeof(sLog)-iMarkLen,
+ pData, iDataLen ) ;
#if defined(DEBUG) && DEBUG
if ( debug ) {
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/fa1d8dec38d0cacbea2e3646f0fbf2ed791dbab8...6815c8737eec3f28560210ddc2689eb7583e9815
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170403/7605fd84/attachment.html>
More information about the vc
mailing list