Re: [PATCH v6 07/16] merge-recursive: avoid returning a wholesale struct
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 4, 2016, 18:09 UTC
- Message-ID
- <xmqqk2fw4d8z.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <4cbe2757bd921a202c359382086fadeb2616434a.1470051326.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 10 quoted lines
> It is technically allowed, as per C89, for functions' return type to > be complete structs (i.e. *not* just pointers to structs). > > However, it was just an oversight of this developer when converting > Python code to C code in 6d297f8 (Status update on merge-recursive in > C, 2006-07-08) which introduced such a return type. > > Besides, by converting this construct to pass in the struct, we can now > start returning a value that can indicate errors in future patches. This > will help the current effort to libify merge-recursive.c.
I do not think returning a small struct by value is unconditionally a bad thing, but I do agree with you that this change makes the resulting code much easier to read, especially once this starts returning errors.
Good.