Commit 68383ac
midx-write: use uint32_t for preferred_pack_idx
midx-write.c has the DISABLE_SIGN_COMPARE_WARNINGS macro defined for a
few reasons, but the biggest one is the use of a signed
preferred_pack_idx member inside the write_midx_context struct. The code
currently uses -1 to indicate an unset preferred pack but pack int ids
are normally handled as uint32_t. There are also a few loops that search
for the preferred pack by name and those iterators will need updates to
uint32_t in the next change.
For now, replace the use of -1 with a 'NO_PREFERRED_PACK' macro and an
equality check. The macro stores the max value of a uint32_t, so we
cannot store a preferred pack that appears last in a list of 2^32 total
packs, but that's expected to be unreasonable already. Furthermore, with
this change we end up extending the range from 2^31 possible packs to
2^32-1.
There are some careful things to worry about with initializing the
preferred pack in the struct and using that value when searching for a
preferred pack that was already incorrect but accidentally working when
the index was initialized to zero.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 9c2262d commit 68383ac
1 file changed
+15
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
263 | | - | |
| 264 | + | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| |||
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
277 | | - | |
| 278 | + | |
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
| |||
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
367 | | - | |
| 368 | + | |
| 369 | + | |
368 | 370 | | |
369 | 371 | | |
370 | 372 | | |
| |||
1058 | 1060 | | |
1059 | 1061 | | |
1060 | 1062 | | |
1061 | | - | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
1062 | 1066 | | |
1063 | 1067 | | |
1064 | 1068 | | |
| |||
1166 | 1170 | | |
1167 | 1171 | | |
1168 | 1172 | | |
1169 | | - | |
| 1173 | + | |
1170 | 1174 | | |
1171 | 1175 | | |
1172 | 1176 | | |
| |||
1176 | 1180 | | |
1177 | 1181 | | |
1178 | 1182 | | |
1179 | | - | |
| 1183 | + | |
1180 | 1184 | | |
1181 | 1185 | | |
1182 | 1186 | | |
1183 | 1187 | | |
1184 | | - | |
| 1188 | + | |
1185 | 1189 | | |
1186 | 1190 | | |
1187 | 1191 | | |
| |||
1217 | 1221 | | |
1218 | 1222 | | |
1219 | 1223 | | |
1220 | | - | |
| 1224 | + | |
1221 | 1225 | | |
1222 | 1226 | | |
1223 | 1227 | | |
1224 | 1228 | | |
1225 | 1229 | | |
1226 | 1230 | | |
1227 | | - | |
| 1231 | + | |
1228 | 1232 | | |
1229 | 1233 | | |
1230 | | - | |
| 1234 | + | |
1231 | 1235 | | |
1232 | 1236 | | |
1233 | 1237 | | |
| |||
0 commit comments