1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: IOC tool complains about undefined behavior for int.
12 Solution: Change to unsigned int. (Dominique Pelle)
13 Files: src/hashtab.c, src/misc2.c
16 *** ../vim-7.3.739/src/hashtab.c 2010-08-15 21:57:25.000000000 +0200
17 --- src/hashtab.c 2012-11-28 18:27:46.000000000 +0100
37 * - skip over a removed item
38 * - return if the item matches
40 ! idx = (int)(hash & ht->ht_mask);
41 hi = &ht->ht_array[idx];
43 if (hi->hi_key == NULL)
45 * - skip over a removed item
46 * - return if the item matches
48 ! idx = (unsigned)(hash & ht->ht_mask);
49 hi = &ht->ht_array[idx];
51 if (hi->hi_key == NULL)
55 ++hash_count_perturb; /* count a "miss" for hashtab lookup */
57 ! idx = (int)((idx << 2) + idx + perturb + 1);
58 hi = &ht->ht_array[idx & ht->ht_mask];
59 if (hi->hi_key == NULL)
60 return freeitem == NULL ? hi : freeitem;
63 ++hash_count_perturb; /* count a "miss" for hashtab lookup */
65 ! idx = (unsigned)((idx << 2U) + idx + perturb + 1U);
66 hi = &ht->ht_array[idx & ht->ht_mask];
67 if (hi->hi_key == NULL)
68 return freeitem == NULL ? hi : freeitem;
71 hashitem_T temparray[HT_INIT_SIZE];
72 hashitem_T *oldarray, *newarray;
73 hashitem_T *olditem, *newitem;
76 long_u oldsize, newsize;
79 hashitem_T temparray[HT_INIT_SIZE];
80 hashitem_T *oldarray, *newarray;
81 hashitem_T *olditem, *newitem;
84 long_u oldsize, newsize;
88 * the algorithm to find an item in hash_lookup(). But we only
89 * need to search for a NULL key, thus it's simpler.
91 ! newi = (int)(olditem->hi_hash & newmask);
92 newitem = &newarray[newi];
94 if (newitem->hi_key != NULL)
95 for (perturb = olditem->hi_hash; ; perturb >>= PERTURB_SHIFT)
97 ! newi = (int)((newi << 2) + newi + perturb + 1);
98 newitem = &newarray[newi & newmask];
99 if (newitem->hi_key == NULL)
102 * the algorithm to find an item in hash_lookup(). But we only
103 * need to search for a NULL key, thus it's simpler.
105 ! newi = (unsigned)(olditem->hi_hash & newmask);
106 newitem = &newarray[newi];
108 if (newitem->hi_key != NULL)
109 for (perturb = olditem->hi_hash; ; perturb >>= PERTURB_SHIFT)
111 ! newi = (unsigned)((newi << 2U) + newi + perturb + 1U);
112 newitem = &newarray[newi & newmask];
113 if (newitem->hi_key == NULL)
115 *** ../vim-7.3.739/src/misc2.c 2012-08-15 16:20:59.000000000 +0200
116 --- src/misc2.c 2012-11-28 18:27:46.000000000 +0100
121 temp = (ush)keys[2] | 2; \
122 ! t = (int)(((unsigned)(temp * (temp ^ 1)) >> 8) & 0xff); \
129 temp = (ush)keys[2] | 2; \
130 ! t = (int)(((unsigned)(temp * (temp ^ 1U)) >> 8) & 0xff); \
138 temp = (ush)keys[2] | 2;
139 ! temp = (int)(((unsigned)(temp * (temp ^ 1)) >> 8) & 0xff);
140 UPDATE_KEYS_ZIP(*p ^= temp);
146 temp = (ush)keys[2] | 2;
147 ! temp = (int)(((unsigned)(temp * (temp ^ 1U)) >> 8) & 0xff);
148 UPDATE_KEYS_ZIP(*p ^= temp);
151 *** ../vim-7.3.739/src/version.c 2012-11-28 18:22:04.000000000 +0100
152 --- src/version.c 2012-11-28 18:28:00.000000000 +0100
156 { /* Add new patch number below this line */
162 From "know your smileys":
163 ~#:-( I just washed my hair, and I can't do nuthin' with it.
165 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
166 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
167 \\\ an exciting new programming language -- http://www.Zimbu.org ///
168 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///