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