[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0480c38b2e164ab0c25aae2db628c221ea0da111.camel@perches.com>
Date: Sun, 26 Apr 2020 13:37:25 -0700
From: Joe Perches <joe@...ches.com>
To: Stephen Boyd <swboyd@...omium.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>
Cc: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>
Subject: Re: [PATCH 5/5] coresight: Avoid casting void pointers
On Sun, 2020-04-26 at 11:58 -0700, Stephen Boyd wrote:
> We don't need to cast void pointers, such as the amba_id data. Assign to
> a local variable to make the code prettier and also return NULL instead
> of 0 to make sparse happy.
[]
> diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
[]
> @@ -206,9 +206,12 @@ cti_remove_assoc_from_csdev(struct coresight_device *csdev) {}
> /* extract the data value from a UCI structure given amba_id pointer. */
> static inline void *coresight_get_uci_data(const struct amba_id *id)
> {
> - if (id->data)
> - return ((struct amba_cs_uci_id *)(id->data))->data;
> - return 0;
> + struct amba_cs_uci_id *uci_id = id->data;
> +
> + if (uci_id)
> + return id->data;
Missing one more level of indirection here yes?
return uci_id->data;
> +
> + return NULL;
> }
And this code would generally be written to return the expected
value at the bottom of the function and any unusual return
early like:
static inline void *coresight_get_uci_data(const struct amba_id *id)
{
struct amba_cs_uci_id *uci_id = id->data;
if (!uci_id)
return NULL;
return uci_id->data;
}
Powered by blists - more mailing lists