aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-02-16 17:56:22 -0500
committerDavid S. Miller <davem@davemloft.net>2011-02-17 18:49:26 -0500
commit3b004569d86d02786ebae496e75dc0b625be3e9a (patch)
treec345e28b1478ee37755b6d5d061a586308fe033c /net/ipv4/fib_trie.c
parent3c7bd1a14071b99d6535b710bc998ae5d3abbb66 (diff)
ipv4: Avoid use of signed integers in fib_trie code.
GCC emits all kinds of crazy zero extensions when we go from signed int, to unsigned short, etc. etc. This transformation has to be legal because: 1) In tkey_extract_bits() in mask_pfx(), the values are used to perform shifts, on which negative values are undefined by C. 2) In fib_table_lookup() we perform comparisons with unsigned values, constants, and additions. None of which should encounter negative values. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 1eae90b054eb..edf3b0997e01 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -217,12 +217,12 @@ static inline int tnode_child_length(const struct tnode *tn)
217 return 1 << tn->bits; 217 return 1 << tn->bits;
218} 218}
219 219
220static inline t_key mask_pfx(t_key k, unsigned short l) 220static inline t_key mask_pfx(t_key k, unsigned int l)
221{ 221{
222 return (l == 0) ? 0 : k >> (KEYLENGTH-l) << (KEYLENGTH-l); 222 return (l == 0) ? 0 : k >> (KEYLENGTH-l) << (KEYLENGTH-l);
223} 223}
224 224
225static inline t_key tkey_extract_bits(t_key a, int offset, int bits) 225static inline t_key tkey_extract_bits(t_key a, unsigned int offset, unsigned int bits)
226{ 226{
227 if (offset < KEYLENGTH) 227 if (offset < KEYLENGTH)
228 return ((t_key)(a << offset)) >> (KEYLENGTH - bits); 228 return ((t_key)(a << offset)) >> (KEYLENGTH - bits);
@@ -1378,11 +1378,11 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi *flp,
1378 int ret; 1378 int ret;
1379 struct rt_trie_node *n; 1379 struct rt_trie_node *n;
1380 struct tnode *pn; 1380 struct tnode *pn;
1381 int pos, bits; 1381 unsigned int pos, bits;
1382 t_key key = ntohl(flp->fl4_dst); 1382 t_key key = ntohl(flp->fl4_dst);
1383 int chopped_off; 1383 unsigned int chopped_off;
1384 t_key cindex = 0; 1384 t_key cindex = 0;
1385 int current_prefix_length = KEYLENGTH; 1385 unsigned int current_prefix_length = KEYLENGTH;
1386 struct tnode *cn; 1386 struct tnode *cn;
1387 t_key pref_mismatch; 1387 t_key pref_mismatch;
1388 1388