From patchwork Thu Feb 8 05:56:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 127252 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1170747ljc; Wed, 7 Feb 2018 21:58:24 -0800 (PST) X-Google-Smtp-Source: AH8x226sRZiarasxcQL5ItDqdH9mUO0N5ytMWVa5EL+ifgHXaq49domblFqsXsgxr8mDGkMWG57h X-Received: by 10.99.97.211 with SMTP id v202mr7112104pgb.412.1518069504512; Wed, 07 Feb 2018 21:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518069504; cv=none; d=google.com; s=arc-20160816; b=h5nZ8jQd5QIplj2G3WWC0cMvR93jGpUySoIpi42yWag1DLv19jf09E/vfSDhJYS1Zl zb1EDsGYjQillBkFu+j6zcSbZq92M6k6rC7E8RFciZt3pKWUiULa0amiuEYIHntY76KY Cr+PFHc0oIONz9R/E37V4yNdebOWoTSpowx5cXZ+sSsEqJTJDGTsIa85I5u8Tp/yANjF y2qogtq2m5kTr0JMmtwm37+8QPMXDQ1x8rJnsDLS/Ok1HxSdoz0iLJwRgOJ04BTCvCp/ F66kj2RJwzsSX6YDFSaMq59oVnuuMEeWyaVg+jO6LxRgVfmWJD7dt6kw9gh6ArLGIWMY NAWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=y/T00zGkk5CQhduvCCSXMIxR8CFcN1Z7X+1AgBsAsjM=; b=do3AGV0AvjnGnUvXiyGVji40wGu62bz434S45SLPr+nsqh1ZxFDOkhGGPejQbnr0je rkFjJs2/wishmJGURBsxqtLnCH+TnqpCXdp0nro/m19W7q3z5sNVUJroNjabELSw7643 b9X4BSy4fbk58NP5Ig+ahBrrHOOLrv+wHOfXmIu3qIQ9+69baG3Z76+XitdnUYHokth5 2HmKM6xyoFv5R1M0FOr8GSTvsKw1UlmREsgXUaHhPSj82AKZnH82BsrvrdpFj7evSh/v +vpymqqrXdxNd9bqIcnydpqwislOZoZeirE0C2kiG1VOiS8T46bkk8GiH4LsBv6idlKJ utoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cSq2qWNE; 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 h89-v6si2286431pld.590.2018.02.07.21.58.24; Wed, 07 Feb 2018 21:58:24 -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=cSq2qWNE; 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 S1751574AbeBHF6G (ORCPT + 14 others); Thu, 8 Feb 2018 00:58:06 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:58455 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951AbeBHF6E (ORCPT ); Thu, 8 Feb 2018 00:58:04 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w185uhG2007816; Thu, 8 Feb 2018 14:56:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w185uhG2007816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518069404; bh=y/T00zGkk5CQhduvCCSXMIxR8CFcN1Z7X+1AgBsAsjM=; h=From:To:Cc:Subject:Date:From; b=cSq2qWNEAnjM/E1blG7QLpVhwDS9CfqMUofE2G9CIihsHzlVph288WasbpI3buB5S ucWIe6jVy80STaLcw1bPkkmiIsE/wr4alo6og8HOjOwTBx3luTwbAbJ6yxmaL7B/m7 xuyKDLx1nh5pCHG5QkVl3c5ohtpe6+UyBooW3RtGafzmnibN12DoO7hxh52G/yFHDs suv4AS+1Xeko7wI/7qv+N9NtKplSLm8D5afD+qPOBKnEzpqupqfOLghuNu0u/IF+tm Y+KHu19jNy7OKj0DV9FMyta22seJhM7Q/MAZdBe9g+Wmd9/fiqxl1HxZaQAfjz1Wq6 oLPFQixOUl16A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Ulf Magnusson , Randy Dunlap , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org, Marc Herbert Subject: [PATCH 1/2] kconfig: remove check_stdin() Date: Thu, 8 Feb 2018 14:56:39 +0900 Message-Id: <1518069400-7037-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Except silentoldconfig, valid_stdin is 1, so check_stdin() is no-op. oldconfig and silentoldconfig work almost in the same way except that the latter generates additional files. Both ask users for input for new symbols. I do not know why only silentoldconfig requires stdio be tty. $ rm -f .config; touch .config $ yes "" | make oldconfig > stdout $ rm -f .config; touch .config $ yes "" | make silentoldconfig > stdout make[1]: *** [silentoldconfig] Error 1 make: *** [silentoldconfig] Error 2 $ tail -n 4 stdout Console input/output is redirected. Run 'make oldconfig' to update configuration. scripts/kconfig/Makefile:40: recipe for target 'silentoldconfig' failed Makefile:507: recipe for target 'silentoldconfig' failed Redirection is useful, for example, for testing where we want to give particular key inputs from a test file, then check the result. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 14 -------------- 1 file changed, 14 deletions(-) -- 2.7.4 Reviewed-by: Ulf Magnusson diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 307bc3f..358e2e4 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -39,7 +39,6 @@ static enum input_mode input_mode = oldaskconfig; static int indent = 1; static int tty_stdio; -static int valid_stdin = 1; static int sync_kconfig; static int conf_cnt; static char line[PATH_MAX]; @@ -72,16 +71,6 @@ static void strip(char *str) *p-- = 0; } -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")); - exit(1); - } -} - /* Helper function to facilitate fgets() by Jean Sacren. */ static void xfgets(char *str, int size, FILE *in) { @@ -113,7 +102,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) printf("%s\n", def); return 0; } - check_stdin(); /* fall through */ case oldaskconfig: fflush(stdout); @@ -315,7 +303,6 @@ static int conf_choice(struct menu *menu) printf("%d\n", cnt); break; } - check_stdin(); /* fall through */ case oldaskconfig: fflush(stdout); @@ -650,7 +637,6 @@ int main(int ac, char **av) return 1; } } - valid_stdin = tty_stdio; } switch (input_mode) { From patchwork Thu Feb 8 05:56:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 127251 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1170667ljc; Wed, 7 Feb 2018 21:58:17 -0800 (PST) X-Google-Smtp-Source: AH8x226BTzmgME7VaWYwqezpvTOBkbDVWbwDZlRW7g8niH2rlyDNRZNfnWtLW64HQGvW6yJm8sIk X-Received: by 2002:a17:902:8f8a:: with SMTP id z10-v6mr8293513plo.395.1518069497127; Wed, 07 Feb 2018 21:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518069497; cv=none; d=google.com; s=arc-20160816; b=fGzT7p/yKBW5J28KvxRL5zsrAGY52JruV6edXhFx1LiAWJwDbnxwAqyO6bfGDxaZjk AAKUPInXZJ/y7zPoMq7ABeMiIcW93nohbh50u41y1llqUBsHxX4/zc+HCZOtqcTVv8ZS sc1OqYNivzgfSndt9tU8YQirj+2QogAdJ97lTZU9hKGeVxlNx1UWgw9AiELoM5o0v0ZL nHq1W317XHGuNtEl1grPQut5pvZgaQ2BNueB5o/Lxtc7ZAoHJXbdqgi27mE6jViJA2lV 5UaBAol7S/4RHGC9g3nGpyBlBG4g8gVUUP/lzrpg0b43hwVBzFKBiwnU9iFmAFbEGKKS nfCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=tkKVsyCnE1leUCGtzur2BHn/LVrjjGUZyjSnZS+mtAI=; b=AxQjHm1asimcMeINo31UArNtue/ucyMYH92MVPeQL0oSbkF2hDc+4aZN4LiOuiogzr qEUnOuT8ggz69kxO4iBGFT11TxUHXro4oDXs8q48eT2hpBrx8WXauG3g59ubuT0dOg2h SV1ScEX1CPuaBqJY5Z0cY2cGq5IlmozP3s58voRW1m1olgPDetIU2Gpcp7ha2D7rPdCd IMht+o4GYjVcuP3Y3VRqse3w9DCLdU1oWdfJldNXBXC7NojMMdKMYPnuUYqAyLQro/TZ Y53XGeYWKT8+5/vVSF1LiciLbVwsv+O6ErsEo8ToODi3GIMkeJ8kOOsvGE0zjWr8giFP nYJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=c3msDm8J; 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 o3-v6si2289365pld.405.2018.02.07.21.58.16; Wed, 07 Feb 2018 21:58:17 -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=c3msDm8J; 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 S1751998AbeBHF6I (ORCPT + 14 others); Thu, 8 Feb 2018 00:58:08 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:58454 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbeBHF6E (ORCPT ); Thu, 8 Feb 2018 00:58:04 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w185uhG3007816; Thu, 8 Feb 2018 14:56:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w185uhG3007816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518069405; bh=tkKVsyCnE1leUCGtzur2BHn/LVrjjGUZyjSnZS+mtAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3msDm8Js4ECoMciy9eOsjrOtg0nnn+J7NA9CHYHuhrfKfl6p/XbG6rP2wbp8T/2k C6dfCv4+KNHqAtOJPaepYM/EoHJrqII0OI1iKHhpOnoPUyAJ+ao4TmPavAMdIdsseX PcRUrKjaamJvENWmoiHNhkTHdyGqITSQ0j8TiJ5ojHVMY3gAqiJMfSF5l5oEwh4zSp yZDyCrn64QRcZH3f9CQhFqFKGAtoV+tOCt8ZW+npsxxNG+BzkgyYzSTNyiE48psNXQ RFfoLIs385cf7lURNPiyCnlM5zFOf1W3EyLarijirk/eKn0O0/oosd3pCvvocjMzIA D5wvv1HSFcBQw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Ulf Magnusson , Randy Dunlap , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org, Marc Herbert Subject: [PATCH 2/2] kconfig: echo stdin to stdout if either is redirected Date: Thu, 8 Feb 2018 14:56:40 +0900 Message-Id: <1518069400-7037-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518069400-7037-1-git-send-email-yamada.masahiro@socionext.com> References: <1518069400-7037-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If stdio is not tty, conf_askvalue() puts additional new line to prevent prompts are all concatenated into a single line. This care is missing in conf_choice(), so a 'choice' prompt and the next prompt are shown in the same line. Move the code into xfgets() to take care of all cases. To improve this more, echo stdin to stdout. This clarifies what keys were input from stdio and the stdout looks like as if it were from tty. I removed the isatty(2) check since stderr is unrelated here. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.7.4 Reviewed-by: Ulf Magnusson diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 358e2e4..c5318d3 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -76,6 +76,9 @@ static void xfgets(char *str, int size, FILE *in) { if (!fgets(str, size, in)) fprintf(stderr, "\nError in reading or end of file.\n"); + + if (!tty_stdio) + printf("%s", str); } static int conf_askvalue(struct symbol *sym, const char *def) @@ -106,8 +109,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) case oldaskconfig: fflush(stdout); xfgets(line, sizeof(line), stdin); - if (!tty_stdio) - printf("\n"); return 1; default: break; @@ -495,7 +496,7 @@ int main(int ac, char **av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - tty_stdio = isatty(0) && isatty(1) && isatty(2); + tty_stdio = isatty(0) && isatty(1); while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { if (opt == 's') {