On Mon, Aug 18, 2025 at 04:00:44PM -0700, Linus Torvalds wrote: > Now, I don't advocate 'goto' as a general programming model, but for > exception handling it's superior to any alternative I know of. > > Exceptions simply DO NOT NEST, and 'try-catch-finally' is an insane > model for exceptions that has only made things worse both for > compilers and for programmers. > > So I do think using labels (without any crazy attempt nesting syntax) > is objectively the superior model. > > And the 'finally' mess is much better handled by compilers dealing > with cleanup - again without any pointless artificial nesting > structures. I think most of our <linux/cleanup.h> models have been > quite successful. I'm still rather cautious about the uses related to locks - it's very easy to overextend the area where lock is held (witness the fs/namespace.c bugs of the "oops, that should've been scoped_guard(), not guard()" variety - we had several this year) and "grab lock, except it might fail" stuff appears to be all awful - when macro is supposed to be used like scoped_cond_guard(lock_timer, return -EINVAL, _id) (hidden in the bowels of another macro, no less)... I'm still trying to come up with something edible for lock_mount() - the best approximation I've got so far is CLASS(lock_mount, mp)(path); if (IS_ERR(mp.mp)) bugger off ... with things like do_add_mount() avoiding the IS_ERR(...) part by starting with if (IS_ERR(mp)) return PTR_ERR(mp); With that we get e.g. CLASS(lock_mount, mp)(mountpoint); error = do_add_mount(real_mount(mnt), mp.mp, mountpoint, mnt_flags); if (!error) // mnt is consumed by successful do_add_mount() retain_and_null_ptr(mnt); return error; but it takes some massage to get there...