From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752079AbbJEQDh (ORCPT ); Mon, 5 Oct 2015 12:03:37 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:38107 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbbJEQDg (ORCPT ); Mon, 5 Oct 2015 12:03:36 -0400 Date: Mon, 5 Oct 2015 18:03:31 +0200 From: Ingo Molnar To: Linus Torvalds Cc: Chris Metcalf , Thomas Gleixner , Peter Zijlstra , Borislav Petkov , open list , "H. Peter Anvin" Subject: Re: [PATCH] string: Improve the generic strlcpy() implementation Message-ID: <20151005160331.GA8387@gmail.com> References: <55F1DD53.1070102@ezchip.com> <20151005112700.GA1096@gmail.com> <20151005115355.GA27073@gmail.com> <20151005131524.GA807@gmail.com> <20151005143354.GB7478@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Linus Torvalds wrote: > So I don't think a "generic" range check helper can force types like > "unsigned long". Yeah. > That said, doing a simple > > git grep '<.*||.*>' > > does show that the "positive or non-zero ranges with constant range > limits" case is fairly common, and maybe we could have a macro that > does some magic compile-time checking that (a) the range really is a > compile-time constant and (b) that range is valid and (c) avoids the > comparison with zero if the expression to be tested is unsigned. > > So it is possible that we could enable type limit checking if we also > introduce a good way to not then create crap patches that actually > make the code more fragile or less readable. I'm not violently against > that. But I *am* violently against introducing that braindead warning > without very clear rules that we don't then have the mindless and > wrong changes to remove proper and obvious range checking and replace > it with "the expression is unsigned so we remove the nice readable > lower bounds check as unnecessary". Ok, and fully agreed. Thanks, Ingo