Skip to contentSkip to conversation

xfrm: use "unsigned int" in __xfrm6_pref_hash()

PATCH Applied Alexey Dobriyan 2 participants 2 messages Mar 23, 2017 – Mar 27, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: use "unsigned int" in __xfrm6_pref_hash()

x86_64 is zero-extending arch so "unsigned int" is preferred over "int" for address calculations.

Space savings:

add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-58 (-58)
function old new delta
xfrm_hash_resize 2752 2743 -9
policy_hash_bysel 985 973 -12
policy_hash_direct 1036 999 -37

---

 net/xfrm/xfrm_hash.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/xfrm/xfrm_hash.h +2 -2
@@ -54,8 +54,8 @@ static inline unsigned int __xfrm4_dpref_spref_hash(const xfrm_address_t *daddr,
 static inline unsigned int __xfrm6_pref_hash(const xfrm_address_t *addr,
 					     __u8 prefixlen)
 {
-	int pdw;
-	int pbi;
+	unsigned int pdw;
+	unsigned int pbi;
 	u32 initval = 0;
 
 	pdw = prefixlen >> 5;     /* num of whole u32 in prefix */
maintainer Applied
#1 lore raw
Quoted 5 lines · Alexey Dobriyan

x86_64 is zero-extending arch so "unsigned int" is preferred over "int" for address calculations.

Space savings:

Quoted 7 lines

add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-58 (-58)
function old new delta
xfrm_hash_resize 2752 2743 -9
policy_hash_bysel 985 973 -12
policy_hash_direct 1036 999 -37

Applied to ipsec-next, thanks!