Skip to content

Commit 8a50571

Browse files
object-file: convert 'switch' back to 'if'
This switch statement was recently added to make it clear that unpack_loose_header() returns an enum value, not an int. This adds complications for future developers if that enum gains new values, since that developer would need to add a case statement to this switch for little real value. Instead, we can revert back to an 'if' statement, but make the enum explicit by using "!= ULHR_OK" instead of assuming it has the numerical value zero. Co-authored-by: Junio C Hamano <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c89855 commit 8a50571

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

object-file.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,12 +2623,8 @@ int read_loose_object(const char *path,
26232623
goto out;
26242624
}
26252625

2626-
switch (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
2627-
NULL)) {
2628-
case ULHR_OK:
2629-
break;
2630-
case ULHR_BAD:
2631-
case ULHR_TOO_LONG:
2626+
if (unpack_loose_header(&stream, map, mapsize, hdr, sizeof(hdr),
2627+
NULL) != ULHR_OK) {
26322628
error(_("unable to unpack header of %s"), path);
26332629
goto out;
26342630
}

0 commit comments

Comments
 (0)