[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240925093538.GZ275077@black.fi.intel.com>
Date: Wed, 25 Sep 2024 12:35:38 +0300
From: Mika Westerberg <mika.westerberg@...ux.intel.com>
To: Markus Elfring <Markus.Elfring@....de>
Cc: linux-usb@...r.kernel.org, Andreas Noever <andreas.noever@...il.com>,
Michael Jamet <michael.jamet@...el.com>,
Yehezkel Bernat <YehezkelShB@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] thunderbolt: Use common error handling code in
update_property_block()
On Wed, Sep 25, 2024 at 11:20:45AM +0200, Markus Elfring wrote:
> >> out_unlock:
> >> mutex_unlock(&xd->lock);
> >> mutex_unlock(&xdomain_lock);
> >> + return;
> >> +
> >> +out_free_dir:
> >> + tb_property_free_dir(dir);
> >> + goto out_unlock;
> >
> > No way, this kind of spaghetti is really hard to follow.
>
> Under which circumstances would you follow advice more from the section
> “7) Centralized exiting of functions” (according to a well-known information source)?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.11#n526
>
> How do you think about to increase the application of scope-based resource management?
It is fine to use goto as it is described in the document you linked but
this what you are doing is certainly not fine, at least in the code I'm
maintaining:
out_unlock:
mutex_unlock(&xd->lock);
mutex_unlock(&xdomain_lock);
return;
out_free_dir:
tb_property_free_dir(dir);
goto out_unlock;
This "goto out_unlock" adds another goto to upwards which makes it
really hard to follow because the flow is not anymore just downwards.
Powered by blists - more mailing lists