diff options
Diffstat (limited to 'contrib/ntp/ntpd/refclock_jjy.c')
-rw-r--r-- | contrib/ntp/ntpd/refclock_jjy.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/contrib/ntp/ntpd/refclock_jjy.c b/contrib/ntp/ntpd/refclock_jjy.c index 22636a0..a73cdd8 100644 --- a/contrib/ntp/ntpd/refclock_jjy.c +++ b/contrib/ntp/ntpd/refclock_jjy.c @@ -110,6 +110,11 @@ /* [Fix] C-DEX JST2000 */ /* Thanks to Mr. Kuramatsu for the report and the patch. */ /* */ +/* 2017/04/30 */ +/* [Change] Avoid a wrong report of the coverity static analysis */ +/* tool. ( The code is harmless and has no bug. ) */ +/* teljjy_conn_send() */ +/* */ /**********************************************************************/ #ifdef HAVE_CONFIG_H @@ -393,6 +398,7 @@ struct refclock refclock_jjy = { #define JJY_CLOCKSTATS_MARK_ATTENTION 5 #define JJY_CLOCKSTATS_MARK_WARNING 6 #define JJY_CLOCKSTATS_MARK_ERROR 7 +#define JJY_CLOCKSTATS_MARK_BUG 8 /* Local constants definition for the clockstats messages */ @@ -3299,6 +3305,7 @@ teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u const char * pCmd ; int i, iLen, iNextClockState ; + char sLog [ 120 ] ; DEBUG_TELJJY_PRINTF( "teljjy_conn_send" ) ; @@ -3327,8 +3334,8 @@ teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u /* Loopback character comes */ #ifdef DEBUG if ( debug ) { - printf( "refclock_jjy.c : teljjy_conn_send : iLoopbackCount=%d\n", - up->iLoopbackCount ) ; + printf( "refclock_jjy.c : teljjy_conn_send : iClockCommandSeq=%d iLoopbackCount=%d\n", + up->iClockCommandSeq, up->iLoopbackCount ) ; } #endif @@ -3351,8 +3358,18 @@ teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) { /* Loopback character and timestamp */ - gettimeofday( &(up->sendTime[up->iLoopbackCount]), NULL ) ; - up->bLoopbackMode = TRUE ; + if ( up->iLoopbackCount < MAX_LOOPBACK ) { + gettimeofday( &(up->sendTime[up->iLoopbackCount]), NULL ) ; + up->bLoopbackMode = TRUE ; + } else { + /* This else-block is never come. */ + /* This code avoid wrong report of the coverity static analysis scan tool. */ + snprintf( sLog, sizeof(sLog)-1, "refclock_jjy.c ; teljjy_conn_send ; iClockCommandSeq=%d iLoopbackCount=%d MAX_LOOPBACK=%d", + up->iClockCommandSeq, up->iLoopbackCount, MAX_LOOPBACK ) ; + jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_BUG, sLog ) ; + msyslog ( LOG_ERR, "%s", sLog ) ; + up->bLoopbackMode = FALSE ; + } } else { /* Regular command */ up->bLoopbackMode = FALSE ; @@ -4383,6 +4400,9 @@ jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData ) case JJY_CLOCKSTATS_MARK_ERROR : pMark = "-X- " ; break ; + case JJY_CLOCKSTATS_MARK_BUG : + pMark = "!!! " ; + break ; default : pMark = "" ; break ; |