On Mon, May 10, 2021 at 07:18:14AM -0600, Edmundo Carmona Antoranz wrote: > On Sun, May 9, 2021 at 11:40 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> > wrote: > > > > > The best way to write error handling is "free the last resource style" > > where you free the most recent resouce that was successfully allocated. > > That way in your head you just have to keep track of one thing, instead > > of tracking everything. > > > > IC. So the answer is rather: single place to free stuff? Yes..... _but_ in > a layered fashion (through tags) instead of having a single tag to take > care of everything. > > Follow up question: is it worth making a patch to try to simplify a > function to have error handling set up this way for code that is already > working? Or not really? > No, absolutely not. This is just my preference and probably the most common way to write error handling but it's not an official standard. Plus it super easy to find error handling code which is not working and fix that instead. regards, dan carpenter