Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3976758ybl; Mon, 26 Aug 2019 03:36:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWJ0fqTnbk6QaaRd4VRZzCwBZ9q37X9XlJwNQuKrN7PbLu9oMcumvB4CgKyawQl7sNGCJj X-Received: by 2002:a17:902:1a4:: with SMTP id b33mr2732714plb.141.1566815762786; Mon, 26 Aug 2019 03:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566815762; cv=none; d=google.com; s=arc-20160816; b=n35S23JeXSNUTo5CvkfIWiEmsVKOO0goOl0dO6F1MArc2MQSrfqnaUuIxGHbrtMtFo cAD94LEmxDiHFWQaeoeE62bons1Z4YMOEoUqXk9FdY/8EGac/Y4aFGcISsj60fGy7AFz bQSxmDZ/jUpSKtk8JEyIk/igOHDPltNcc9vFotzaXots2PwhDK/g4RAO8DwSuZijg+Zc Tlz2w8S4DqLTjA3JQWEprAu8IC+A0PVCLfb+KG6a8ByAs3vPqRG617g/hmzAQRrdfR+2 PSFaSDVUHfW1ow5gD+rUju0yT1nqbSwgfeJYQvCi1WJkXi0uCUGSGnCulOWg+1Gsg+MZ dubg== 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=f58vpwABOBh2MNQqFfaOOsgJksb7ft1/w6MmuYq9nes=; b=yEuTPPFA6WLT03cmGM7K1au8MsXedmyosXRgHp4puwYX1DJV0cDfWEP063ZMOid9jP bPGEn/wzf+IrDGmIDMQeGcXL4s46DtKZYRlVVmQoJlEeTeDSRcvuMWES7vSf+lOjZjgZ nLj7XNvt/D5PNLcL2HgN5GJxcGeOCUVih6kjnTyWRX8BhIVPiJJEe7cwMzgYw0AeGg5q KM5pYBQ7cChdgrgRnFx0pHaRQPWOU4n0sjgzEO9yVjx86mtUqNEAUW+lc2yGjYJ1tAmm hnUWUX53ckKxcyLPzjx/RS9quCG6xO8wbhYrR4q6qp6s0BUVTbPYUxsoMLxjBM6hb+Lg FG5g== 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 x6si9031749plm.396.2019.08.26.03.35.47; Mon, 26 Aug 2019 03:36:02 -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 S1731240AbfHZKE2 (ORCPT + 99 others); Mon, 26 Aug 2019 06:04:28 -0400 Received: from mga05.intel.com ([192.55.52.43]:9528 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731224AbfHZKE2 (ORCPT ); Mon, 26 Aug 2019 06:04:28 -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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Aug 2019 03:04:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,431,1559545200"; d="scan'208";a="197020346" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.150]) by fmsmga001.fm.intel.com with ESMTP; 26 Aug 2019 03:04:25 -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: <87o90c9rkc.fsf@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190824233724.1775-1-uwe@kleine-koenig.org> <20190824165829.7d330367992c62dab87f6652@linux-foundation.org> <87o90c9rkc.fsf@intel.com> Date: Mon, 26 Aug 2019 13:04:24 +0300 Message-ID: <87lfvg9r9z.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 Mon, 26 Aug 2019, Jani Nikula wrote: > 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. Meh, failed to notice the range ERESTARTSYS..ERECALLCONFLICT. Other than that, it's nicer. ;) BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center