Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751476AbbEZExG (ORCPT ); Tue, 26 May 2015 00:53:06 -0400 Received: from [212.69.189.236] ([212.69.189.236]:50342 "EHLO mail.hofr.at" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751180AbbEZExD (ORCPT ); Tue, 26 May 2015 00:53:03 -0400 Date: Tue, 26 May 2015 06:52:05 +0200 From: Nicholas Mc Guire To: Tejun Heo Cc: Nicholas Mc Guire , Li Zefan , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cgroup: add explicit cast and comment for return type conversion Message-ID: <20150526045205.GA13387@opentech.at> References: <1432472872-3578-1-git-send-email-hofrat@osadl.org> <20150524203528.GB7099@htj.duckdns.org> <20150525055742.GE1397@opentech.at> <20150525114045.GA526@htj.duckdns.org> <20150525115047.GA7413@opentech.at> <20150526000538.GH7099@htj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150526000538.GH7099@htj.duckdns.org> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1941 Lines: 41 On Mon, 25 May 2015, Tejun Heo wrote: > 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. > got it - not an issue for me - as noted I was not that sure how sensible it is either the point of this RFC was precisely to clarify this. Will mark those safe conversions as false-postives then and leave it as is. Thanks for the clarification! thx! hofrat -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/