From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934233AbbEMMTH (ORCPT ); Wed, 13 May 2015 08:19:07 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:34480 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933933AbbEMMTE (ORCPT ); Wed, 13 May 2015 08:19:04 -0400 MIME-Version: 1.0 In-Reply-To: <20150510135203.GC1717@p183.telecom.by> References: <20150508182911.GA9044@p183.telecom.by> <20150508183029.GB9044@p183.telecom.by> <20150508134646.6b9bf4158d220b65c5a922f9@linux-foundation.org> <20150510135203.GC1717@p183.telecom.by> Date: Wed, 13 May 2015 15:19:03 +0300 Message-ID: Subject: Re: [PATCH 02/12] Add parse_integer() (replacement for simple_strto*()) From: Alexey Dobriyan To: Andrew Morton , Noel Grandin Cc: Linux Kernel , Rasmus Villemoes Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Answering to Noel Grandin, gmane sent email to list only] > > int parse_integer(const char *s, unsigned int base, T *val); > > > > I suspect splitting this into > parse_signed_int > and > parse_unsigned_int > (or some other equivalent names) > will make the call-sites a lot easier to read. parse_integer() is about two and only two points (everything else is immaterial and technical details): 1) unified interface, 2) automatically fixing overflow bug based on type T. Two interfaces in this situation is no different from having four. C doesn't have generic functions so programmers get hardwired to million of names all doing roughly the same but __b_c_e and _Generic allows to mimic generic functions which is at least something.