[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXJAmwwKu_yUW_vjXhT64+QPyZsHpgqLtih6coQKqgOVC+0EA@mail.gmail.com>
Date: Mon, 1 Sep 2025 21:54:06 -0700
From: John Ousterhout <ouster@...stanford.edu>
To: Andrew Lunn <andrew@...n.ch>
Cc: Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org, edumazet@...gle.com,
horms@...nel.org, kuba@...nel.org
Subject: Re: [PATCH net-next v15 14/15] net: homa: create homa_plumbing.c
On Mon, Sep 1, 2025 at 4:03 PM Andrew Lunn <andrew@...n.ch> wrote:
>
> On Mon, Sep 01, 2025 at 03:53:35PM -0700, John Ousterhout wrote:
> > On Tue, Aug 26, 2025 at 9:17 AM Paolo Abeni <pabeni@...hat.com> wrote:
> >
> > > > + status = proto_register(&homa_prot, 1);
> > > > + if (status != 0) {
> > > > + pr_err("proto_register failed for homa_prot: %d\n", status);
> > > > + goto error;
> > > > + }
> > > > + init_proto = true;
> > >
> > > The standard way of handling the error paths it to avoid local flags and
> > > use different goto labels.
> >
> > I initially implemented this with different goto labels, but there
> > were so many different labels that the code became unmanageable (very
> > difficult to figure out what to change when adding or removing
> > initializers). The current approach is *way* cleaner and more obvious,
> > so I hope I can keep it. The label approach works best when there is
> > only one label that collects all errors.
>
> This _might_ mean you need to split it unto a number of helper
> function, with each helper using a goto, and the main function calling
> the helper also using goto when a helper returns an error code.
Unfortunately helpers don't help. There are already separate functions
for the individual initializations. The problem is with handling
errors in the parent. If a child returns an error, the parent must
reverse all of the initializations that completed before that child
was invoked, so error handling is slightly different for every child
invocation.
-John-
Powered by blists - more mailing lists