Commit 2290e27
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 c4f75cc commit 2290e27
1 file changed
Lines changed: 15 additions & 11 deletions
| 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 | | |
| |||
1040 | 1042 | | |
1041 | 1043 | | |
1042 | 1044 | | |
1043 | | - | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1044 | 1048 | | |
1045 | 1049 | | |
1046 | 1050 | | |
| |||
1148 | 1152 | | |
1149 | 1153 | | |
1150 | 1154 | | |
1151 | | - | |
| 1155 | + | |
1152 | 1156 | | |
1153 | 1157 | | |
1154 | 1158 | | |
| |||
1158 | 1162 | | |
1159 | 1163 | | |
1160 | 1164 | | |
1161 | | - | |
| 1165 | + | |
1162 | 1166 | | |
1163 | 1167 | | |
1164 | 1168 | | |
1165 | 1169 | | |
1166 | | - | |
| 1170 | + | |
1167 | 1171 | | |
1168 | 1172 | | |
1169 | 1173 | | |
| |||
1199 | 1203 | | |
1200 | 1204 | | |
1201 | 1205 | | |
1202 | | - | |
| 1206 | + | |
1203 | 1207 | | |
1204 | 1208 | | |
1205 | 1209 | | |
1206 | 1210 | | |
1207 | 1211 | | |
1208 | 1212 | | |
1209 | | - | |
| 1213 | + | |
1210 | 1214 | | |
1211 | 1215 | | |
1212 | | - | |
| 1216 | + | |
1213 | 1217 | | |
1214 | 1218 | | |
1215 | 1219 | | |
| |||
0 commit comments