Received: by 10.223.176.5 with SMTP id f5csp1344122wra; Wed, 7 Feb 2018 17:51:30 -0800 (PST) X-Google-Smtp-Source: AH8x226BrA94oNv8ibU35ikEorZ2Kv62LlJAPNfEW842O2cMgFLSmzW/0kKvDFjllrzIUndMUz7m X-Received: by 2002:a17:902:6c0e:: with SMTP id q14-v6mr8050410plk.445.1518054689999; Wed, 07 Feb 2018 17:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518054689; cv=none; d=google.com; s=arc-20160816; b=h54MyrFNlcV8cd5AeP8o0WN5LLHKihhCgW2UJyPdgU11n/YYcvi2Tjf57ru/GvYfhz uCmVBBBOlCUe8DH2FI6Q2HxZGU6pgD9CbBmD6zbkOPplPbHOGIW3pwcksNmQnN9HYUH6 LHnYhwKxkY6hMvdU496l5ylLcuOaU7u8ZCq7Ty667Xm0fiOqNGiok2X4NWcw7mrscdoW 24UwPMOm9qRi00MkeOfBS52RNRxwfWfRmnCCraWZE3SIwnvfXgVfOLGVBm702YsOZtlN DQS1yteTdPL4hihQ/cZkbZa8auo4duTUul4U1F3hoQrYWzMi8nyqH9vGxUx90AKmh6W7 nAlQ== 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:dkim-filter :arc-authentication-results; bh=3KG/ekbLEvhK/DmBysLOnG5zuBtux5gSrWo1TCFZuxM=; b=hGI50Rif/+zcKrltPI6pAIH+pXEbzgVafPGWcgvhAc7J2H3SamrnhhMNipVcG10Pxs jSioe9RvPjrwSBYinHrLyUjjWaZY4kNH2L4JoaWIi0N1bY0i2CB4qJp6UjWmBXKO0c/U aZMGOe0Wiric5GkE05JITrIIqh9bXn9E3KEIAtCeQWCgV8PybR+DJYjkKUo4jFkQiSvX QYR54fRgRu92rdhHWHcc3UmDovrArVT7pbWhKSgGGZYdYQ/7NtLqXe3P6I79e1wQ1KFB XTbjsKpuy7KTfb7LZ+9KeJm6NTUmhBn+fl9AyENGdS0lokrwF63iImBRG1m+zSKW/Lzh 40EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=PEarKnCp; 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 z21-v6si374293plo.545.2018.02.07.17.51.15; Wed, 07 Feb 2018 17:51:29 -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=@nifty.com header.s=dec2015msa header.b=PEarKnCp; 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 S1751624AbeBHBue (ORCPT + 99 others); Wed, 7 Feb 2018 20:50:34 -0500 Received: from conssluserg-04.nifty.com ([210.131.2.83]:44627 "EHLO conssluserg-04.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751123AbeBHBuc (ORCPT ); Wed, 7 Feb 2018 20:50:32 -0500 Received: from mail-vk0-f46.google.com (mail-vk0-f46.google.com [209.85.213.46]) (authenticated) by conssluserg-04.nifty.com with ESMTP id w181oFj7015357; Thu, 8 Feb 2018 10:50:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com w181oFj7015357 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518054616; bh=3KG/ekbLEvhK/DmBysLOnG5zuBtux5gSrWo1TCFZuxM=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=PEarKnCpr9xc9SqPPZjmoZvLEgCrBqEVqkYbSiLZu3+fGl85jXz9T3YeXpHbApQan 5H1xtR76gscudYAYP68lE6m3ZWbIZLQYC7h9aZdreIqBmHdQHv3VQ0DDl8Q8YmhXhF fw0zqTm/Xu+RL2Tlq6ifQ+nv4vltAlBJ4q2NGWRMg7cTJ7t3eze5SBBLugUrPbaJ/O UcIU2cyeS8pZR8Z2agzi/SSCXv4V6JzrTdBDzuAIgNPukILtu+O4aOb14MAWgZlPo6 7jJWJWZE/N5RnrHTEJUeOt6bfPbbBDunl5rFISk7AUrYE/HiMv06+MpXiWUwxRJ1x2 geTWqTa8y+rzw== X-Nifty-SrcIP: [209.85.213.46] Received: by mail-vk0-f46.google.com with SMTP id q62so1824554vkb.11; Wed, 07 Feb 2018 17:50:16 -0800 (PST) X-Gm-Message-State: APf1xPA3Shf91KkQgiYa9kzzEcMF27DWyWUzwAkrP2w0X0ccKs6DeR+b VnZUfZDDXyENnA0KHmIoGQ1X9lSJfMlL0KBCkBg= X-Received: by 10.31.151.147 with SMTP id z141mr7079988vkd.113.1518054615015; Wed, 07 Feb 2018 17:50:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.83.212 with HTTP; Wed, 7 Feb 2018 17:49:34 -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: Masahiro Yamada Date: Thu, 8 Feb 2018 10:49:34 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 01/14] kconfig: send error messages to stderr To: Ulf Magnusson 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 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. > 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. >> 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