Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3973555ybl; Mon, 26 Aug 2019 03:33:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnSBPOKi1Nl9TpgR7gXY9oxb88dXLhm8/CmV3c5isRu+yDPYIpoAMKtOMj9RQFSvLUFzrw X-Received: by 2002:a17:90a:21c1:: with SMTP id q59mr18443523pjc.6.1566815581185; Mon, 26 Aug 2019 03:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566815581; cv=none; d=google.com; s=arc-20160816; b=aeLxe4Pv7u9U9S5qcrDAOL+H9cGDsChL4RSe2StZtXmdJHIiMwDrPJ2RHeIxI6eDs/ ePKgQOc3SORHMKIanCDOYhF8iDQiyXfhsqrI0eefwcsRngjNd3kRKBJDHgT4mDcL/d4o yEhlKMx0x5Xs4SbGkDtpNcrHvYh9vDEvlhP/sR1rQo1uC2tl3FYC4FXtzqfHfETRNtDk 3L7rZsyxXpe7JuzUIYYLdcT+qa/7JIvqbQLyo6K9Zhp1jIYA/X122eMyZUDdYLpgD66k Vk+ZnkYXwe+8XOpqQPB5T3gOW9PQIiX/nt07uK04Cn51exZX2FqHvtMBdS5ex26U24Uv oK0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=yi9Dvq9+/9la+8EQ2n69UHrmDi6X2op8ueS0pLhRapo=; b=dnB5utvdR23CgRufFtBwsFKv4T20Xq2mA9RmhNznjV8ZlOpQ3VgULvCzkjeGXA9+2O GTdKcYNxE26wBtBDFkPnU2ufaWh9xYnZTx1mywCdFhjtNqje1m7K/VZI+Z4CBzOJsmmn EtY+qRxPSWtbNc/1o1LuJ3p1xqcoEKHUTD02kWy609U/ISKNVmUY+8Zy5P2K0FTZDIdY zu8KeUpV28rbZ0I9NTc1QGZUOV9gel31pM/dxrIz4wA6V1TLmm83hs0kLQkoEhYSpDfI F3dQYJmZgL4C+IVVo7vDqPSjrYV7Cah9hvlWR0xq9yzDGgj/cMuuzMLl6YLhwBNr4JTL dF0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si45327pll.248.2019.08.26.03.32.45; Mon, 26 Aug 2019 03:33:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731176AbfHZJ6Q (ORCPT + 99 others); Mon, 26 Aug 2019 05:58:16 -0400 Received: from mga14.intel.com ([192.55.52.115]:49016 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730338AbfHZJ6P (ORCPT ); Mon, 26 Aug 2019 05:58:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Aug 2019 02:58:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,431,1559545200"; d="scan'208";a="197019323" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.150]) by fmsmga001.fm.intel.com with ESMTP; 26 Aug 2019 02:58:12 -0700 From: Jani Nikula To: Andrew Morton , Uwe =?utf-8?Q?Kleine-K?= =?utf-8?Q?=C3=B6nig?= Cc: Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , Petr Mladek , Sergey Senozhatsky , Steven Rostedt Subject: Re: [PATCH v1 1/2] vsprintf: introduce %dE for error constants In-Reply-To: <20190824165829.7d330367992c62dab87f6652@linux-foundation.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190824233724.1775-1-uwe@kleine-koenig.org> <20190824165829.7d330367992c62dab87f6652@linux-foundation.org> Date: Mon, 26 Aug 2019 12:58:11 +0300 Message-ID: <87o90c9rkc.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 24 Aug 2019, Andrew Morton wrote: >> --- a/lib/vsprintf.c >> +++ b/lib/vsprintf.c >> @@ -533,6 +533,192 @@ char *number(char *buf, char *end, unsigned long long num, >> return buf; >> } >> >> +#define ERRORCODE(x) { .str = #x, .err = x } >> + >> +static const struct { >> + const char *str; >> + int err; >> +} errorcodes[] = { > > It's a bit of a hack, but an array of char*'s and a separate array of > ushorts would save a bit of space. Or just #define ERRORCODE(x) [x] = #x static const char * const errorcodes[] = { ERRORCODE(EPERM), ERRORCODE(ENOENT), ... }; Saves space, faster lookup, discovers at build time why EWOULDBLOCK would always show up as EAGAIN in the logs. We don't have holes to speak of in the error codes. BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center