From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756997Ab1DOUv5 (ORCPT ); Fri, 15 Apr 2011 16:51:57 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:61655 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756988Ab1DOUvy (ORCPT ); Fri, 15 Apr 2011 16:51:54 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; b=PEdwd1C7/gIwxuv31kNZc/yR9hyTUMAWkfoxAqflQ59AhzWMhT/ciuG5HJXSj5eNeH KLXT8DMhXY0eOPt8QYSIoAeqCch4xkMKB7rVfqChj4Wq6xTe7ic3Sk3QZ7ajSFTYXq9d 4tBBpbiFw+eaDj5IKy13cqU2wnQ5wUNUFVVAg= Date: Fri, 15 Apr 2011 23:51:48 +0300 From: Alexey Dobriyan To: Michal Nazarewicz Cc: Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kstrtox: reuse functions from ctype.h Message-ID: <20110415205148.GA6132@p183> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 14, 2011 at 04:30:17PM +0200, Michal Nazarewicz wrote: > On Thu, 14 Apr 2011 16:06:34 +0200, Alexey Dobriyan > wrote: > >> @@ -47,8 +42,8 @@ static int _kstrtoull(const char *s, unsigned int > >> base, unsigned long long *res) > >> > >> if ('0' <= *s && *s <= '9') > >> val = *s - '0'; > >> - else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') > >> - val = _tolower(*s) - 'a' + 10; > >> + else if (isxdigit(*s)) > > > > [0-9] are isxdigit() as well, so the code sort of logically duplicate. > > Yes, so? ;) > > I think isxdigit(*s) looks nicer than “'a' <= _tolower(*s) && > _tolower(*s) <= 'f'”. If you write isxdigit(*s) you have to write some other expression for "val = " to be nicer. The point it's doesn't matter, compiler will optimize all those _tolower().