Re: [greybus-dev] [PATCH 1/8] driver core: Add helper for accessing Power Management callbacs

From
Krzysztof Wilczyński <hidden>
Date
2020-05-26 15:01:27
Also in
linux-acpi, linux-pci, linux-pm, linux-s390, linux-scsi, linux-usb
Reply to
Alex Elder, 2020-05-26
Hello Alex and Greg,

[...]
This could just be:

	if (drv)
		return drv->pm;

	return NULL;

Or if you want to evoke passion in Greg:

	return drv ? drv->pm : NULL;

					-Alex
quoted
I hate ? : lines with a passion, as they break normal pattern mattching
in my brain.  Please just spell this all out:
	if (drv && drv->pm)
		return drv->pm;
	return NULL;

Much easier to read, and the compiler will do the exact same thing.

Only place ? : are ok to use in my opinion, are as function arguments.
I will steer away from the ternary operator next time.  Also, good to
learn about Greg's preference.

Thank you both!

Krzysztof
Thread (26 messages) 26 messages, 7 authors, last reply 2020-05-26
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help