Re: [PATCH 2/2] media: staging: atomisp: Removed else branch in function

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

 



On Tue, 2020-10-06 at 21:04 +0300, Dan Carpenter wrote:
> Code should generally do "error handling" instead of "success handling".

Maybe something to add to coding-style
(in '6} Functions' maybe?)...

> That way the success path is always indented one tab and the error path
> is indented two tabs.  I like to say that the call and the error handling
> are part of the same thing, but with success handling, it's like
> do the call, do more stuff, go back to the error handling from the
> earlier call.
[]
> Anyway, TLDR, please write it like this:
> 
> 	if (on == 0)
>  		return power_down(sd);
> 
> 	ret = power_up(sd);
> 	if (ret)
> 		return ret;
> 
> 	return gc0310_init(sd);

Much nicer, thanks for taking the time to write it.






[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux