linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mike Leach <mike.leach@linaro.org>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Leo Yan <leo.yan@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	 James Clark <james.clark@linaro.org>,
	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 09:28:42 +0100	[thread overview]
Message-ID: <CAJ9a7ViTTVzXifBc0u_sB54Q71MDVk40=53TfK4OfXwy2vL3bg@mail.gmail.com> (raw)
In-Reply-To: <28ccdeaa-865e-4e81-8a95-eaec9b2754ef@arm.com>

On Thu, 12 Jun 2025 at 06:19, Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
>
>
> 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;
> >
I'd agree that the container_of() cannot return NULL, but what happens
if stm_data is NULL?
Perhaps the NULL check was on the wrong parameter?

Mike

> >       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>
>


-- 
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK


  reply	other threads:[~2025-06-12  9:51 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
2025-06-12  8:28     ` Mike Leach [this message]
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='CAJ9a7ViTTVzXifBc0u_sB54Q71MDVk40=53TfK4OfXwy2vL3bg@mail.gmail.com' \
    --to=mike.leach@linaro.org \
    --cc=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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).