/* Based on MurmurHash3, written by Austin Appleby and placed in the
  * public domain.
  */
-static inline int avtab_hash(const struct avtab_key *keyp, u32 mask)
+static inline u32 avtab_hash(const struct avtab_key *keyp, u32 mask)
 {
        static const u32 c1 = 0xcc9e2d51;
        static const u32 c2 = 0x1b873593;
 }
 
 static struct avtab_node*
-avtab_insert_node(struct avtab *h, int hvalue,
+avtab_insert_node(struct avtab *h, u32 hvalue,
                  struct avtab_node *prev,
                  const struct avtab_key *key, const struct avtab_datum *datum)
 {
 static int avtab_insert(struct avtab *h, const struct avtab_key *key,
                        const struct avtab_datum *datum)
 {
-       int hvalue;
+       u32 hvalue;
        struct avtab_node *prev, *cur, *newnode;
        u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
                                          const struct avtab_key *key,
                                          const struct avtab_datum *datum)
 {
-       int hvalue;
+       u32 hvalue;
        struct avtab_node *prev, *cur;
        u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
 struct avtab_node *avtab_search_node(struct avtab *h,
                                     const struct avtab_key *key)
 {
-       int hvalue;
+       u32 hvalue;
        struct avtab_node *cur;
        u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD);
 
 
 void avtab_destroy(struct avtab *h)
 {
-       int i;
+       u32 i;
        struct avtab_node *cur, *temp;
 
        if (!h)
 #ifdef CONFIG_SECURITY_SELINUX_DEBUG
 void avtab_hash_eval(struct avtab *h, const char *tag)
 {
-       int i, chain_len, slots_used, max_chain_len;
+       u32 i, chain_len, slots_used, max_chain_len;
        unsigned long long chain2_len_sum;
        struct avtab_node *cur;
 
 
                        if (chain_len > max_chain_len)
                                max_chain_len = chain_len;
-                       chain2_len_sum += chain_len * chain_len;
+                       chain2_len_sum += (unsigned long long)chain_len * chain_len;
                }
        }
 
 {
        __le16 buf16[4];
        u16 enabled;
-       u32 items, items2, val, vers = pol->policyvers;
+       u32 items, items2, val, i;
        struct avtab_key key;
        struct avtab_datum datum;
        struct avtab_extended_perms xperms;
        __le32 buf32[ARRAY_SIZE(xperms.perms.p)];
-       int i, rc;
-       unsigned set;
+       int rc;
+       unsigned int set, vers = pol->policyvers;
 
        memset(&key, 0, sizeof(struct avtab_key));
        memset(&datum, 0, sizeof(struct avtab_datum));
 
 int avtab_write(struct policydb *p, struct avtab *a, void *fp)
 {
-       unsigned int i;
+       u32 i;
        int rc = 0;
        struct avtab_node *cur;
        __le32 buf[1];