[Git][NTPsec/ntpsec][master] Patch from Takao abe adapted - prevents Coverity warnings.
Eric S. Raymond
gitlab at mg.gitlab.com
Thu May 11 15:35:35 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
4b9ae578 by Eric S. Raymond at 2017-05-11T11:35:06-04:00
Patch from Takao abe adapted - prevents Coverity warnings.
- - - - -
1 changed file:
- ntpd/refclock_jjy.c
Changes:
=====================================
ntpd/refclock_jjy.c
=====================================
--- a/ntpd/refclock_jjy.c
+++ b/ntpd/refclock_jjy.c
@@ -87,6 +87,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() */
+/* */
/**********************************************************************/
#include "config.h"
@@ -354,6 +359,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 */
@@ -3373,6 +3379,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" ) ;
@@ -3401,8 +3408,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
@@ -3425,9 +3432,19 @@ 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 */
- clock_gettime(CLOCK_REALTIME,
+ if ( up->iLoopbackCount < MAX_LOOPBACK ) {
+ clock_gettime(CLOCK_REALTIME,
&(up->sendTime[up->iLoopbackCount]));
- up->bLoopbackMode = true ;
+ 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, sLog ) ;
+ up->bLoopbackMode = false ;
+ }
} else {
/* Regular command */
up->bLoopbackMode = false ;
@@ -4520,6 +4537,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 ;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/4b9ae578289bf7911e3669bb13275961eef1b315
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/4b9ae578289bf7911e3669bb13275961eef1b315
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/20170511/b6ea600b/attachment.html>
More information about the vc
mailing list