[Git][NTPsec/ntpsec][master] 4 commits: libisc: add some attribute((pure))

Gary E. Miller gitlab at mg.gitlab.com
Fri Apr 14 21:55:13 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
c1fa98a9 by Gary E. Miller at 2017-04-14T14:45:57-07:00
libisc: add some attribute((pure))

- - - - -
5dc21621 by Gary E. Miller at 2017-04-14T14:48:49-07:00
Strok(): add attribute((pure))

- - - - -
0a82cdf5 by Gary E. Miller at 2017-04-14T14:50:52-07:00
auth_findkey(): remove unused function.

- - - - -
f0284a30 by Gary E. Miller at 2017-04-14T14:52:31-07:00
auth_havekey(): remove unused functions and its tests.

- - - - -


5 changed files:

- include/ntp_stdlib.h
- include/parse.h
- libisc/include/isc/netaddr.h
- libntp/authkeys.c
- tests/libntp/authkeys.c


Changes:

=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -44,7 +44,6 @@ extern	void	errno_to_str(int, char *, size_t);
 
 /* authkeys.c */
 extern	void	auth_delkeys	(void);
-extern	int	auth_havekey	(keyid_t);
 extern	int	authdecrypt	(keyid_t, uint32_t *, int, int);
 extern	int	authencrypt	(keyid_t, uint32_t *, int);
 extern	int	authhavekey	(keyid_t);
@@ -58,7 +57,6 @@ extern	int	clocktime	(int, int, int, int, int, uint32_t, uint32_t *, uint32_t *)
 extern	void	init_auth	(void);
 extern	void	init_lib	(void);
 extern	void	init_network	(void);
-extern	struct savekey *auth_findkey (keyid_t);
 extern	void	auth_moremem	(int);
 extern	void	auth_prealloc_symkeys(int);
 extern	int	ymd2yd		(int, int, int);


=====================================
include/parse.h
=====================================
--- a/include/parse.h
+++ b/include/parse.h
@@ -292,7 +292,8 @@ extern unsigned int parse_restart (parse_t *, char);
 extern unsigned int parse_addchar (parse_t *, char);
 extern unsigned int parse_end (parse_t *);
 
-extern int Strok (const unsigned char *, const unsigned char *);
+extern int Strok (const unsigned char *, const unsigned char *)
+		__attribute__((pure));
 extern int Stoi (const unsigned char *, long *, int);
 
 extern time_t parse_to_unixtime (clocktime_t *, unsigned long *);


=====================================
libisc/include/isc/netaddr.h
=====================================
--- a/libisc/include/isc/netaddr.h
+++ b/libisc/include/isc/netaddr.h
@@ -27,8 +27,8 @@ struct isc_netaddr {
 };
 
 bool
-isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b,
-		     unsigned int prefixlen);
+isc_netaddr_eqprefix(const isc_netaddr_t *, const isc_netaddr_t *,
+		     unsigned int) __attribute__((pure));
 /*%<
  * Compare the 'prefixlen' most significant bits of the network
  * addresses 'a' and 'b'.  If 'b''s scope is zero then 'a''s scope is
@@ -92,7 +92,7 @@ void
 isc_netaddr_setzone(isc_netaddr_t *netaddr, uint32_t zone);
 
 uint32_t
-isc_netaddr_getzone(const isc_netaddr_t *netaddr);
+isc_netaddr_getzone(const isc_netaddr_t *netaddr) __attribute__((pure));
 
 void
 isc_netaddr_any(isc_netaddr_t *netaddr);
@@ -119,7 +119,7 @@ isc_netaddr_isexperimental(isc_netaddr_t *na);
  */
 
 bool
-isc_netaddr_islinklocal(isc_netaddr_t *na);
+isc_netaddr_islinklocal(isc_netaddr_t *na) __attribute__((pure));
 /*%<
  * Returns #true if the address is a link local address.
  */


=====================================
libntp/authkeys.c
=====================================
--- a/libntp/authkeys.c
+++ b/libntp/authkeys.c
@@ -307,46 +307,6 @@ freesymkey(
 
 
 /*
- * auth_findkey - find a key in the hash table
- */
-struct savekey *
-auth_findkey(
-	keyid_t		id
-	)
-{
-	for (symkey * sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
-		if (id == sk->keyid) {
-			return sk;
-		}
-	}
-
-	return NULL;
-}
-
-
-/*
- * auth_havekey - return true if the key id is zero or known
- */
-int
-auth_havekey(
-	keyid_t		id
-	)
-{
-	if (0 == id || cache_keyid == id) {
-		return true;
-	}
-
-	for (symkey * sk = key_hash[KEYHASH(id)]; sk != NULL; sk = sk->hlink) {
-		if (id == sk->keyid) {
-			return true;
-		}
-	}
-
-	return false;
-}
-
-
-/*
  * authhavekey - return true and cache the key, if zero or both known
  *		 and trusted.
  */


=====================================
tests/libntp/authkeys.c
=====================================
--- a/tests/libntp/authkeys.c
+++ b/tests/libntp/authkeys.c
@@ -79,14 +79,12 @@ TEST(authkeys, HaveKeyCorrect) {
 
 	AddTrustedKey(KEYNO);
 
-	TEST_ASSERT_TRUE(auth_havekey(KEYNO));
 	TEST_ASSERT_TRUE(authhavekey(KEYNO));
 }
 
 TEST(authkeys, HaveKeyIncorrect) {
 	const keyid_t KEYNO = 2;
 
-	TEST_ASSERT_FALSE(auth_havekey(KEYNO));
 	TEST_ASSERT_FALSE(authhavekey(KEYNO));
 }
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b147d4869e175fe9e15c6467303840a7f21bfc5e...f0284a302b616e9fbcad98cb0c7dd398c8f0c710

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b147d4869e175fe9e15c6467303840a7f21bfc5e...f0284a302b616e9fbcad98cb0c7dd398c8f0c710
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/20170414/5a7fe2da/attachment.html>


More information about the vc mailing list