Commit 1cb2f29
unpack_loose_rest(): rewrite return handling for clarity
We have a pattern like:
if (error1)
...handle error 1...
else if (error2)
...handle error 2...
else
...return buf...
...free buf and return NULL...
This is a little subtle because it is the return in the success block
that lets us skip the common error handling. Rewrite this instead to
free the buffer in each error path, marking it as NULL, and then all
code paths can use the common return.
This should make the logic a bit easier to follow. It does mean
duplicating the buf cleanup for errors, but it's a single line.
Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 547f719 commit 1cb2f29
1 file changed
+6
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1348 | 1348 | | |
1349 | 1349 | | |
1350 | 1350 | | |
1351 | | - | |
| 1351 | + | |
1352 | 1352 | | |
1353 | | - | |
| 1353 | + | |
| 1354 | + | |
1354 | 1355 | | |
1355 | 1356 | | |
1356 | | - | |
1357 | | - | |
| 1357 | + | |
| 1358 | + | |
1358 | 1359 | | |
1359 | | - | |
1360 | | - | |
| 1360 | + | |
1361 | 1361 | | |
1362 | 1362 | | |
1363 | 1363 | | |
| |||
0 commit comments