Re: [PATCH] thunderbolt: Use common error handling code in update_property_block()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux