Re: [PATCH 2/7] object.c: make type_from_string() return "enum object_type"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 8, 2021, 21:48 UTC
- Message-ID
- <xmqq1rcp5nbk.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20210308200426.21824-3-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 7 quoted lines
> Change the type_from_string*() functions to return an "enum > object_type", and refactor their callers to check for "== OBJ_BAD" > instead of "< 0". > > This helps to distinguish code in object.c where we really do return > -1 from code that returns an "enum object_type", whose OBJ_BAD happens > to be -1.
"We will be adding different error modes and the plan is to signal them by returning negative values other than -1" would make sense (if that is what we are going to see in the remainder of the series), but not the above.
To the callees, what comes back from a function is -1 either way, and they cannot tell -1 resulting from OBJ_BAD and -1 resulting from error() apart, can they?