All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: remove unnecessary code
@ 2017-02-21  5:17 Gustavo A. R. Silva
  2017-02-21 17:40 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-02-21  5:17 UTC (permalink / raw)
  To: lgirdwood, broonie, support.opensource
  Cc: linux-kernel, Gustavo A. R. Silva, Peter Senna Tschudin

The name of an array used by itself will always return the array's address.
So it makes no sense to evaluate it, since the test will always evaluate as
true.

Addresses-Coverity-ID: 751412
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/regulator/da9055-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c
index d029c94..a118f63 100644
--- a/drivers/regulator/da9055-regulator.c
+++ b/drivers/regulator/da9055-regulator.c
@@ -612,7 +612,7 @@ static int da9055_regulator_probe(struct platform_device *pdev)
 	config.driver_data = regulator;
 	config.regmap = da9055->regmap;
 
-	if (pdata && pdata->regulators) {
+	if (pdata) {
 		config.init_data = pdata->regulators[pdev->id];
 	} else {
 		ret = da9055_regulator_dt_init(pdev, regulator, &config,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: remove unnecessary code
  2017-02-21  5:17 [PATCH] regulator: remove unnecessary code Gustavo A. R. Silva
@ 2017-02-21 17:40 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2017-02-21 17:40 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: lgirdwood, support.opensource, linux-kernel, Peter Senna Tschudin

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

On Mon, Feb 20, 2017 at 11:17:36PM -0600, Gustavo A. R. Silva wrote:
> The name of an array used by itself will always return the array's address.
> So it makes no sense to evaluate it, since the test will always evaluate as
> true.

> -	if (pdata && pdata->regulators) {
> +	if (pdata) {

This isn't actually helping anything, it just makes the code potentially
less robust if someone changes regulators to be allocated separately.
There's no cost to having the check in the code, the compiler should
notice if it's always true.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-21 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21  5:17 [PATCH] regulator: remove unnecessary code Gustavo A. R. Silva
2017-02-21 17:40 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.