[PATCH] component: replace ternary operator with min()

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

 



From: Jiangshan Yi <yijiangshan@xxxxxxxxxx>

Fix the following coccicheck warning:

drivers/base/component.c:544: WARNING opportunity for min().
drivers/base/component.c:740: WARNING opportunity for min().

min() macro is defined in include/linux/minmax.h. It avoids
multiple evaluations of the arguments when non-constant and performs
strict type-checking.

Signed-off-by: Jiangshan Yi <yijiangshan@xxxxxxxxxx>
---
 drivers/base/component.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 5eadeac6c532..349c54694481 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -541,7 +541,7 @@ int component_master_add_with_match(struct device *parent,
 
 	mutex_unlock(&component_mutex);
 
-	return ret < 0 ? ret : 0;
+	return min(ret, 0);
 }
 EXPORT_SYMBOL_GPL(component_master_add_with_match);
 
@@ -737,7 +737,7 @@ static int __component_add(struct device *dev, const struct component_ops *ops,
 	}
 	mutex_unlock(&component_mutex);
 
-	return ret < 0 ? ret : 0;
+	return min(ret, 0);
 }
 
 /**
-- 
2.25.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux