Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1463766rdf; Sun, 5 Nov 2023 00:56:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa/cjJwf9et3GnGZ8Iw041ZdDdaLyoiSR0MIJTL8gzxkWO0SCz9guasllrPVf6GVVg2PW3 X-Received: by 2002:a05:6808:8d0:b0:3af:75d5:e10b with SMTP id k16-20020a05680808d000b003af75d5e10bmr25796606oij.25.1699171012754; Sun, 05 Nov 2023 00:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699171012; cv=none; d=google.com; s=arc-20160816; b=tLEMSMr4f1EXxqE+ML1o8IqRZd/8tE/S2t/Tzp9dn0cDaOMb6af6rrCBglWZJXL6eH O6TW5GJrJuyYQKFft3XJyQUbXWewke/t6Hx7DyiPPfOTjybIGILcfyA3ZeNCUWi/WToQ blOO4MGk1XxghFfoDX7FP+VeyI84LBx3UKxIXqzmYsq1ANMeW7RpMMdzPaBh7f4HgRS9 2rFEMoEErCFaVfLxYS5R6x29xASgP+nlSHdV07NYGdkoRkSL7iNfCuSt+Ltu1tUZpUn/ q/XvttnnsfsLwF7Dkk3hNc35GGTC9h/xpRVmfEk1RRdcaC0TDvhiW2eG/xi4CsoyNjSf S9yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=B9WNxIJHRnGsbPZ5KMOO8nPKk+H1JZ3gSk9KGAfeIMw=; fh=QpLWixg+c7jUb6f1b0f/JSNEI45EzgFr9sAQMtTt1v8=; b=CpeAHp1fULUzbsk5n3Civ7R69yPeh6aFMpysHfbrk1JKskBcRVCwoaIaGvaNozaYQo 9wg6P+Oll4Q0BBfpqCXu2ddIR83Vh+/HwwpAEI3xLRUka98a26vFXiNbYE7FFtHXnt3i 7DNwVGpJqMnYH1UGPQNQy/bn8QkZF9HOL8BWTCY6Rh1aoRX0h5JXPPwXfALdsO6Ha933 8/Iuo6AG1FYszUsBpVkV9E/jkZSwxxzTMjiG6IhFtKmLVlrI04Clg4FrOuSS2Fog22h3 Vq3M9DDwSwFe8ExAgl2L+SfGerwnqN/9Qkmuh46rWLtjK9azRiKgBKBEowYpSy3QXZiG /jFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iydKVa66; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j65-20020a638b44000000b005ac13df150dsi5711235pge.384.2023.11.05.00.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 00:56:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iydKVa66; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C59378083DFD; Sun, 5 Nov 2023 00:56:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbjKEH4k (ORCPT + 99 others); Sun, 5 Nov 2023 02:56:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjKEH4j (ORCPT ); Sun, 5 Nov 2023 02:56:39 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7EFAC6; Sun, 5 Nov 2023 00:56:35 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 567B9C433C9; Sun, 5 Nov 2023 07:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699170995; bh=NO/6VdsZWes1wh0lm2MDJmpIOUg5lGll4DVhzAMddw0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iydKVa66n3x+i4cKBtqK7tlzbvc9FWDknuBvmYjrV725HFdFBwLym4O0pUEwfKeoa eQWl2FF6cJ7Nihjpe0Yp2IfEkbjQctJG/mn1TNw6HFcSrShNhG7EmR8rRNGSFRc5AY hxIpWOHJE2DWwoUA2nYlXUXojeebu3IBrmuIrFm1aOKpvnD8jg8nNINZO9YmfqdG1o vDzaCzdQUYGuiR7wZA9ZPOnHsZMlAv/y3uk41nH5R2ty/84Kxtdp3WzYGQ9BQLMQS7 09t07kj7h4OZBbUXNr8YqFUl+J1IEsktj4uWmzbRfer7Q2LRSaghwthfHzZ0screD5 o7sjvjVcF7fVw== Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-586beb5e6a7so1972841eaf.1; Sun, 05 Nov 2023 00:56:35 -0700 (PDT) X-Gm-Message-State: AOJu0YymA60Nug0TQb8Z6TWDhDhViaujL2/zzpNsiIZN52y6WbR/tWFg H/xrW4duAxFd13A0ozpxpE+ba4jC3oQvfUOUoww= X-Received: by 2002:a05:6870:80ce:b0:1ef:b5e9:a4ef with SMTP id r14-20020a05687080ce00b001efb5e9a4efmr24255511oab.55.1699170994705; Sun, 05 Nov 2023 00:56:34 -0700 (PDT) MIME-Version: 1.0 References: <20231104222715.3967791-1-yoann.congal@smile.fr> In-Reply-To: <20231104222715.3967791-1-yoann.congal@smile.fr> From: Masahiro Yamada Date: Sun, 5 Nov 2023 16:55:57 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] kconfig: avoid an infinite loop in oldconfig/syncconfig To: Yoann Congal Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Randy Dunlap , Brandon Maier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 05 Nov 2023 00:56:49 -0700 (PDT) On Sun, Nov 5, 2023 at 7:27=E2=80=AFAM Yoann Congal = wrote: > > Exit on error when asking for value and reading stdin returns an error > (mainly if it has reached EOF or is closed). > > This infinite loop happens in particular for hex/int configs without an > explicit default value. > > Previously, this case would loop: > * oldconfig prompts for the value but stdin has reached EOF > * It gets the global default value : an empty string > * This is not a valid hex/int value so it prompts again, hence the > infinite loop. > > This case happens with a configuration like this (a hex config without a > valid default value): > config TEST_KCONFIG > hex "Test KConfig" > # default 0x0 > > And using: > make oldconfig < /dev/null > > This was discovered when working on Yocto bug[0] on a downstream > kconfig user (U-boot) > > [0]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=3D14136 > > CC: Brandon Maier > Signed-off-by: Yoann Congal Applied to linux-kbuild. Thanks. > --- > v4->v5: > * Switched to Masahiro Yamada's suggested code. > v3->v4: > * Added Brandon Maier's "Tested-by". Thanks! > v2->v3: > * Simplify the patch by fusing comments of : > * Masahiro Yamada : Exit as soon as reading stdin hits an error > * Randy Dunlap : Display the name of the currently read symbol > v1->v2: > * Improve coding style > * Put more info in the commit message > --- > scripts/kconfig/conf.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c > index 33d19e419908..62de1fbaff97 100644 > --- a/scripts/kconfig/conf.c > +++ b/scripts/kconfig/conf.c > @@ -76,8 +76,10 @@ static void strip(char *str) > /* Helper function to facilitate fgets() by Jean Sacren. */ > static void xfgets(char *str, int size, FILE *in) > { > - if (!fgets(str, size, in)) > + if (!fgets(str, size, in)) { > fprintf(stderr, "\nError in reading or end of file.\n"); > + exit(1); > + } > > if (!tty_stdio) > printf("%s", str); > -- > 2.30.2 > --=20 Best Regards Masahiro Yamada