All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <linux-rtc@vger.kernel.org>
Subject: Re: [bug report] rtc: Introduce ti-k3-rtc
Date: Thu, 30 Jun 2022 20:48:04 -0500	[thread overview]
Message-ID: <20220701014804.etabmwlyahsghrfx@lucrative> (raw)
In-Reply-To: <YrqmHSiHfLJegA4v@kili>

Hi Dan,
On 09:56-20220628, Dan Carpenter wrote:
> Hello Nishanth Menon,
> 
> The patch b09d633575e5: "rtc: Introduce ti-k3-rtc" from Jun 23, 2022,
> leads to the following Smatch static checker warning:
> 
> 	drivers/rtc/rtc-ti-k3.c:186 k3rtc_unlock_rtc()
> 	info: return a literal instead of 'ret'
> 
> drivers/rtc/rtc-ti-k3.c
>     180 static int k3rtc_unlock_rtc(struct ti_k3_rtc *priv)
>     181 {
>     182         int ret;
>     183 
>     184         ret = k3rtc_check_unlocked(priv);
>     185         if (!ret)
> --> 186                 return ret;
> 
> It look more intentional when code uses literals:
> 
> 	if (!ret)
> 		return 0;
> 
> The k3rtc_check_unlocked() function can also return error codes so maybe
> this should be:
> 
> 	if (ret <= 0)
> 		return 0;

Interesting for a couple of reasons:
a) yep - if ret was < 0, driver does'nt anticipate that from regmap
   op(unless something really bad happened), so it warn_once
   the information and does continue as if nothing happened.. So, yep, I
   could potentially do <=0 and document the rationale - might be better
   to return ret instead of 0 though. I can send a patch if you agree.
b) How do i reproduce the warning that you reported?

I have been trying to reproduce the check (so that I don't get more
reports) and I am probably missing something obvious (using
https://repo.or.cz/smatch.git and hints from
Documentation/driver-api/media/maintainer-entry-profile.rst):
$ git describe
next-20220630

$ rm drivers/rtc/rtc-ti-k3.o; make CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=arm64 -j1 CHECK=/tmp/x C=2 drivers/rtc/rtc-ti-k3.o
  CHECK   scripts/mod/empty.c
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHECK   arch/arm64/kernel/vdso/vgettimeofday.c
  CC      drivers/rtc/rtc-ti-k3.o
  CHECK   drivers/rtc/rtc-ti-k3.c

$ cat /tmp/x
#!/bin/bash
/tmp/sm/bin/smatch -p=kernel $@
$ /tmp/sm/bin/smatch --version
v0.5.0-8047-g2aeb55346b81
$ cd /tmp/smatch
/tmp/smatch$ git describe
v0.5.0-8047-g2aeb55346b81
$ CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=arm64 /tmp/smatch/smatch_scripts/kchecker drivers/rtc/rtc-ti-k3.c
  SYNC    include/generated/autoconf.h
  CHECK   scripts/mod/empty.c
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHECK   arch/arm64/kernel/vdso/vgettimeofday.c
  CC      drivers/rtc/rtc-ti-k3.o
  CHECK   drivers/rtc/rtc-ti-k3.c
$ aarch64-none-linux-gnu-gcc --version
aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

  reply	other threads:[~2022-07-01  1:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  6:56 [bug report] rtc: Introduce ti-k3-rtc Dan Carpenter
2022-07-01  1:48 ` Nishanth Menon [this message]
2022-07-01  4:43   ` Dan Carpenter

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=20220701014804.etabmwlyahsghrfx@lucrative \
    --to=nm@ti.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-rtc@vger.kernel.org \
    /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.