[Ksummit-discuss] [CORE TOPIC] More useful types in the linux kernel
Matthew Wilcox
willy6545 at gmail.com
Fri Aug 12 03:51:52 UTC 2016
On Aug 11, 2016 8:44 AM, "Dan Carpenter" <dan.carpenter at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/ksummit-discuss/attachments/20160811/8073ddb0/attachment.html>
More information about the Ksummit-discuss
mailing list