[Git][NTPsec/ntpsec][master] Move variable declarations closer to usage

Matt Selsky gitlab at mg.gitlab.com
Sun Feb 24 00:13:29 UTC 2019


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
b3726684 by Matt Selsky at 2019-02-24T00:09:43Z
Move variable declarations closer to usage

- - - - -


5 changed files:

- ntpd/ntp_config.c
- ntpd/ntpd.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_jjy.c
- ntpd/refclock_oncore.c


Changes:

=====================================
ntpd/ntp_config.c
=====================================
@@ -2397,18 +2397,16 @@ config_fudge(
 # ifdef REFCLOCK
 	attr_val *curr_opt;
 	sockaddr_u addr_sock;
-	address_node *addr_node;
 	struct refclockstat clock_stat;
-	bool err_flag;
 
 	curr_fudge = HEAD_PFIFO(ptree->fudge);
 	for (; curr_fudge != NULL; curr_fudge = curr_fudge->link) {
-		err_flag = false;
+		bool err_flag = false;
 
 		/* Get the reference clock address and
 		 * ensure that it is sane
 		 */
-		addr_node = curr_fudge->addr;
+		address_node *addr_node = curr_fudge->addr;
 		ZERO_SOCK(&addr_sock);
 		if (getnetnum(addr_node->address, &addr_sock)
 		    != 1) {
@@ -2719,7 +2717,6 @@ config_peers(
 	)
 {
     sockaddr_u		peeraddr;
-    peer_node *		curr_peer;
 
     /* add servers named on the command line with iburst implied */
     for ( ; cmdline_server_count > 0;
@@ -2763,7 +2760,7 @@ config_peers(
     }
 
     /* add associations from the configuration file */
-    curr_peer = HEAD_PFIFO(ptree->peers);
+    peer_node * curr_peer = HEAD_PFIFO(ptree->peers);
     for (; curr_peer != NULL; curr_peer = curr_peer->link) {
 	ZERO_SOCK(&peeraddr);
 
@@ -2886,12 +2883,11 @@ config_unpeers(
 	)
 {
 	sockaddr_u		peeraddr;
-	unpeer_node *		curr_unpeer;
 	struct peer *		p;
 	const char *		name;
 	int			rc;
 
-	curr_unpeer = HEAD_PFIFO(ptree->unpeers);
+	unpeer_node * curr_unpeer = HEAD_PFIFO(ptree->unpeers);
 	for (; curr_unpeer != NULL; curr_unpeer = curr_unpeer->link) {
 		/*
 		 * Either AssocID will be zero, and we unpeer by name/


=====================================
ntpd/ntpd.c
=====================================
@@ -1048,7 +1048,6 @@ wait_child_sync_if(
 	long	wait_sync1
 	)
 {
-	int	rc;
 	int	exit_code;
 	time_t	wait_end_time;
 	time_t	cur_time;
@@ -1071,8 +1070,8 @@ wait_child_sync_if(
 		wtimeout.tv_nsec = 0;
 		FD_ZERO(&readset);
 		FD_SET(pipe_read_fd, &readset);
-		rc = pselect(pipe_read_fd + 1, &readset, NULL, NULL,
-			     &wtimeout, NULL);
+		int rc = pselect(pipe_read_fd + 1, &readset, NULL, NULL,
+				 &wtimeout, NULL);
 		if (-1 == rc) {
 			if (EINTR == errno)
 				continue;


=====================================
ntpd/refclock_gpsd.c
=====================================
@@ -410,7 +410,7 @@ static void
 gpsd_init(void)
 {
 	addrinfoT   hints;
-	int         rc, idx;
+	int         idx;
 
 	memset(s_svcerr, 0, sizeof(s_svcerr));
 	memset(&hints, 0, sizeof(hints));
@@ -419,8 +419,8 @@ gpsd_init(void)
 	hints.ai_socktype = SOCK_STREAM;
 
 	for (idx = 0; s_svctab[idx][0] && !s_gpsd_addr; idx++) {
-		rc = getaddrinfo(s_svctab[idx][0], s_svctab[idx][1],
-				 &hints, &s_gpsd_addr);
+		int rc = getaddrinfo(s_svctab[idx][0], s_svctab[idx][1],
+				     &hints, &s_gpsd_addr);
 		s_svcerr[idx] = rc;
 		if (0 == rc)
 			break;


=====================================
ntpd/refclock_jjy.c
=====================================
@@ -1796,7 +1796,6 @@ jjy_receive_citizentic_jjy200 ( struct recvbuf *rbufp )
 
 	char	*pBuf, sLog [ MAX_LOGTEXT ], sMsg [ 16 ] ;
 	int	iLen ;
-	int	rc ;
 	char	cApostrophe, sStatus[3] ;
 	int	iWeekday ;
 
@@ -1839,10 +1838,10 @@ jjy_receive_citizentic_jjy200 ( struct recvbuf *rbufp )
 
 	/* 'XX YY/MM/DD W HH:MM:SS<CR> */
 
-	rc = sscanf ( pBuf, "%c%2s %2d/%2d/%2d %1d %2d:%2d:%2d",
-		      &cApostrophe, sStatus,
-		      &up->year, &up->month, &up->day, &iWeekday,
-		      &up->hour, &up->minute, &up->second ) ;
+	int rc = sscanf ( pBuf, "%c%2s %2d/%2d/%2d %1d %2d:%2d:%2d",
+			  &cApostrophe, sStatus,
+			  &up->year, &up->month, &up->day, &iWeekday,
+			  &up->hour, &up->minute, &up->second ) ;
 	sStatus[2] = 0 ;
 
 	if ( rc != 9 || cApostrophe != '\''


=====================================
ntpd/refclock_oncore.c
=====================================
@@ -922,7 +922,7 @@ oncore_init_shmem(
 	struct instance *instance
 	)
 {
-	int l, fd;
+	int fd;
 	uint8_t *cp, *cp1, *buf, *shmem_old;
 	struct msg_desc *mp;
 	struct stat sbuf;
@@ -989,7 +989,7 @@ oncore_init_shmem(
 	/* next build the new SHMEM buffer in memory */
 
 	for (mp=oncore_messages; mp->flag[0]; mp++) {
-		l = mp->shmem;
+		int l = mp->shmem;
 		buf[l + 0] = mp->len >> 8;
 		buf[l + 1] = mp->len & 0xff;
 		buf[l + 2] = 0;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b37266847d01ca32003c97ec9bbdb7c2f78a9976

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b37266847d01ca32003c97ec9bbdb7c2f78a9976
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/20190224/7ab88fa0/attachment-0001.html>


More information about the vc mailing list