On Aug 11, 2016 8:44 AM, "Dan Carpenter" <dan.carpenter@oracle.com> wrote:
> I need these manual fixes when not knowing the error code causes
> problems because a function does this:
> if (ret)
> return ret;
> But the caller does:
> if (ret < 0)
> return ret;
> There is a mismatch because Smatch thinks any non-zero is an error but
> the caller knows only negatives are errors.
Can we introduce types for this? We have a number of different return type conventions in the kernel:
bool
errno_t (-4095 to 0 are valid)
count_t (-4095 to INT_MAX)
long_count_t (-4095 to LONG_MAX)
ulong_count_t (-4095 to -4096)
struct foo _err*
I think this is good programmer documentation in addition to being potentially useful to smatch.