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 Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux