Skip to contentSkip to conversation

: alg_key_len & alg_icv_len should be unsigned

XFRM Applied Eric Dumazet 3 participants 4 messages Apr 25, 2008

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

In commit ba749ae98d5aa9d2ce9a7facde0deed454f92230 ([XFRM]: alg_key_len should be unsigned to avoid integer divides <http://git2.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=ba749ae98d5aa9d2ce9a7facde0deed454f92230>) alg_key_len field of struct xfrm_algo was converted to unsigned int to avoid integer divides.

Then Herbert in commit 1a6509d991225ad210de54c63314fd9542922095 ([IPSEC]: Add support for combined mode algorithms) added a new structure xfrm_algo_aead, that resurrected a signed int for alg_key_len and re-introduce integer divides.

This patch avoids these divides and saves 64 bytes of text on i386.

include/linux/xfrm.h +4 -4
index 0c82c80..2ca6bae 100644
@@ -97,10 +97,10 @@ struct xfrm_algo {
 };
 
 struct xfrm_algo_aead {
-	char	alg_name[64];
-	int	alg_key_len;	/* in bits */
-	int	alg_icv_len;	/* in bits */
-	char	alg_key[0];
+	char		alg_name[64];
+	unsigned int	alg_key_len;	/* in bits */
+	unsigned int	alg_icv_len;	/* in bits */
+	char		alg_key[0];
 };
 
 struct xfrm_stats {
Acked-by
#1 lore raw
Quoted 6 lines · Eric Dumazet

In commit ba749ae98d5aa9d2ce9a7facde0deed454f92230 ([XFRM]: alg_key_len should be unsigned to avoid integer divides
<http://git2.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=ba749ae98d5aa9d2ce9a7facde0deed454f92230>)
alg_key_len field of struct xfrm_algo was converted to unsigned int to avoid integer divides.

Quoted 8 lines

Then Herbert in commit 1a6509d991225ad210de54c63314fd9542922095 ([IPSEC]: Add support for combined mode algorithms) added a new structure xfrm_algo_aead, that resurrected a signed int for alg_key_len and re-introduce integer divides.

This patch avoids these divides and saves 64 bytes of text on i386.

I actually wrote my patch before yours was merged which was why it was signed.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 8 lines · Herbert Xu

I actually wrote my patch before yours was merged which was why it was signed.

Cheers,

No problem Herbert, this is a minor cleanup after all :)

maintainer Applied
#3 lore raw
In reply to Herbert Xu

From: Herbert Xu <[email protected]>
Date: Fri, 25 Apr 2008 15:14:20 +0800

Quoted 12 lines · Eric Dumazet
Quoted 11 lines

In commit ba749ae98d5aa9d2ce9a7facde0deed454f92230 ([XFRM]: alg_key_len should be unsigned to avoid integer divides
<http://git2.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=ba749ae98d5aa9d2ce9a7facde0deed454f92230>)
alg_key_len field of struct xfrm_algo was converted to unsigned int to avoid integer divides.

Then Herbert in commit 1a6509d991225ad210de54c63314fd9542922095 ([IPSEC]: Add support for combined mode algorithms) added a new structure xfrm_algo_aead, that resurrected a signed int for alg_key_len and re-introduce integer divides.

Quoted 8 lines
Quoted 3 lines

This patch avoids these divides and saves 64 bytes of text on i386.

I actually wrote my patch before yours was merged which was why it was signed.

Applied, thanks everyone.