Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1969858ybl; Thu, 29 Aug 2019 01:28:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8gcTdgYiL2xnTIloWmDTl1JLB0Cw1LAsnpG8ngjQqN8eCNw1RL6yElIYlVpbDJHWxbaJb X-Received: by 2002:a17:902:1024:: with SMTP id b33mr8763885pla.325.1567067290832; Thu, 29 Aug 2019 01:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567067290; cv=none; d=google.com; s=arc-20160816; b=nAl3cjtbvQvIxpzF/Klt0IQQIXCmZPxpb6ib4zm6AkbuzTPVhkeLft22Fy6CkN+qwp hI1FJb8gbBY+wTzp0AF7d83BINH7anjJ+f9vS042zFns9JxiUil+GcelwHEXOn9fSdD/ 5fhMmPTJyiXNc+4W/Z//lFIeNeJIyEI7tx839Do5m8g5QScnYdXoaGUg8hO1Y+7aRh2i o6u1EEXZMWQMaP6QRjNXd5dCZYQd0Ms000dp9G3lV7P2LJLIixrG2mhWNbVDmwwIJs+N ZXWsOOgrrNrCJisExSmbRspWnZwzdaUyPOXa20xKCEV4vIYW+f0BhyWj+Yi3IatvsJFM uM4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Lc4OgMeJxeO58Duke2abfdQJf6k+AAyCDjOvHJwyPe4=; b=ORozoE2itOfferCFVxoutl274HzLYXxZxzddomO7/P8/KpIu0YWcYnzXo2lWDT8MBY 2G/j8NYBxyu2BNN7TtwjQg5lg4kzKOyMyVtHhsDY5S30lX58PE72hSKrRxFwjXxt7cVq PsnLu9KWtMETWpMkUeddXranhipueAZ1KPOp4AVcl/2eOFDlqFqGrAzsUVkDDizYaKVA nnUqUH+w1oW1dUaOs45IeVYq384jKZTfOj1ZrTmh4bb0tbbte2AxU73Nr1hTU0UfixRp 12W+DMRIoLseReIddksU87o2JmGocAVcfQwL/PEWXCkq2i1QDKPa9JPg8alDS3BeI827 6jYg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si1428888pgr.460.2019.08.29.01.27.56; Thu, 29 Aug 2019 01:28:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbfH2I1H (ORCPT + 99 others); Thu, 29 Aug 2019 04:27:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:34120 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725776AbfH2I1H (ORCPT ); Thu, 29 Aug 2019 04:27:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EFD47AFF9; Thu, 29 Aug 2019 08:27:05 +0000 (UTC) Subject: Re: [PATCH v2] vsprintf: introduce %dE for error constants To: Petr Mladek , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= Cc: Sergey Senozhatsky , Steven Rostedt , Andrew Morton , Jani Nikula , Jonathan Corbet , metux IT consult Enrico Weigelt , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190827211244.7210-1-uwe@kleine-koenig.org> <20190828113216.p2yiha4xyupkbcbs@pathway.suse.cz> <74303921-aa95-9962-2254-27e556af54f4@kleine-koenig.org> <20190829081249.3zvvsa4ggb5pfozl@pathway.suse.cz> From: Juergen Gross Message-ID: <45cd5b50-9854-fce7-5f08-f7660abb8691@suse.com> Date: Thu, 29 Aug 2019 10:27:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190829081249.3zvvsa4ggb5pfozl@pathway.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.08.19 10:12, Petr Mladek wrote: > On Wed 2019-08-28 21:18:37, Uwe Kleine-König wrote: >> Hello Petr, >> >> On 8/28/19 1:32 PM, Petr Mladek wrote: >>> On Tue 2019-08-27 23:12:44, Uwe Kleine-König wrote: >>>> Petr Mladek had some concerns: >>>>> There are ideas to make the code even more tricky to reduce >>>>> the size, keep it fast. >>>> >>>> I think Enrico Weigelt's suggestion to use a case is the best >>>> performance-wise so that's what I picked up. Also I hope that >>>> performance isn't that important because the need to print an error >>>> should not be so common that it really hurts in production. > > This is contadicting. The "best" performance-wise solution was > choosen in favor of space. The next sentence says that performance > is not important. > >>> I personally do not like switch/case. It is a lot of code. >>> I wonder if it even saved some space. >> >> I guess we have to die either way. Either it is quick or it is space >> efficient. > > I am more concerned about the size. Well, array of strings will > be both fast and size efficient. > >> With the big case I trust the compiler to pick something >> sensible expecting that it adapts for example to -Osize. > > I am not sure what are the expectations here. I can't imagine > another translation than: > > if (val == 1) > str = "EPERM"; > else if (val == 2) > str = "ENOENT" > else if (val == 3) > str = "ESRCH" > ... > > It means that all constans will be hardcoded in the code instead > of in data section. Plus there will be instructions for each > if/else part. > >>> If you want to safe space, I would use u16 to store the numbers. >>> Or I would use array of strings. There will be only few holes. >>> >>> You might also consider handling only the most commonly >>> used codes from errno.h and errno-base.h (1..133). There will >>> be no holes and the codes are stable. >> >> I'd like to postpone the discussion about "how" until we agreed about >> the "if at all". > > It seems that all people like this feature. Hmm, what about already existing format strings conatining "%dE"? Yes, I could find only one (drivers/staging/speakup/speakup_bns.c), but nevertheless... > > BTW: I though more about generating or cut&pasting the arrary. > I can't find any reasonable way how to generate it. Generate the array and errno.h/errno-base.h from the same source? Juergen