Skip to contentSkip to conversation

: alg_key_len should be unsigned to avoid integer divides

XFRM Applied Eric Dumazet 2 participants 2 messages Jan 12, 2008 – Jan 13, 2008

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

alg_key_len is currently defined as 'signed int'. This unfortunatly leads to integer divides in several paths.

Converting it to unsigned is safe and saves 208 bytes of text on i386.

include/linux/xfrm.h +1 -1
index 1131eab..f8507ee 100644
@@ -92,7 +92,7 @@ struct xfrm_replay_state
 
 struct xfrm_algo {
 	char	alg_name[64];
-	int	alg_key_len;    /* in bits */
+	unsigned int	alg_key_len;    /* in bits */
 	char	alg_key[0];
 };
 
maintainer Applied
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Sat, 12 Jan 2008 18:29:32 +0100

Quoted 6 lines

alg_key_len is currently defined as 'signed int'. This unfortunatly leads to integer divides in several paths.

Converting it to unsigned is safe and saves 208 bytes of text on i386.

Applied.

I realigned the struct members in a follow-on changeset.

commit 7305e737926be49e09718df53f4285bf69cc3755

Author: David S. Miller <[email protected]>
Date:   Sat Jan 12 21:31:29 2008 -0800

[XFRM]: Fix struct xfrm_algo code formatting.

Realign struct members.

include/linux/xfrm.h +2 -2
index f8507ee..9b5b00c 100644
@@ -91,9 +91,9 @@ struct xfrm_replay_state
 };
 
 struct xfrm_algo {
-	char	alg_name[64];
+	char		alg_name[64];
 	unsigned int	alg_key_len;    /* in bits */
-	char	alg_key[0];
+	char		alg_key[0];
 };
 
 struct xfrm_stats {