Re: [PATCH v4 5/5] ref-filter: get_ref_atom_value() error handling
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 20, 2018, 22:30 UTC
- Message-ID
- <xmqqh8paqt0f.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CAPig+cSxGgG=1k95j+n4DZHBdtN++7F6_U5fu0gOcjwwPQ5GZw@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 17 quoted lines
> Overall, with the need for resource cleanup, this function becomes
> unusually noisy after this change. It could be tamed by doing
> something like this:
>
> int ret = 0;
> void *buf = get_obj(oid, obj, &size, &eaten);
> if (!buf)
> ret = strbuf_error(_("missing object %s for %s"),
> oid_to_hex(oid), ref->refname);
> else if (!*obj)
> ret = strbuf_error(_("parse_object_buffer failed on %s for %s"),
> oid_to_hex(oid), ref->refname);
> else
> grab_values(ref->value, deref, *obj, buf, size);
> if (!eaten)
> free(buf);
> return ret;I have no idea what strbuf_error() that does not take any strbuf is doing, but I think you can initialize ret to -1 (i.e. assume the worst at the beginning), and then make the "ok, we didn't get any errors" case do
else {
grab_values(...);
ret = 0;
}