public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Benjamin MUGNIER <benjamin.mugnier@foss.st.com>
Cc: oe-kbuild@lists.linux.dev, lkp@intel.com,
	oe-kbuild-all@lists.linux.dev, linux-media@vger.kernel.org,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: Re: [sailus-media-tree:master 17/47] drivers/media/i2c/st-vgxy61.c:891 vgxy61_apply_gpiox_strobe_mode() warn: impossible condition '(reg < 0) => (0-u16max < 0)'
Date: Thu, 10 Nov 2022 16:11:59 +0300	[thread overview]
Message-ID: <Y2z4n8b+tEtzNR/4@kadam> (raw)
In-Reply-To: <fcb1fc9c-df59-aefd-93f7-9acd2df44f91@foss.st.com>

On Thu, Nov 10, 2022 at 12:43:30PM +0100, Benjamin MUGNIER wrote:
> After running smatch on my tree I couldn't reproduce this warning:
>   warn: pm_runtime_get_sync() also returns 1 on success
> I'm using the latest smatch cloned from github. Do you append some
> options to kchecker to get this output ?

TL;DR: Thanks for the report!  I will fix it later this week.

It's not really supposed to warn at all...  The pm_runtime_get_sync()
returns negatives on error so testing for "if (ret < 0) {" is correct
as a general case.  In this case it is wrong but normally it would be
the correct check.

This is an interaction with the check for uninitialized variables,
check_uninitialized.c.  A common false positive was caused by mismatches
where a function checks for if (ret) but the caller checks for
if (ret < 0) {.

int function(...)
{
	ret = frob();
	if (ret)
        ^^^^^^^^
		return ret;
	return 0;
}

int caller(...)
{
	ret = function();
	if (ret < 0) {
        ^^^^^^^^^^^^

How should positives be treated?  So what the check_uninitialized.c
check does is that it says, "let's assume that "ret >= 0" and "!ret"
are equivalent".  It creates a fake environment to test what !ret means
for uninitialized variables.  The check_pm_runtime_get_sync.c check sees
the "!ret" condition and says, "Nope.  That's supposed to be "ret < 0"".

Smatch shouldn't be printing warnings from inside the fake environment.

regards,
dan carpenter


  reply	other threads:[~2022-11-10 13:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  5:19 [sailus-media-tree:master 17/47] drivers/media/i2c/st-vgxy61.c:891 vgxy61_apply_gpiox_strobe_mode() warn: impossible condition '(reg < 0) => (0-u16max < 0)' Dan Carpenter
2022-11-10 11:43 ` Benjamin MUGNIER
2022-11-10 13:11   ` Dan Carpenter [this message]
2022-11-10 14:03     ` Dan Carpenter
2022-11-10 14:06       ` Dan Carpenter
2022-11-10 15:04         ` Benjamin MUGNIER
2022-11-10 15:33           ` 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=Y2z4n8b+tEtzNR/4@kadam \
    --to=error27@gmail.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=linux-media@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=sakari.ailus@linux.intel.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