Re: [PATCH] regulator: da9052: remove null pointer check on array pdata->regulators

From: Mark Brown
Date: Mon Sep 12 2016 - 19:52:01 EST


On Thu, Sep 08, 2016 at 11:07:36AM +0100, Colin King wrote:

> pdata->regulators is an array of DA9052_MAX_REGULATORS struct
> regulator_init_data pointers hence cannot be null, so the null pointer
> check on pdata->regulators is redundant. Remove it.

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

What is the benefit of this change? Due to the way C handles arrays and
pointers one can't immediately tell without opening up the header file
if regulators is a pointer to an array or an embedded array so it's more
work to read and since this is the probe path it's unlikely to be a
meaningful speed improvement even if the compiler doesn't figure it out
at build time.

Attachment: signature.asc
Description: PGP signature