goto???

Martin Knappe kohaerenzstifter at posteo.de
Fri Jul 17 05:22:58 EDT 2015


I'm just messing ...
I guess I felt a bit challenged by your "try to write that without using 
goto"

I use goto myself very much for function cleanup. I wouldn't normally 
code the way I did in that snippet.

Apart from that, my general rule for any function is:

1) Only ONE return statement.
2) Only ONE cleanup label to goto in case of an error. Call that label 
"finish", ALWAYS.

Am 17.07.2015 11:13 schrieb Sudip Mukherjee:
> On Fri, Jul 17, 2015 at 2:18 PM, Martin Knappe
> <kohaerenzstifter at posteo.de> wrote:
>> Very easy:
> Looks good. :)
> But for me, now while reading the code I have to keep a note of the
> value of cleanupState variable and the error path becomes confusing.
> And besides in your opinion now which code is more readable, the 
> original
> code or this one?
> 
> regards
> sudip



More information about the Kernelnewbies mailing list