Linux cgroups development
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Nicholas Mc Guire <der.herr-kA1LtwSENNE@public.gmane.org>
Cc: Nicholas Mc Guire
	<hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>,
	Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] cgroup: add explicit cast and comment for return type conversion
Date: Mon, 25 May 2015 20:05:38 -0400	[thread overview]
Message-ID: <20150526000538.GH7099@htj.duckdns.org> (raw)
In-Reply-To: <20150525115047.GA7413-AxMHDufBahDk7+2FdBfRIA@public.gmane.org>

Hello, Nicholas.

On Mon, May 25, 2015 at 01:50:47PM +0200, Nicholas Mc Guire wrote:
> that would be no benefit of course - the goal is not to simply put casts
> in but to use casts as last resort if type cleanups are not doable or if
> the type missmatch is intended - the cast then should document that it
> is intentional and comments explain why it is justified. If that were the
> result of type cleanup I think it would benefit the kernel code as I 
> suspect that quite a few of the type missmatches simply happened.

I'm having a bit of hard time agreeing with the utility of this.  If
you can fix up the variable type to go away, sure, but adding
unnecessary explicit cast and comment for something this trivial?  I'm
not sure.  I mean, C is not a language which can propagate param
constraints to the return types.  e.g. strnlen() will happily return
size_t even when the maximum length is e.g. int.  We simply aren't
writing in a language where these things are easily distinguished and
I'm not sure shoehorning explicit constraints all over the source code
brings enough benefit to justify the added noise.

If you can identify actual problem cases, awesome.  If some can easily
be removed by tweaking types to match the actual usage, great too, but
let's please not do this explicit version of implicit casts and
pointless comments.

Thanks.

-- 
tejun

  parent reply	other threads:[~2015-05-26  0:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-24 13:07 [PATCH] cgroup: add explicit cast and comment for return type conversion Nicholas Mc Guire
     [not found] ` <1432472872-3578-1-git-send-email-hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
2015-05-24 20:35   ` Tejun Heo
     [not found]     ` <20150524203528.GB7099-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2015-05-25  5:57       ` Nicholas Mc Guire
     [not found]         ` <20150525055742.GE1397-AxMHDufBahDk7+2FdBfRIA@public.gmane.org>
2015-05-25 11:40           ` Tejun Heo
     [not found]             ` <20150525114045.GA526-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2015-05-25 11:50               ` Nicholas Mc Guire
     [not found]                 ` <20150525115047.GA7413-AxMHDufBahDk7+2FdBfRIA@public.gmane.org>
2015-05-26  0:05                   ` Tejun Heo [this message]
     [not found]                     ` <20150526000538.GH7099-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2015-05-26  4:52                       ` Nicholas Mc Guire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150526000538.GH7099@htj.duckdns.org \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=der.herr-kA1LtwSENNE@public.gmane.org \
    --cc=hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox