All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Nishanth Menon <nm@ti.com>
Cc: linux-rtc@vger.kernel.org
Subject: Re: [bug report] rtc: Introduce ti-k3-rtc
Date: Fri, 1 Jul 2022 07:43:26 +0300	[thread overview]
Message-ID: <20220701044325.GP11460@kadam> (raw)
In-Reply-To: <20220701014804.etabmwlyahsghrfx@lucrative>

On Thu, Jun 30, 2022 at 08:48:04PM -0500, Nishanth Menon wrote:
> 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?

Oh sorry.  I never published this warning.  :/

I generally don't like style checks because life is too short for style
debates.  But the real reason for this check is to find inverted
if (ret) checks.  So maybe I should publish it.  Inverted checks aren't
super common.

regards,
dan carpenter


      reply	other threads:[~2022-07-01  4:43 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
2022-07-01  4:43   ` Dan Carpenter [this message]

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=20220701044325.GP11460@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=linux-rtc@vger.kernel.org \
    --cc=nm@ti.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.