Re: Why do we have both x*() and *_or_die() for "do or die"?
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- May 22, 2018, 18:38 UTC
- Message-ID
- <20180522183807.GK10623@aiede.svl.corp.google.com>
- In-Reply-To
- <CACsJy8BnsbOvz+iSz=9ug99Cs5Dm17Fgk65K2nXusBg0dML4xg@mail.gmail.com>
Duy Nguyen wrote:
> On Tue, May 22, 2018 at 7:49 PM, Ævar Arnfjörð Bjarmason > <avarab@gmail.com> wrote:
Show 8 quoted lines
>> Just a side-question unrelated to this patch per-se, why do we have both >> x*() and *_or_die() functions in the codebase? > > I wondered about that myself shortly after suggesting > repo_read_index_or_die(). My only guess is xfoo is better version of > foo, which sometimes involves dying inside but that's not the only > possible improvement. Later I guess people go with _or_die() more > because it describes what the function does much better.
In particular, there are functions like xwrite that don't die on error and write_or_die that do.
I'd probably be in favor of a series using cocinelle to rename the functions that do die on error to _or_die. The main case where I pause for a moment is xmalloc, since I'm worried about the verboseness of malloc_or_die, but I suspect I would get used to it.
Thanks, Jonathan