Commit 547f719
unpack_loose_rest(): simplify error handling
Inflating a loose object is considered successful only if we got
Z_STREAM_END and there were no more bytes. We check both of those
conditions and return success, but then have to check them a second time
to decide which error message to produce.
I.e., we do something like this:
if (!error_1 && !error_2)
...return success...
if (error_1)
...handle error1...
else if (error_2)
...handle error2...
...common error handling...
This repetition was the source of a small bug fixed in an earlier commit
(our Z_STREAM_END check was not the same in the two conditionals).
Instead we can chain them all into a single if/else cascade, which
avoids repeating ourselves:
if (error_1)
...handle error1...
else if (error_2)
...handle error2....
else
...return success...
...common error handling...
Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 84b5c1a commit 547f719
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1347 | 1347 | | |
1348 | 1348 | | |
1349 | 1349 | | |
1350 | | - | |
1351 | | - | |
1352 | | - | |
1353 | 1350 | | |
1354 | 1351 | | |
1355 | 1352 | | |
1356 | 1353 | | |
1357 | 1354 | | |
1358 | 1355 | | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
1359 | 1359 | | |
1360 | 1360 | | |
1361 | 1361 | | |
| |||
0 commit comments