Received: by 10.223.176.5 with SMTP id f5csp1354209wra; Wed, 7 Feb 2018 18:04:57 -0800 (PST) X-Google-Smtp-Source: AH8x22752lv2DAI87I1Mn0TWmJNTUbBWPkkAgCq0vqObUs+Qd2yHIf7mewUMCoD0F0SkhCbHyMJt X-Received: by 2002:a17:902:bc3:: with SMTP id 61-v6mr7846808plr.407.1518055496923; Wed, 07 Feb 2018 18:04:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518055496; cv=none; d=google.com; s=arc-20160816; b=hki8uzjbg2Na7oRvVjBIsio9Hjs+JIvBiD2ijQpXMp6rsQzuSZbyYdLdJ23OWzryae ExzGg8N0ujuskfEdyT4sZipBxzsKsjLQadowAkg+ktiyva0riO6WLzk3xHcNWAH5YX4B O+TT+NYPkvJmcr3km6cmoUh4OeoOoCShcYmVNmI3XD1gfyj0QGWqFmOVHh0vEvZmxw28 X1gTgkDVxQ50n5adJrK0z+BDKgeWBT626ruW8zzorvPvyPGc4ZwUZOHB+KZXihVjygg8 JtwqKKLrtBWAM5bUiIFEL4vLXKnSLZ+eJDPyZm0q1drrD9A0/6y0NCSfnIb5W9DDQV7S h+8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=CMkL/dkrblrfioNSwlNYuKNfTkkc+C9pVt6ijV4CZPc=; b=rJpWm9kK3OXlNUGbWgYTKoG/ihTy2CESpJmJcINULRfTjTvNLZAhRIjbDh9oEfxQ0M xFcaLK6DiD45p06yECu8z979c0iR3nnzsp8N0xa4MdfL/tSB6ja+lyptvTM/Vv0V/z9X C0hcUskw9y0L2Zmu9Klrz8F88gmZfXn6cW6zKwaw2oaSUdV8DU69t9SbacTSkKRsmhar R6K8OCqxZr2i/XZi+4ob7mGMMxEtde2UlTxBydxI7JGUEraM2taEjOVJLHbxXF5mlY8e 0C07ZHZCQnEJcGw0jBVPbMMCMmRBVw5DLzyYs7P3npXAG8uJYkiGWAZdIvOrxokwpHcX 5ntw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ImTbFKff; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t29si1528171pfa.359.2018.02.07.18.04.41; Wed, 07 Feb 2018 18:04:56 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ImTbFKff; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751574AbeBHCCj (ORCPT + 99 others); Wed, 7 Feb 2018 21:02:39 -0500 Received: from mail-ua0-f193.google.com ([209.85.217.193]:42567 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751123AbeBHCCh (ORCPT ); Wed, 7 Feb 2018 21:02:37 -0500 Received: by mail-ua0-f193.google.com with SMTP id 47so1914258uau.9; Wed, 07 Feb 2018 18:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CMkL/dkrblrfioNSwlNYuKNfTkkc+C9pVt6ijV4CZPc=; b=ImTbFKffUpqTdDRuJ4CagowZrc3hBiE7B7EguWCLBiA6bsyOI1ht0kWtjoD49lUcst Gw+/yw7ZYVrbSSDGRzM0rnO+v+EVD2eIDV4qvZMTYOTIV6Cn9Kmi195s1EqXlDlDJ1WM 5kP2Dhs75f+sCLSHOP4yiVVhZEORhusM20qS64Nlzr93vcOQF18NKLz9VYcudxkDycyb p05JWWJH5SKHUJQHIWBjBTKdKImsnoM3U7UUGOUWNrxT7Hq3XQ/1Che6sYF4HF6A3QUD wxFvVnQB5Q5ZgH0iWpnQZDqfcNz9MwjerKHmc+OErbxHrLd7W2nWe2PgVVAY6tPaOaG6 Pr6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CMkL/dkrblrfioNSwlNYuKNfTkkc+C9pVt6ijV4CZPc=; b=WJGf5/dKqhnsxUnXmDruBMIfn3qzu4QJrQ+u9Kyn5HMyPmM+rCG4BqpIOs+vG09NNd sObTbXnboAEga6L5gLyngpwLJwPJVmiQYSC9j9hC+SIO3lf8S7cUGSN8cHOUoXhgeDwM PJlgiUwHuDEGsjUfnMKLxlqnYKx28KJZ9LLoPlr1RH+o1QApKaKGTF1ACT5lAcAtC4Dp 2BmQ33HzPG2crZsvZQBvKGMCvhINyPFifWvJ7482LUJixf/ISUc4LfWGQMrtz0kYNXTI Tm+0+oNHF5Ju+ucWWkookkFVlfjOCT2wQYQ6//DxCINzgNiTFlmn6BPKFMqTIHuUoqLO 21kQ== X-Gm-Message-State: APf1xPCOIizBbfBF9h9im2JuNUHMpUHjtzzLcjyWE+GleFvrByHY0BvG QbLmr4hnTb/uREK2eSX+omDnUv8l48PQoTiANYY= X-Received: by 10.176.25.65 with SMTP id u1mr7193896uag.108.1518055356740; Wed, 07 Feb 2018 18:02:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.70.21 with HTTP; Wed, 7 Feb 2018 18:02:36 -0800 (PST) In-Reply-To: References: <1517877294-4826-1-git-send-email-yamada.masahiro@socionext.com> <1517877294-4826-2-git-send-email-yamada.masahiro@socionext.com> From: Ulf Magnusson Date: Thu, 8 Feb 2018 03:02:36 +0100 Message-ID: Subject: Re: [PATCH 01/14] kconfig: send error messages to stderr To: Masahiro Yamada Cc: Linux Kbuild mailing list , Greg Kroah-Hartman , Andrew Morton , Nicolas Pitre , "Luis R . Rodriguez" , Randy Dunlap , Sam Ravnborg , Michal Marek , Linus Torvalds , Linux Kernel Mailing List , Marc Herbert Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 8, 2018 at 2:49 AM, Masahiro Yamada wrote: > 2018-02-08 5:24 GMT+09:00 Ulf Magnusson : >> On Tue, Feb 6, 2018 at 1:34 AM, Masahiro Yamada >> wrote: >>> These messages should be directed to stderr. >>> >>> Signed-off-by: Masahiro Yamada >>> --- >>> >>> scripts/kconfig/conf.c | 18 +++++++++++------- >>> scripts/kconfig/zconf.l | 27 +++++++++++++++------------ >>> 2 files changed, 26 insertions(+), 19 deletions(-) >>> >>> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c >>> index 307bc3f..90a76aa2 100644 >>> --- a/scripts/kconfig/conf.c >>> +++ b/scripts/kconfig/conf.c >>> @@ -75,9 +75,11 @@ static void strip(char *str) >>> static void check_stdin(void) >>> { >>> if (!valid_stdin) { >>> - printf(_("aborted!\n\n")); >>> - printf(_("Console input/output is redirected. ")); >>> - printf(_("Run 'make oldconfig' to update configuration.\n\n")); >>> + fprintf(stderr, >>> + _("Aborted!\n" >>> + "Console input/output is redirected.\n" >>> + "Run 'make oldconfig' to update configuration.\n\n") >>> + ); >> >> This could use fputs() too, moving the stderr to the last argument. > > > In general, I am not keen on replacement of (f)printf with (f)puts. > > If '%' does not appear in the format literal, compiler will automatically > replace the function call with a faster one. > > My compiler replaced both fprintf(stderr, "blah\n") and fputs("blah\n", stderr) > with fwrite. > > At this moment, right, the compiler cannot optimize it > because it never knows the result of _(...). > > If we rip off the gettext things, it will be optimized. No problem with me. Just some personal OCD. :) > > > >> I think the _() thingies around the strings are for gettext >> (https://www.gnu.org/software/gettext/manual/html_node/Mark-Keywords.html). >> This would break it if there are existing translations, since the >> msgids change. > > Right. I will keep inside _(...) as-is just in case > to not break gettext. > > > > >> More practically, I doubt anyone is translating these tools. IMO we >> should remove the gettext stuff unless we find traces of translations. > > I agree. Probably, it should not hurt to eliminate gettext, > but out of scope of this series. Yeah, out of scope. > > >>> exit(1); >>> } >>> } >>> @@ -565,7 +567,7 @@ int main(int ac, char **av) >>> } >>> } >>> if (ac == optind) { >>> - printf(_("%s: Kconfig file missing\n"), av[0]); >>> + fprintf(stderr, _("%s: Kconfig file missing\n"), av[0]); >>> conf_usage(progname); >>> exit(1); >>> } >>> @@ -590,9 +592,11 @@ int main(int ac, char **av) >>> if (!defconfig_file) >>> defconfig_file = conf_get_default_confname(); >>> if (conf_read(defconfig_file)) { >>> - printf(_("***\n" >>> - "*** Can't find default configuration \"%s\"!\n" >>> - "***\n"), defconfig_file); >>> + fprintf(stderr, >>> + _("***\n" >>> + "*** Can't find default configuration \"%s\"!\n" >>> + "***\n"), >>> + defconfig_file); >>> exit(1); >>> } >>> break; >>> diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l >>> index 07e074d..0ba4900 100644 >>> --- a/scripts/kconfig/zconf.l >>> +++ b/scripts/kconfig/zconf.l >>> @@ -184,7 +184,9 @@ n [A-Za-z0-9_-] >>> append_string(yytext, 1); >>> } >>> \n { >>> - printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); >>> + fprintf(stderr, >>> + "%s:%d:warning: multi-line strings not supported\n", >>> + zconf_curname(), zconf_lineno()); >> >> Whether stuff is translated seems inconsistent too. > > > Right. Many people change the same tool, it is difficult to > keep the consistency. > > > > >>> current_file->lineno++; >>> BEGIN(INITIAL); >>> return T_EOL; >>> @@ -294,7 +296,7 @@ void zconf_initscan(const char *name) >>> { >>> yyin = zconf_fopen(name); >>> if (!yyin) { >>> - printf("can't find file %s\n", name); >>> + fprintf(stderr, "can't find file %s\n", name); >>> exit(1); >>> } >>> >>> @@ -315,8 +317,8 @@ void zconf_nextfile(const char *name) >>> current_buf->state = YY_CURRENT_BUFFER; >>> yyin = zconf_fopen(file->name); >>> if (!yyin) { >>> - printf("%s:%d: can't open file \"%s\"\n", >>> - zconf_curname(), zconf_lineno(), file->name); >>> + fprintf(stderr, "%s:%d: can't open file \"%s\"\n", >>> + zconf_curname(), zconf_lineno(), file->name); >>> exit(1); >>> } >>> yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); >>> @@ -325,20 +327,21 @@ void zconf_nextfile(const char *name) >>> >>> for (iter = current_file->parent; iter; iter = iter->parent ) { >>> if (!strcmp(current_file->name,iter->name) ) { >>> - printf("%s:%d: recursive inclusion detected. " >>> - "Inclusion path:\n current file : '%s'\n", >>> - zconf_curname(), zconf_lineno(), >>> - zconf_curname()); >>> + fprintf(stderr, >>> + "%s:%d: recursive inclusion detected. " >>> + "Inclusion path:\n current file : '%s'\n", >>> + zconf_curname(), zconf_lineno(), >>> + zconf_curname()); >>> iter = current_file->parent; >>> while (iter && \ >>> strcmp(iter->name,current_file->name)) { >>> - printf(" included from: '%s:%d'\n", >>> - iter->name, iter->lineno-1); >>> + fprintf(stderr, " included from: '%s:%d'\n", >>> + iter->name, iter->lineno-1); >>> iter = iter->parent; >>> } >>> if (iter) >>> - printf(" included from: '%s:%d'\n", >>> - iter->name, iter->lineno+1); >>> + fprintf(stderr, " included from: '%s:%d'\n", >>> + iter->name, iter->lineno+1); >>> exit(1); >>> } >>> } >>> -- >>> 2.7.4 >>> >> >> The unrelated gettext stuff aside: >> >> Reviewed-by: Ulf Magnusson >> >> Cheers, >> Ulf >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > -- > Best Regards > Masahiro Yamada Cheers, Ulf