Re: [PATCH v3 10/12] usage: allow dying without writing an error message
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jun 3, 2025, 10:46 UTC
- Message-ID
- <aD7SoaRg4UV6ktJL@pks.im>
- In-Reply-To
- <CAOLa=ZQTYTNiUhFW+kOqMro0rpWVTkyKop7az_6h7zgM8njRhw@mail.gmail.com>
On Tue, Jun 03, 2025 at 11:04:56AM +0200, Karthik Nayak wrote:
Show 15 quoted lines
> On Tue, Jun 3, 2025 at 10:34 AM Kristoffer Haugsbakk > <kristofferhaugsbakk@fastmail.com> wrote: > > > > On Tue, Jun 3, 2025, at 10:31, Karthik Nayak wrote: > > > Patrick Steinhardt <ps@pks.im> writes: > > > > > >> Sometimes code wants to die in a situation where it already has written > > >> an error message. To use the same error code as `die()` we have to open > > >> code the code with a call to `exit(128)` in such cases, which is easy to > > > > > > Nit: This reads a little weird. > > > > Maybe s/to open code the code/to open-code the code/ > > Ah, that makes so much difference.
That reads better, but I guess we can improve it even further. How about this instead:
To retain the same error code as `die()` we have to use `exit(128)`,
which is easy to get wrong and leaves magical numbers all over our
codebase.Patrick