From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751854AbbEDOdY (ORCPT ); Mon, 4 May 2015 10:33:24 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:34971 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbbEDOdP (ORCPT ); Mon, 4 May 2015 10:33:15 -0400 From: Rasmus Villemoes To: Alexey Dobriyan Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/10] parse_integer: convert mm/ Organization: D03 References: <20150502004714.GA21655@p183.telecom.by> <20150502005535.GF21655@p183.telecom.by> X-Hashcash: 1:20:150504:akpm@linux-foundation.org::MqCaRiJhY7zRverg:0000000000000000000000000000000000001VM2 X-Hashcash: 1:20:150504:adobriyan@gmail.com::u5j/Azp1iP1pVlen:00000000000000000000000000000000000000000058MB X-Hashcash: 1:20:150504:linux-kernel@vger.kernel.org::JgzlIlX+nJ2wN8bo:0000000000000000000000000000000004dqa Date: Mon, 04 May 2015 16:33:12 +0200 In-Reply-To: <20150502005535.GF21655@p183.telecom.by> (Alexey Dobriyan's message of "Sat, 2 May 2015 03:55:35 +0300") Message-ID: <878ud4if9z.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 02 2015, Alexey Dobriyan wrote: > Convert mm/ directory away from deprecated simple_strto*() interface. > > One thing to note about parse_integer() and seemingly useless casts -- > range of accepted values depends on result type. > > int val; > parse_integer(s, 0, &val); > > will accept negative integers, while > > int val; > parse_integer(s, 0, (unsigned int *)&val); > > will accept only 0 and positive integers. ... and then silently write a negative value to val if the parsed integer happens to be larger than INT_MAX. Again, I think passing cast expressions to parse_integer should be verboten. In these particular cases: * memtest_pattern should just be unsigned int - it's only ever used as such anyway, and it represents a count. * hashdist should be a boolean, but even in its current form, there's no reason to not just use parse_integer as-is. If people like to set it by passing -42 just let them. Rasmus