[Git][NTPsec/ntpsec][master] 3 commits: C99 allows for loops to declare counters inline

Eric S. Raymond gitlab at mg.gitlab.com
Tue Oct 11 12:22:18 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
7d785546 by Matt Selsky at 2016-10-11T08:22:04-04:00
C99 allows for loops to declare counters inline

- - - - -
0b9b3750 by Matt Selsky at 2016-10-11T08:22:04-04:00
Fix IndentationError: unindent does not match any outer indentation level

- - - - -
50b0284a by Matt Selsky at 2016-10-11T08:22:04-04:00
vulture: Unused attribute 'current_value'

- - - - -


5 changed files:

- contrib/gps-log
- libntp/authkeys.c
- libntp/socktoa.c
- ntpd/ntpd.c
- ntpdig/kod_management.c


Changes:

=====================================
contrib/gps-log
=====================================
--- a/contrib/gps-log
+++ b/contrib/gps-log
@@ -15,7 +15,6 @@ class GpsPoller(threading.Thread):
         threading.Thread.__init__(self)
         global gpsd #bring it in scope
         gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
-        self.current_value = None
         self.running = True
 
     def run(self):
@@ -47,8 +46,8 @@ if __name__ == '__main__':
             except AttributeError as e:
                 print( 'parse error\n')
 
-      sys.stdout.flush()
-      time.sleep(5) #set to whatever
+        sys.stdout.flush()
+        time.sleep(5) #set to whatever
 
     except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
         print("\nKilling Thread...")


=====================================
libntp/authkeys.c
=====================================
--- a/libntp/authkeys.c
+++ b/libntp/authkeys.c
@@ -315,9 +315,7 @@ auth_findkey(
 	keyid_t		id
 	)
 {
-	symkey *	sk;
-
-	for (sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
+	for (symkey * sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
 		if (id == sk->keyid) {
 			return sk;
 		}
@@ -335,13 +333,11 @@ auth_havekey(
 	keyid_t		id
 	)
 {
-	symkey *	sk;
-
 	if (0 == id || cache_keyid == id) {
 		return true;
 	}
 
-	for (sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
+	for (symkey * sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
 		if (id == sk->keyid) {
 			return true;
 		}
@@ -497,7 +493,6 @@ MD5auth_setkey(
 	size_t len
 	)
 {
-	symkey *	sk;
 	symkey **	bucket;
 	uint8_t *	secret;
 	size_t		secretsize;
@@ -509,7 +504,7 @@ MD5auth_setkey(
 	 * new value.
 	 */
 	bucket = &key_hash[KEYHASH(keyno)];
-	for (sk = *bucket; sk != NULL; sk = sk->hlink) {
+	for (symkey * sk = *bucket; sk != NULL; sk = sk->hlink) {
 		if (keyno == sk->keyid) {
 			sk->type = (unsigned short)keytype;
 			secretsize = len;
@@ -535,11 +530,9 @@ MD5auth_setkey(
 		    (unsigned short)secretsize, secret);
 #ifdef DEBUG
 	if (debug >= 4) {
-		size_t	j;
-
 		printf("auth_setkey: key %d type %d len %d ", (int)keyno,
 		    keytype, (int)secretsize);
-		for (j = 0; j < secretsize; j++)
+		for (size_t j = 0; j < secretsize; j++)
 			printf("%02x", secret[j]);
 		printf("\n");
 	}	


=====================================
libntp/socktoa.c
=====================================
--- a/libntp/socktoa.c
+++ b/libntp/socktoa.c
@@ -102,7 +102,6 @@ sock_hash(
 	)
 {
 	u_int hashVal;
-	u_int j;
 	size_t len;
 	const uint8_t *pch;
 
@@ -132,7 +131,7 @@ sock_hash(
 		break;
 	}
 
-	for (j = 0; j < len ; j++)
+	for (u_int j = 0; j < len ; j++)
 		hashVal = 37 * hashVal + pch[j];
 
 	return (u_short)(hashVal & USHRT_MAX);


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -555,7 +555,6 @@ ntpdmain(
 
 	if (!dumpopts)
 	{
-		int i;
 		char buf[1024];	/* Secret knowledge of msyslog buf length */
 		char *cp = buf;
 
@@ -565,7 +564,7 @@ ntpdmain(
 		snprintf(cp, sizeof(buf), "Command line:");
 		cp += strlen(cp);
 
-		for (i = 0; i < saved_argc ; ++i) {
+		for (int i = 0; i < saved_argc ; ++i) {
 			snprintf(cp, sizeof(buf) - (cp - buf),
 				" %s", saved_argv[i]);
 			cp += strlen(cp);


=====================================
ntpdig/kod_management.c
=====================================
--- a/ntpdig/kod_management.c
+++ b/ntpdig/kod_management.c
@@ -123,7 +123,6 @@ write_kod_db(void)
 	FILE *db_s;
 	char *pch;
 	int dirmode;
-	register int a;
 
 	db_s = fopen(kod_db_file, "w");
 
@@ -157,7 +156,7 @@ write_kod_db(void)
 		return false;
 	}
 
-	for (a = 0; a < kod_db_cnt; a++) {
+	for (register int a = 0; a < kod_db_cnt; a++) {
 		fprintf(db_s, "%16.16llx %s %s\n", (unsigned long long)
 			kod_db[a]->timestamp, kod_db[a]->type,
 			kod_db[a]->hostname);



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/c285c4fd79c009ce539da89458ccd4544eb477d9...50b0284aa6857b8dbb493fd5b8436ebdaa46ef29
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161011/ec9d4df2/attachment.html>


More information about the vc mailing list