[PATCH v1 14/14] extcon: Use positive conditional in ternary operator

Andy Shevchenko posted 14 patches 3 years ago
There is a newer version of this series
[PATCH v1 14/14] extcon: Use positive conditional in ternary operator
Posted by Andy Shevchenko 3 years ago
It's easier to parse by a human being the positive conditional.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index edfa0450e605..3e8522d522b4 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1466,7 +1466,7 @@ EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
  */
 const char *extcon_get_edev_name(struct extcon_dev *edev)
 {
-	return !edev ? NULL : edev->name;
+	return edev ? edev->name : NULL;
 }
 EXPORT_SYMBOL_GPL(extcon_get_edev_name);
 
-- 
2.40.0.1.gaa8946217a0b
Re: [PATCH v1 14/14] extcon: Use positive conditional in ternary operator
Posted by Chanwoo Choi 3 years ago
On 23. 3. 22. 23:40, Andy Shevchenko wrote:
> It's easier to parse by a human being the positive conditional.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/extcon/extcon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
> index edfa0450e605..3e8522d522b4 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1466,7 +1466,7 @@ EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
>   */
>  const char *extcon_get_edev_name(struct extcon_dev *edev)
>  {
> -	return !edev ? NULL : edev->name;
> +	return edev ? edev->name : NULL;
>  }
>  EXPORT_SYMBOL_GPL(extcon_get_edev_name);
>  

It is not fix-up patch and I'm not sure that it is beneficial patch. 
I will not apply it.

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi
Re: [PATCH v1 14/14] extcon: Use positive conditional in ternary operator
Posted by Andy Shevchenko 3 years ago
On Mon, Apr 03, 2023 at 11:38:41PM +0900, Chanwoo Choi wrote:
> On 23. 3. 22. 23:40, Andy Shevchenko wrote:
> > It's easier to parse by a human being the positive conditional.

...

> >  const char *extcon_get_edev_name(struct extcon_dev *edev)
> >  {
> > -	return !edev ? NULL : edev->name;
> > +	return edev ? edev->name : NULL;
> >  }
> >  EXPORT_SYMBOL_GPL(extcon_get_edev_name);
> 
> It is not fix-up patch and I'm not sure that it is beneficial patch.
> I will not apply it.

It improves the cognitive perception of the code, but I'm fine with
no patch being applied.

-- 
With Best Regards,
Andy Shevchenko