From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Leo Yan <leo.yan@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
James Clark <james.clark@linaro.org>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] coresight: stm: Remove redundant NULL checks
Date: Thu, 12 Jun 2025 10:48:59 +0530 [thread overview]
Message-ID: <28ccdeaa-865e-4e81-8a95-eaec9b2754ef@arm.com> (raw)
In-Reply-To: <20250611-arm_cs_fix_smatch_warning_v1-v1-1-02a66c69b604@arm.com>
On 11/06/25 8:14 PM, Leo Yan wrote:
> container_of() cannot return NULL, so the checks for NULL pointers are
> unnecessary and can be safely removed.
>
> As a result, this commit silences the following smatch warnings:
>
> coresight-stm.c:345 stm_generic_link() warn: can 'drvdata' even be NULL?
> coresight-stm.c:356 stm_generic_unlink() warn: can 'drvdata' even be NULL?
> coresight-stm.c:387 stm_generic_set_options() warn: can 'drvdata' even be NULL?
> coresight-stm.c:422 stm_generic_packet() warn: can 'drvdata' even be NULL?
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
> drivers/hwtracing/coresight/coresight-stm.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index e45c6c7204b4491e0f879bc7d5d445aa1d3118be..464b0c85c3f7d3519169d62a51e9f8c6281b5358 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -342,7 +342,7 @@ static int stm_generic_link(struct stm_data *stm_data,
> {
> struct stm_drvdata *drvdata = container_of(stm_data,
> struct stm_drvdata, stm);
> - if (!drvdata || !drvdata->csdev)
> + if (!drvdata->csdev)
> return -EINVAL;
>
> return coresight_enable_sysfs(drvdata->csdev);
> @@ -353,7 +353,7 @@ static void stm_generic_unlink(struct stm_data *stm_data,
> {
> struct stm_drvdata *drvdata = container_of(stm_data,
> struct stm_drvdata, stm);
> - if (!drvdata || !drvdata->csdev)
> + if (!drvdata->csdev)
> return;
>
> coresight_disable_sysfs(drvdata->csdev);
> @@ -384,7 +384,7 @@ static long stm_generic_set_options(struct stm_data *stm_data,
> {
> struct stm_drvdata *drvdata = container_of(stm_data,
> struct stm_drvdata, stm);
> - if (!(drvdata && coresight_get_mode(drvdata->csdev)))
> + if (!coresight_get_mode(drvdata->csdev))
> return -EINVAL;
>
> if (channel >= drvdata->numsp)
> @@ -419,7 +419,7 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
> struct stm_drvdata, stm);
> unsigned int stm_flags;
>
> - if (!(drvdata && coresight_get_mode(drvdata->csdev)))
> + if (!coresight_get_mode(drvdata->csdev))
> return -EACCES;
>
> if (channel >= drvdata->numsp)
>
Seems to be a sensible clean up.
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
next prev parent reply other threads:[~2025-06-12 5:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 14:44 [PATCH 0/2] coresight: Dismiss smatch warnings Leo Yan
2025-06-11 14:44 ` [PATCH 1/2] coresight: stm: Remove redundant NULL checks Leo Yan
2025-06-12 5:18 ` Anshuman Khandual [this message]
2025-06-12 8:28 ` Mike Leach
2025-06-12 9:19 ` Leo Yan
2025-06-11 14:44 ` [PATCH 2/2] coresight: perf: Use %px for printing pointers Leo Yan
2025-06-12 5:44 ` Anshuman Khandual
2025-06-12 9:11 ` Leo Yan
2025-07-10 12:35 ` [PATCH 0/2] coresight: Dismiss smatch warnings Suzuki K Poulose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28ccdeaa-865e-4e81-8a95-eaec9b2754ef@arm.com \
--to=anshuman.khandual@arm.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mike.leach@linaro.org \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.