From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 770CA2C for ; Fri, 12 Aug 2016 04:07:13 +0000 (UTC) Received: from mail-ua0-f194.google.com (mail-ua0-f194.google.com [209.85.217.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E372B8B for ; Fri, 12 Aug 2016 04:07:12 +0000 (UTC) Received: by mail-ua0-f194.google.com with SMTP id 109so1187463uat.2 for ; Thu, 11 Aug 2016 21:07:12 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20160812040155.kvw5322jqshtmljb@x> References: <87inw1skws.fsf@x220.int.ebiederm.org> <25598.1469113525@warthog.procyon.org.uk> <18158a39-1297-7368-3c0e-3e9b3ce2c3ab@suse.com> <20160811154429.GB4134@mwanda> <20160812040155.kvw5322jqshtmljb@x> From: Matthew Wilcox Date: Fri, 12 Aug 2016 00:07:11 -0400 Message-ID: To: Josh Triplett Content-Type: multipart/alternative; boundary=001a114dd64056cb850539d804f2 Cc: Dan Carpenter , ksummit-discuss@lists.linuxfoundation.org Subject: Re: [Ksummit-discuss] [CORE TOPIC] More useful types in the linux kernel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --001a114dd64056cb850539d804f2 Content-Type: text/plain; charset=UTF-8 On Aug 11, 2016 9:02 PM, "Josh Triplett" wrote: > On Thu, Aug 11, 2016 at 11:51:52PM -0400, Matthew Wilcox wrote: > > 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. > > I'd love to see an explicit type distinct from "int" for "potentially an > errno". And if any code uses "potentially an errno *or* a non-errno > non-zero return value", that should ideally use a distinct type as well. I think the biggest problem is coming up with good names for the types. And the churn of introducing them, particularly converting function pointers and all occurrences. --001a114dd64056cb850539d804f2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Aug 11, 2016 9:02 PM, "Josh Triplett" <josh@joshtriplett.org> wrote: > On Thu, Aug 11, 2016 at 11:51:52PM -0400, Matthew Wilcox wrote:
> > Can we introduce types for this? We have a number of different re= turn 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 bein= g
> > potentially useful to smatch.
>
> I'd love to see an explicit type distinct from "int" for= "potentially an
> errno".=C2=A0 And if any code uses "potentially an errno *or= * a non-errno
> non-zero return value", that should ideally use a distinct type a= s well.

I think the biggest problem is coming up with good names for= the types. And the churn of introducing them, particularly converting func= tion pointers and all occurrences.

--001a114dd64056cb850539d804f2--