From: Dave Hart Date: Wed, 15 Dec 2010 00:14:11 +0000 (+0000) Subject: quiet gcc4 warnings X-Git-Tag: NTP_4_2_7P94~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aff0e59d191a504b16031ebb32f5c8f3990677eb;p=thirdparty%2Fntp.git quiet gcc4 warnings alloc/free peer group identity member bk: 4d080853JAZhazHIWB14ZG6evGyVRQ --- diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 5e9dc5d52..afa989e82 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -563,7 +563,6 @@ ctl_error( ) { int maclen; - keyid_t * pkid; numctlerrors++; DPRINTF(3, ("sending control error %u\n", errcode)); diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index d3a96d2ff..ec2508bb2 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -3591,13 +3591,14 @@ input_handler( l_fp ts_e; /* Timestamp at EOselect() gob */ #endif fd_set fds; - int select_count = 0; + size_t select_count; endpt *ep; #if defined(HAS_ROUTING_SOCKET) struct asyncio_reader *asyncio_reader; #endif handler_calls++; + select_count = 0; /* * If we have something to do, freeze a timestamp. diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index d16a9b2f2..9eeec21c1 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -467,6 +467,9 @@ free_peer( if (p->hostname != NULL) free(p->hostname); + if (p->ident != NULL) + free(p->ident); + if (p->addrs != NULL) free(p->addrs); /* from copy_addrinfo_list() */ @@ -894,7 +897,7 @@ newpeer( #endif /* AUTOKEY */ peer->ttl = (u_char)ttl; peer->keyid = key; - peer->ident = group; + peer->ident = estrdup(group); peer->precision = sys_precision; peer->hpoll = peer->minpoll; if (cast_flags & MDF_ACAST) diff --git a/ntpd/refclock_jjy.c b/ntpd/refclock_jjy.c index df7869dc9..a088140c6 100644 --- a/ntpd/refclock_jjy.c +++ b/ntpd/refclock_jjy.c @@ -1349,7 +1349,6 @@ jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer ) static void printableString ( char *sOutput, int iOutputLen, char *sInput, int iInputLen ) { - char *printableControlChar[] = { "", "", "", "", "", "", "", "", @@ -1360,28 +1359,34 @@ printableString ( char *sOutput, int iOutputLen, char *sInput, int iInputLen ) "", "" , "", "", "" , "" , "" , "" , " " } ; - - int i, j, n ; - - for ( i = j = 0 ; i < iInputLen && j < iOutputLen ; i ++ ) { + size_t InputLen; + size_t OutputLen; + size_t i; + size_t j; + size_t n; + + InputLen = (size_t)iInputLen; + OutputLen = (size_t)iOutputLen; + for ( i = j = 0 ; i < InputLen && j < OutputLen ; i ++ ) { if ( isprint( sInput[i] ) ) { n = 1 ; - if ( j + 1 >= iOutputLen ) + if ( j + 1 >= OutputLen ) break ; sOutput[j] = sInput[i] ; } else if ( ( sInput[i] & 0xFF ) < COUNTOF(printableControlChar) ) { n = strlen( printableControlChar[sInput[i] & 0xFF] ) ; - if ( j + n + 1 >= iOutputLen ) + if ( j + n + 1 >= OutputLen ) break ; strncpy( sOutput + j, printableControlChar[sInput[i] & 0xFF], - (size_t)iOutputLen - j ) ; + OutputLen - j ) ; } else { n = 5 ; - if ( j + n + 1 >= iOutputLen ) break ; - snprintf( sOutput + j, (size_t)iOutputLen - j, - "", sInput[i] & 0xFF ) ; + if ( j + n + 1 >= OutputLen ) + break ; + snprintf( sOutput + j, OutputLen - j, "", + sInput[i] & 0xFF ) ; } j += n ; } diff --git a/ntpd/refclock_mx4200.c b/ntpd/refclock_mx4200.c index 11d4a260a..7c85d07e6 100644 --- a/ntpd/refclock_mx4200.c +++ b/ntpd/refclock_mx4200.c @@ -840,7 +840,7 @@ mx4200_receive( * Capture the last PPS signal. * Precision timestamp is returned in pp->lastrec */ - if (mx4200_pps(peer) != NULL) { + if (0 != mx4200_pps(peer)) { mx4200_debug(peer, "mx4200_receive: pps failure\n"); refclock_report(peer, CEVNT_FAULT); return; diff --git a/sntp/tests/packetHandling.cpp b/sntp/tests/packetHandling.cpp index 74b861da7..15f7fd98f 100644 --- a/sntp/tests/packetHandling.cpp +++ b/sntp/tests/packetHandling.cpp @@ -122,7 +122,7 @@ TEST_F(mainTest, OffsetCalculationPositiveOffset) { offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &root_disp); EXPECT_DOUBLE_EQ(1.25, offset); - EXPECT_DOUBLE_EQ(LOGTOD(-16), precision); + EXPECT_DOUBLE_EQ(1. / ULOGTOD(16), precision); EXPECT_DOUBLE_EQ(0.25, root_disp); } @@ -164,7 +164,7 @@ TEST_F(mainTest, OffsetCalculationNegativeOffset) { offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &root_disp); EXPECT_DOUBLE_EQ(-1, offset); - EXPECT_DOUBLE_EQ(LOGTOD(-1), precision); + EXPECT_DOUBLE_EQ(1. / ULOGTOD(1), precision); EXPECT_DOUBLE_EQ(0.5, root_disp); }