Commit 194db7c
committed
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. This improves the
range from 2^31 already.
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>1 parent 49b6afa commit 194db7c
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 | | |
| |||
1060 | 1062 | | |
1061 | 1063 | | |
1062 | 1064 | | |
1063 | | - | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
1064 | 1068 | | |
1065 | 1069 | | |
1066 | 1070 | | |
| |||
1168 | 1172 | | |
1169 | 1173 | | |
1170 | 1174 | | |
1171 | | - | |
| 1175 | + | |
1172 | 1176 | | |
1173 | 1177 | | |
1174 | 1178 | | |
| |||
1178 | 1182 | | |
1179 | 1183 | | |
1180 | 1184 | | |
1181 | | - | |
| 1185 | + | |
1182 | 1186 | | |
1183 | 1187 | | |
1184 | 1188 | | |
1185 | 1189 | | |
1186 | | - | |
| 1190 | + | |
1187 | 1191 | | |
1188 | 1192 | | |
1189 | 1193 | | |
| |||
1211 | 1215 | | |
1212 | 1216 | | |
1213 | 1217 | | |
1214 | | - | |
| 1218 | + | |
1215 | 1219 | | |
1216 | 1220 | | |
1217 | 1221 | | |
1218 | 1222 | | |
1219 | 1223 | | |
1220 | 1224 | | |
1221 | | - | |
| 1225 | + | |
1222 | 1226 | | |
1223 | 1227 | | |
1224 | | - | |
| 1228 | + | |
1225 | 1229 | | |
1226 | 1230 | | |
1227 | 1231 | | |
| |||
0 commit comments