From patchwork Fri Feb 2 15:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp521729dyc; Fri, 2 Feb 2024 07:59:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtx5T/JdDdFRMUOhrdyepgUZdBOPFgOwBoT3fm850+y7BB63p4UHy7PJUHHaxecb1C5jXN X-Received: by 2002:a17:906:30d3:b0:a31:8944:2cf6 with SMTP id b19-20020a17090630d300b00a3189442cf6mr2051150ejb.8.1706889564654; Fri, 02 Feb 2024 07:59:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889564; cv=pass; d=google.com; s=arc-20160816; b=AVmsTTp51Yh+IBDUV5JEF4zEhDRLavKBpmZuGd7yku/CrpQ/VSdSv0Ww77gxk5EAKV dp9uo9Ot0763woWLc8UI1e+dHAsy4FH/mFR5GINvT+gLZ90FYEcMSVHuYiqOtFzibw3H 1gpfxSmSwrdLvbPC4qMAUH97DxapVRA8F4/5Axrs0BFgoYA7dHyLM5fqkK0xg+oDKHv/ YdCICJspdR0XkrL6i2P+hyeEZNkrUPbQzjscgGWHFfVGb/ZQ7pwqRDZLY3Jt5+IVk6Jq Jwx7htWAkEOuKU76MqI2VG6GnWTLg0KpIdB9E360GJj8gYDSuRwX5ARiX5tDywNkzycg JR6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CxgzqSsqMZfSO2aGzVAqKWdHc1GS/5/rfQA5n2H97jo=; fh=YhI86J3KmZCgFtIbEBBODjgCKPxPkClZNMPl+n1b9Wc=; b=eomw8Vm8p1OBsQxqdC7DGdR5sfaIqvVQnDWE4PedG2KPDfn4yj3/tJkTulFvtHvORf jL6mdJoIDOtOC5yrCzqxHWOPpV2d/FnfCUnS6QsTLwhOmQon+SeWdITCw8dZVRzMuGt3 cBCY28LHW4y15gNYSRCTHeEN9Y00zDXUi7snDh32eF1HIXwZoSwqahRE8uh4D3go5LQ/ pDKOxFkKxJOGV1wChH9ZNp/hdDAlho5jkZ4A/Vrw9SMRlMnuNZmzI536CoZEDMG9VSAy h8tq/uSbAFtUJP+vGhG2q91uNCUL1KxKd6IxEYwoRIbfaMN3SUhxiMAql870dfTxvTgn 7QxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NjPyEICc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50060-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50060-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXVyIAjMPRWW0S3iRpVABmVLiK0MFUENIcHk959L+3MXmTYQlfIyVrmXtESvPqnFhSYQQymHTqKDBq/b7qUk5wP2NYk8Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ca24-20020a170906a3d800b00a28ba5dd13asi821750ejb.1055.2024.02.02.07.59.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:59:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50060-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NjPyEICc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50060-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50060-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 42F5C1F29D81 for ; Fri, 2 Feb 2024 15:59:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD8FD148317; Fri, 2 Feb 2024 15:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NjPyEICc" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BC991474D0; Fri, 2 Feb 2024 15:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889512; cv=none; b=lBBQQp/omGHFvS6vgKdMn8qM5hm1zSBvU+dP4DeaSDztsAxhX4si5Ir4xK59dHHlSj+gb8LAnKiqKoWyo2xnStuIIOpL79H5hxupDEEVJQYoRJX+aCk8uq5YKUs/wYlWyFeWoQVYKA7w2VPecykrOsJPZaMjbnuLyiBA26uN744= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889512; c=relaxed/simple; bh=0zjrnd8HxqGEk4V/+9L30lJo6lzcn61RhZYmqtdDahY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rOEsJ0DYvyWGd+uuYSVzM6fM0Gu2IE252Uz8uITV2OizQ2IK0Cf+v3BLkSbu2DjJmL93LTv3j+9DYEM4C1cHpgQBxrwFa4r4VNn3TtATsD6ResTxD5mt/8rK68A9vUvtbjhoXHvIUg4U/tgXdi/r8u+D8Lu9lBgGsKREJx4aIwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NjPyEICc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0CBBC43390; Fri, 2 Feb 2024 15:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889511; bh=0zjrnd8HxqGEk4V/+9L30lJo6lzcn61RhZYmqtdDahY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjPyEICcCinl8z3u4AxSSHdlSJA2HhXiOK0v8gPVhLMPkDkG1KeD3HTgqSwUfxqfQ Icne3B9EFy9SqptamIRc+TR2Wf+s2AV7pRbWg/zPt4EqKzovuhH5B8AoENgdSQddfA c8Ka+yiJ0ellWjGRGL2fGQ+UtQwKC4r5b74KdkZHHp65cauwwa35qN42Aha/VsDx+2 EyYtH52Jnk8am2jFHpvfnt/ll1s4+ifKfEozdfMxNQ4z701wMKKqILKio1f7Ot+ovh /3JldDJD+nf8MJxG0eQjIeeZh2M4GEwB43qFbf0pR5ANvNH7U14vctxncRD3rInEbf j3DVnAR83Blag== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 01/27] kconfig: fix infinite loop when expanding a macro at the end of file Date: Sat, 3 Feb 2024 00:57:59 +0900 Message-Id: <20240202155825.314567-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803431769701547 X-GMAIL-MSGID: 1789803431769701547 A macro placed at the end of a file with no newline causes an infinite loop. [Test Kconfig] $(info,hello) \ No newline at end of file I realized that flex-provided input() returns 0 instead of EOF when it reaches the end of a file. Fixes: 104daea149c4 ("kconfig: reference environment variables directly and remove 'option env='") Signed-off-by: Masahiro Yamada --- scripts/kconfig/lexer.l | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index f93b535a080c..5f1bc3320307 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -303,8 +303,11 @@ static char *expand_token(const char *in, size_t n) new_string(); append_string(in, n); - /* get the whole line because we do not know the end of token. */ - while ((c = input()) != EOF) { + /* + * get the whole line because we do not know the end of token. + * input() returns 0 (not EOF!) when it reachs the end of file. + */ + while ((c = input()) != 0) { if (c == '\n') { unput(c); break; From patchwork Fri Feb 2 15:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp523705dyc; Fri, 2 Feb 2024 08:01:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIdLVR0f1jEs2jM8G7R+46BNyRPRV66Ik7N1TJxLArMWwX+d8hYhCp5syCPRMVn+9GeD6J X-Received: by 2002:a17:903:264a:b0:1d9:44d4:706b with SMTP id je10-20020a170903264a00b001d944d4706bmr2591806plb.50.1706889699340; Fri, 02 Feb 2024 08:01:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889699; cv=pass; d=google.com; s=arc-20160816; b=o6i4jBIrw6VjxMmvrmlYHD2XSKcUXyiiXgrRqFQBlN5NXekOCJvqgRyQbk3CLml5FH iBg3Y2PPBkLrfj8hFcv2EXSzGV3w74WQtFJfRfwUJcR+AX50swnEojEzgseJmYAiFaoi wXQwNDqFbGW2PknRh4x3lLt1PUhJNAl6mH0uH3sL9OmsagNZKIAOSQxdFbDav97nuU6Q phd1GxP43RAY/mt4+oOeDaJ0JWFSK55TkWauPZc1lnPgv6oB3VUxthj9G9W5oAMiO7oU Fc9ZkcfyYkot03DkVpBQ+Ro1r84f+ptjSLLRplI3Qo1ZWHlP2vEJ5i6mctgt+s+HkbDk TBqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lh1YRqpDh4hbfZ8d436gOJuB3GsfKTSdM0GHXVoEWBo=; fh=T5Mx87QQOTmIYe6ojhBO7671EJrsVjL/uuFxmk9exBE=; b=FzrLEwsuvMl9RYuNnLOap3zeIH2/XbQZYHkZKT8KJONsVzMhtVtXtBotGmNM8/+K6P E0YenlbF7fmKYrjmSTXAXgImYAmLx7haSAftMfwZexsZo3vtITGnKp1SO6Yw9qQXDF7l n3hg0+GDaCecTE7OUsejtK0huHjBBow46lSsGexIcIzxjJIu9gUdfntpzEonm4UU+yh1 s2XsXN9E8YlX9+28pm4mtjZ0zJOexeNGLelW0HRH49/Gy2uNnNd7cjlLfOpg/1rc/GK7 rKtxFo4GvktazJmj8omBVcwIwy7i+SDbBmcpOCYfy6+rsktL420b7VC/fqwPEKksOcsz BpIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NpuPqRlk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50061-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50061-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUDPdp0iE6XuPC95HSpDozHQeFzAzBn7mY5rTO5H7TdGjp52NNaMMIFUUEH+fQE8qgtgtXl/ZNQbPEHWhtrHNh6zkMbDQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t10-20020a170902d28a00b001d9176f56f7si1839204plc.462.2024.02.02.08.01.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:01:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50061-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NpuPqRlk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50061-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50061-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 93765290F91 for ; Fri, 2 Feb 2024 15:59:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D949E1487EA; Fri, 2 Feb 2024 15:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NpuPqRlk" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FE5C1482E3; Fri, 2 Feb 2024 15:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889513; cv=none; b=AxcEewD3rokcQkAwVQfzhPogE7TbmhgEWMMfHISJ5EntoiMu3342eBcoQRt4sn5Ba02jsR1feh71ORLF8jqAmefDh7Gx51+34cvBHFMmH+ACgyRBr+nYkP5DxCvmiT3HYxWmAs3/u34du6SNkIUJCXqrPA2blqMYcf62XuoV7Ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889513; c=relaxed/simple; bh=iLMWYG9L/UfAHJBH+yDa8fL9Z1alCW8nTVuRLWkFGEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WjYCTjxD1AeVcetxnhD7toIsUiLAcLmmeA7s9i395WgDyQhLIo6vvGiul90mhljtXLLv8/A+dxovVkGsHkgTk2iofpNJqE6M+Ds31qcxyu/znJvLLkvw9PtxAmpJ0GK0YQhR7KyemTmwazfWKxk9wLINPSQs+sZOE3imf3hrLaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NpuPqRlk; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 061D0C433C7; Fri, 2 Feb 2024 15:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889512; bh=iLMWYG9L/UfAHJBH+yDa8fL9Z1alCW8nTVuRLWkFGEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpuPqRlkvGyBwYgYUT16rib5rySaETzs/nqVuIY5CKa0/laJ4lhuboWHFRZt9MFy5 dCj9jM44SzStc7QpKiMe1vsKJOn/fc6S7Rs6V2BuVOxJH0M6KroAPtk/5ZZlhCQuEe nzwmDRMCvvdFcp8NbwV2qQyep08nevb+637wq2lH6LsBgA/lXgdSwozcjLVUWJPf3d qa4ABjM8q4MswOH+92fwi/aqmgatahYy2VEE3tHNvYC5xk0feDEAdcbw0WlQ3HeWOM ZXv/ZhGaVwVoSZDSIx+WXX+h0AsiXh2OdCIJTmSRP7cyd07LMQKiVQDLKv0Y5Q9BRS 0Lfj81ou4IaoQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 02/27] kconfig: fix off-by-one in zconf_error() Date: Sat, 3 Feb 2024 00:58:00 +0900 Message-Id: <20240202155825.314567-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803573226100110 X-GMAIL-MSGID: 1789803573226100110 yyerror() reports the line number of the next line. This +1 adjustment was introduced more than 20 years ago [1]. At that time, the line number was decremented then incremented back and forth. The line number management was refactored in a more maintainable way. Such compensation is no longer needed. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=d4f8a4530eb07a1385fd17b0e62a7dce97486f49 Signed-off-by: Masahiro Yamada --- scripts/kconfig/parser.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 2af7ce4e1531..5ab2e3f7ca33 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -557,7 +557,7 @@ static void zconf_error(const char *err, ...) static void yyerror(const char *err) { - fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); } static void print_quoted_string(FILE *out, const char *str) From patchwork Fri Feb 2 15:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp523903dyc; Fri, 2 Feb 2024 08:01:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1z7ZYMxZwAuVvLyRCoQExahbhzGrDLjudH8mTROqtnCREIBDpK7PL9hwyUoh7pKNh2wbs X-Received: by 2002:a05:6a20:438a:b0:19e:3364:ca99 with SMTP id i10-20020a056a20438a00b0019e3364ca99mr2699323pzl.3.1706889713580; Fri, 02 Feb 2024 08:01:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889713; cv=pass; d=google.com; s=arc-20160816; b=F3Lp+/uY+ipVzwSdSQtkBksrnLQdZhp7DUOsvL7086WSWHzW8uYNeqwvPadqqqATnx lpZuwgo17y7iwdi19JtEC+zaCdV8G0zyw9ZEKT5XKe8GEu9ioOrQ3igWIWEDa6Izc5uc W5ovVN9q3bW223pYPb1xrrAsI+daccyWtAdV7fGyYT4YjRkpLwlLxCP7S0iR6Odp7mFQ Az+Yb+cgjmXPSfdbdDgptdh4bMzJCC3X0SLaayVJWe5ar1p2mGjpmjJw77Wc/cC2NC/C 4sIPVm8ncJASWnQwb2y/uQnB7cFRKYmxrCDG7CAbmGnqbjcZzvqIjEoKBJq4IKm5X+ap KdeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m1YQlLZgHosM0Bdds2fmmVAneK8hghTIMoKFo389Dbc=; fh=G4TI/D6avxytfJFJ4EGGSpFJck8nMe0kqkzalinBykw=; b=A2aLORzvLjNJP1olgDjazilfBFYprfdXcoi8lhLpPhYnVlpLVYI0dXZfZeKIbK0TVo C3xD5hyFcH8nO/ok0F89YCicf3qXTOJ9ezxV3Tgm8dFIjiorXFnRXMSJ7UmvctnoEiwU VFqHK10vF8MkvhlX9Snlp+PeLoZf4WXyMxcs4c3R50RWbLmSYzQoRbxDCl7ZF89KDfv3 5SlPA5FbHL4Er59lFY3NztUqOL9zAvwC5C5GGUbiuMpvQrap/YiX46qCg0GIact4KEt8 P1Pf/LhQPuz9j49tVj7G13NtABXqxYDnc/gZS1Qguq7zQTwLzeDY1Zb8Whmp7lSYNeA4 6Rmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J3YzqHSF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50062-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVuZYpdECkPDzG0qxbJRMfBqxa9uTPDbPiiW8VGvFoy85UW3fTzanocoQvq0yAP/WXw11+IbYBopcnSWk/LuHg+jB4lOA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m131-20020a633f89000000b005cd966560b7si1808359pga.626.2024.02.02.08.01.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50062-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J3YzqHSF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50062-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7323A284E8E for ; Fri, 2 Feb 2024 16:00:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1549E148FF5; Fri, 2 Feb 2024 15:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J3YzqHSF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D29148306; Fri, 2 Feb 2024 15:58:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889514; cv=none; b=VeZlrYTX4IDr44KRLxCWsBTj0KZyLo8OLto00t2MVO3nNrAxulO4HD9/HSwIcInwEdnEALdWEpxgZ+kVbIYZPWXQhJAKjUNcx6srPz4vjnInlnUGOvL4uS3ggyK9xey1NjDVhsa0vZa8RLJavoEG2UgxAko6bZbdlwTTRRLytX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889514; c=relaxed/simple; bh=U5NM7Nt1jzE4iRK2epL3mIB1zFDNJP0QdfPYsv0sK38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Paffz+8cnpXb+fd+SbNygp5dQP/bt4eEaClRNEFq5sLaTOAx5MArwz1gzft22gCD30xb4dOc++nyVCYG+AWGxueN9PJ1kXdbNVBCJAESlVQAF6wcSQZhOwNWk5Jy76qAsxO1LZZYJkbKL8XE/Y4Ku7J5b+fXaAZRg1COaKqFZZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J3YzqHSF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2052EC43390; Fri, 2 Feb 2024 15:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889513; bh=U5NM7Nt1jzE4iRK2epL3mIB1zFDNJP0QdfPYsv0sK38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J3YzqHSFhHi/Xn7vCle18PeBGaX/7q1UbDyit2H5q+IpYHWf0ytoRBCOnCJE52OHB bVVZygYNsWon2/wSxLISzOFDKYs9b2af6fJvaI6U+KqexT4vjwUV7FafeB7snJlsuM AljXW9pKS0iOCaTXeNV+TPqcJ8MmbH3zRyE3nWUpkXPr37NpBam/0n0MU46rejfLMj kjETDZbZptK2dSJlxCdoY759SVoQClevoVR7z2zJgSpFfdun8Ln4QUMCOBGYUAuKkP kKsOSErVCP6nsd5o1RLn0YIqr0E/HN7vX/m3PTLhHqSk47xl4/7ZFkTczY2CIT9G/j JM9wM/B7FMspg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 03/27] kconfig: remove orphan lookup_file() declaration Date: Sat, 3 Feb 2024 00:58:01 +0900 Message-Id: <20240202155825.314567-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803588392314919 X-GMAIL-MSGID: 1789803588392314919 There is no definition, no caller for lookup_file(). Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 4a9a23b1b7e1..e0d866569155 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -279,7 +279,6 @@ struct jump_key { extern struct file *file_list; extern struct file *current_file; -struct file *lookup_file(const char *name); extern struct symbol symbol_yes, symbol_no, symbol_mod; extern struct symbol *modules_sym; From patchwork Fri Feb 2 15:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp522424dyc; Fri, 2 Feb 2024 08:00:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEleRqk8Zqj/ZeSO+UlYhA9a0v7QLPuaJQPLYBdnprcrjNMbcMuYyIadTNvDzUlNZBzwMb2 X-Received: by 2002:a17:906:3888:b0:a34:abc2:3627 with SMTP id q8-20020a170906388800b00a34abc23627mr1828653ejd.24.1706889627963; Fri, 02 Feb 2024 08:00:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889627; cv=pass; d=google.com; s=arc-20160816; b=oPEFMCDaa2H8OhuKnvn94WIDKrpa0SNZTCMw0ySGic7aYco4uJNUUrYSC5iLB+SmTf E9BXTsR1AhIjTfj0MyhXMl7mUfeY9V5I7XfNlqHwPnTrKMU/LxzjyCH9wFstW/RaVtKS pGP6N0K4yhmJ9C7ZRRWYDiNiAJNHH3TswSvTmf2xJrCugJJvZzwWUfNKrJhiZWmd9PAd vl9AumJe51609e/eylnYKCcrlfQo3GgiFXIQTnwmNLe4Qh/SQm/Ov5y7FOONETf0l5C0 LPm5lUcni6aAYJeJ9PshJjyQUXqXK/WzH/Y+M9BSIgk6CSQ7lMwQAilJ2WHO4df85WcK MWJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o2AKtudjgboqETUd/bb9gDu/Y4/PrxqXdafzY2pBkRI=; fh=vfOJvpsTdsKIp2IwZs1ee2eecGV/56kai6zkkyigiVI=; b=O/K7Vy9KfrTS93OWDp+2gEjTM1hXrzd7apbXDjIKrj09FMxnzimZP7XnijXykXcjA0 TgiylNOB1nqWkKtBhoOnBMOnRIG+MYVcpj7bqVrdlQ0SpQriUZQjZ4NX8gskpxLv5qO4 XVqilbS1UFkRnSvBBnseFrCpkoadn+Tvv4YNTVapRGeSRpDAaatXjotXmTM5d1AOLQVb QTlO64C2wj2gxGGRwi/BdZBzB7Zryo6ceojU3vEqidk4YEdyuMff2Xzu4F3ugUHfaSbn D6G+At+JuTEJ7c/xo6Zg75bGZotKgmZu0jKQCfIsG8C5x+RkOYfs0NAq4jdzsz8H/v9/ +4ZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CV62y6n5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50064-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCU/PGQPnL7iuPk5k9Uhm5c3OXK436IV0KYIc4yIc9LyqdlQTNIjyah/1HRLOwA6V3bK0pHctaDZMr4R4NI28X0FSaAo9w== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hg20-20020a170906f35400b00a36fdfd5fcbsi803035ejb.959.2024.02.02.08.00.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:00:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CV62y6n5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50064-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9112B1F233CE for ; Fri, 2 Feb 2024 16:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CE5514901E; Fri, 2 Feb 2024 15:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CV62y6n5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7260A1487D3; Fri, 2 Feb 2024 15:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889515; cv=none; b=GvbzoIncIWT91PazMq+kDr9H5zM8RSzhAZtfm4Cpkz9LXS39CmGnNE3hRLSoOvlhxI1v29nYMacoMh5r+jU/cFeQOAs6BnzukXIeTwFKvu49xa/jwvveAeUZtorbta5eljdbzdwdM5MCZ+fnK6lj+BlxaakmXX36Z0duShAiP+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889515; c=relaxed/simple; bh=nSRikX5IZ2J1r96VDgq1SrF4bz4pPtNZkcuO4TYY710=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sZ4vPbHv0L4mjV2Bzq+gg+exBAiiRDrschWOy8JERZXG8Kl3xRaaZHfgDVv345mVKOiLIM/MMBqEzTSQXsGjf0QkHuOP+4ztIrEIIotsCQxUJteSkWZMy0+k2pBjkcHjr0brfko94167GAavHKZ1vu+AysElgAKA8Ku9KB2Y3Mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CV62y6n5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45BF9C433C7; Fri, 2 Feb 2024 15:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889514; bh=nSRikX5IZ2J1r96VDgq1SrF4bz4pPtNZkcuO4TYY710=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CV62y6n5vEDASX+xf/AutgHxnf/P5YBnpFM/BAEhoZzY3FEbrJHCneBJB/LQZc+hY 9BbfRSPPA5ErdoGySq43TYdBMwI7BW2oK0RB1vMQtM2RDTt55azyoEC7tZ/JtPRL6H gUwPDPbYsVQMTGO1t2+WErK5yFqjfAj2Obq2v14kRac8R5Ppi+17MLKhGoC8NfoidV jeFf5D6ZpQzDwdQHDHChMB94zcz2s10npXwQatOonr+YcmHlY6zO6LueOjKwO07YRm 4ZTnYT77R+QtRI7Cpn/R5bRcMl8tq8Fej1uTNv/kpmNMa16hkZ5OvlXAmKw6Lx5SU1 hHk/xhtTjNQ1g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 04/27] kconfig: remove compat_getline() Date: Sat, 3 Feb 2024 00:58:02 +0900 Message-Id: <20240202155825.314567-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803498697192610 X-GMAIL-MSGID: 1789803498697192610 Commit 1a7a8c6fd8ca ("kconfig: allow long lines in config file") added a self-implemented getline() for better portability. However, getline() is standardized [1] and already used in other programs such as scripts/kallsyms.c. Use getline() provided by libc. [1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 53 +------------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f53dcdd44597..7f0aa39b68c1 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -293,63 +293,12 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) return 0; } -#define LINE_GROWTH 16 -static int add_byte(int c, char **lineptr, size_t slen, size_t *n) -{ - size_t new_size = slen + 1; - - if (new_size > *n) { - new_size += LINE_GROWTH - 1; - new_size *= 2; - *lineptr = xrealloc(*lineptr, new_size); - *n = new_size; - } - - (*lineptr)[slen] = c; - - return 0; -} - -static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) -{ - char *line = *lineptr; - size_t slen = 0; - - for (;;) { - int c = getc(stream); - - switch (c) { - case '\n': - if (add_byte(c, &line, slen, n) < 0) - goto e_out; - slen++; - /* fall through */ - case EOF: - if (add_byte('\0', &line, slen, n) < 0) - goto e_out; - *lineptr = line; - if (slen == 0) - return -1; - return slen; - default: - if (add_byte(c, &line, slen, n) < 0) - goto e_out; - slen++; - } - } - -e_out: - line[slen-1] = '\0'; - *lineptr = line; - return -1; -} - /* like getline(), but the newline character is stripped away */ static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream) { ssize_t len; - len = compat_getline(lineptr, n, stream); + len = getline(lineptr, n, stream); if (len > 0 && (*lineptr)[len - 1] == '\n') { len--; From patchwork Fri Feb 2 15:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp524278dyc; Fri, 2 Feb 2024 08:02:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IE570q84V0C2u0fCRUi8IB3bna4BW1VOADjYWGRS/BjirpJ/3HFMExx6LG0foYXIJOwxeHf X-Received: by 2002:a05:6a20:3b83:b0:19c:64a5:2162 with SMTP id b3-20020a056a203b8300b0019c64a52162mr5872407pzh.20.1706889740306; Fri, 02 Feb 2024 08:02:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889740; cv=pass; d=google.com; s=arc-20160816; b=zSfest0yMJe/EC8rTLLxFZYY9zd6qUcNrBn96xYxlAWQcLu6FpubhyiuEiLciamtyh 9e+fXjAegtGow95VOrftuqrv+v3gmuWKvGg309muuWdKDHvLGF8/6uv9aH+v2VzBqlyR UqlD0CGkHp0MG462xaXCAtYJinsebXetdK1SJqrzH95yZ5x2a3HHi0u4aZaXJmZ1PPp3 59qUMOF3/js8Vg720PgWu2pJj3wWQFoGC2Vn+kQXvht8/VX+citMtVmBposTAark9+8Y u+uN3KRk9QGfXh7qVpp4GZyWOQy67Cd9SnQP178eCpOQS60v7NSz0KrnNeQds2zG9aPG 0Muw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=REh71BSfWZPhzWRgxT0aWAmdVgtK9CEC8kNrWd51NOc=; fh=+YUgJsigrkUDxg/nNs/Hus7QleSQREitXRRFrrx7/rI=; b=lk1DqaX77oagcU5ASgzAUp87RxyowdIu+DTQqrSuafWzZ/+xrl0PABwGPUbNlI3bI8 pRKo43rSGa7E2tO6uqIVsv8zxZx7xod7MAevrH3dAFAWTQV0DG0LU23X7UDB90ci3RWy c/p0xzbQ3pwqLwJ23BaeGRXDe/SctNUPT8cYImYYveEDBT9cRWZhp7gh1yJVuGYAdXyO MdaczFAqvIuF390JeCr+weozlmvjxH/0iSKlthfPvGGacC8IIrMq9t5/ZuQjWhD/t1vs 8ymebvSfKA3/EmvKgTEnInlE1P0JnPxyImuiVgKk5ldcFBZEaeWrBfFKo9FD5S51OUcY 8Ckw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OzARufdB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50065-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVo4wrHuxnounqVSOeKuigzRZrWD2A9a/Ygeh11QmS2/4mgwwXLQwzOOTWkTB6/cMspvnvoYi7kb/BsTZlq0fWg7x3c6w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l5-20020a654485000000b005d79ebbdc0asi1785237pgq.334.2024.02.02.08.02.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:02:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OzARufdB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50065-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CECDF291882 for ; Fri, 2 Feb 2024 16:00:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59D0114A09C; Fri, 2 Feb 2024 15:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OzARufdB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CADE1482E3; Fri, 2 Feb 2024 15:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889516; cv=none; b=mxygVc23mrNxy1blwmc/4JYwFRPLR6YWdbcKufGd/Xp2hVZdpwRG6JMoHsRfaHRwKtChGq+OpRLls8k3E/U40FZI0r3a/ZS5xSY7fgMqyntu3DS3sGLtAMUBlSvxWDr78n2kzODhoyUUkJBfR43bXjheEH/grb9C3NuPoruMPUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889516; c=relaxed/simple; bh=QxttmJ6wH6mvkJitGwDubEDFOUUd2Xr4fYtG01w5re4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WONbj9olxerMc9dvNFdNkDvnv5vqbsbp1+zQ5gVOl4b88YUOUSIhdQfiHCmWsdAsVOiw1/dSbFjoCoU7vE3clarlJNKfDnO5r3nFtqdZYwVyQtI68YgzUka8lDf7DSYvfdpmmqZausQseG3FEWdnYrSVTunzey2OazMw5y5ql2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OzARufdB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EC86C43394; Fri, 2 Feb 2024 15:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889516; bh=QxttmJ6wH6mvkJitGwDubEDFOUUd2Xr4fYtG01w5re4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OzARufdBT5hsokUprAZCTDzxdWpGu+Zgr8rkMV6VpJTEoyd7K0Zj0EDWoTyH/8ksw NWxctv98n7HaGkAbYF3bVksUklaPM/Pj9n3MZsApGSnB300SB10Y+nGQFuv8DssnFB XIrA72wAAr/x0BZokXdPHoas20PqgAbG4SUBDbC9UdApGxyDW49W86hhotLQ9hFE25 0pPy1VpIoGOVORHKWrL2si/hI/MsHWQo69+lKaY283REIWZptn97kKBRYJQasiSbRi Dis1SEEwDJ4eabvi9qyTEh4N1/DeIyxc1hqes+Ddm63hGEgJGuUzI8cKX1xejrVm7a Y27KPWi15K/Qw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 05/27] kconfig: remove unneeded sym_find() call in conf_parse() Date: Sat, 3 Feb 2024 00:58:03 +0900 Message-Id: <20240202155825.314567-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803616673038488 X-GMAIL-MSGID: 1789803616673038488 sym_find("n") is equivalent to &symbol_no. Signed-off-by: Masahiro Yamada --- scripts/kconfig/parser.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 5ab2e3f7ca33..625224973c51 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -494,7 +494,7 @@ void conf_parse(const char *name) if (yynerrs) exit(1); if (!modules_sym) - modules_sym = sym_find( "n" ); + modules_sym = &symbol_no; if (!menu_has_prompt(&rootmenu)) { current_entry = &rootmenu; From patchwork Fri Feb 2 15:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp523120dyc; Fri, 2 Feb 2024 08:01:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMyYmI+qlcCjp2zqsufIlCyur4JO3Z1jdwz7XCaCpaGfClffjGJm1DmpIxM5khjkwvU3V+ X-Received: by 2002:a05:6214:486:b0:68c:385b:ac93 with SMTP id pt6-20020a056214048600b0068c385bac93mr7373508qvb.59.1706889668354; Fri, 02 Feb 2024 08:01:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889668; cv=pass; d=google.com; s=arc-20160816; b=FFuUKKhDIBT8MT1Wb4ymsAgH5P36f3e7SDUpbBSezSx9CsH/xstdLxKJMtzUkIAX78 MJdhCqP4JOtD8o/L+kDkHKUxZmJXAcZ+yXLf5PSPT44OxEnHaKIvCIm+ncT7CwXWTmAg Nq8RXr/rf+nWdM1b9gXk5BaZMsZYFYmzO+wpJ19O/2dB7Kao0mw8ovwTWgBTAY448fP4 ThT988enY/rF6I/dCoBNDgmr+peduTHUoz8RFrqXqbsTTqtuTv66MKG8kteheGh/gqm9 /J9VUSRWWo2cpNUxCwuy5AWWCjfZBMYzSg+1ayEiCvp4h8w7B6eE/rkbtY+25XHWSuEV FxXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bPZRnTJl96mKmIqsUkvzfJ1PLleDwTTXwypwCroKTgM=; fh=aP+utUWnRbh+gGD8hGSCe48QI4Bm3gyUJGyMTIY4NvI=; b=SkYRBecPrciqGBB44y9IUQJz3/t7njyF/JkY40O8zHsez/WEI114jNE2rWsrjIqqNE KI6A5JK9LWXVLfZLy5T7ZMR1tqbD0oa8Lwd7whSOzVA6y9NkodagZJqDwMHYJSHOJTk0 kzgyXwM0RNah9kiXN8uXCUmyYpzir4LwuI0WQOs7sV2PHT6j8muIoDlSr2jAEJXirt54 PMlP6ukw5Bc6uf3s0lBmC9ZlmWSJceUahMvGPJWUmijLnR0Gm4UW/mumHdA2k0/nV6xS E6LHygPVmyYeu3tow/IvfHBLX3Arql1cH+kWbVuzQsZFLmT9P1iSUSg7lDgdmk7L7YAN 7VAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pnIkimcj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50066-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWIdZb7SZu13CUrTZ6DYJudocH1SLOelqQh00hyyvFEWFXIsP4bRHeTkFYs30/Nu4ypLMp/oe9vyFZsx3MhaXvcVN+ifg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t22-20020a05620a0b1600b007832fdba75asi2348028qkg.356.2024.02.02.08.01.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:01:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pnIkimcj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50066-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 297D11C22F23 for ; Fri, 2 Feb 2024 16:01:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7785914A0BF; Fri, 2 Feb 2024 15:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pnIkimcj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A79C314830D; Fri, 2 Feb 2024 15:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889517; cv=none; b=AnawPIoGxsLCPtf2eiLbE7V6jv8kOOm4eLmb90OBzVZtT+uSiWVvDtsUdJyKPXOjKqq41RIoIvmI5g6a/f2rOb/cpWfIp9l1comQrpapX1Olrm4xyOSnojY7MGA7MayuZi1OVeN3w+qIi+BrehBkfbUwzpkCV6x3hKD8HJye6VA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889517; c=relaxed/simple; bh=/e+y+eilKt3GBjvzu+Sekt9FhDg+Vd4BKzKbrcOkrYI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VcKz+5i0vKCbmswHxq7Aw3QN/4fxepBBZ9dcyfXhZC6K1bwNl7Kx16TVHBCYbdc+okAtaNILV85mSTY+haVfYcz5e+iDTwkoLgyeNNMR528qfzkk8yWfo4LoNyTH8AXRGoD0WCumq9ekLpJnxv0Gnb1No9ZjktxCHcWZ3eGEY4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pnIkimcj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84531C43390; Fri, 2 Feb 2024 15:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889517; bh=/e+y+eilKt3GBjvzu+Sekt9FhDg+Vd4BKzKbrcOkrYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnIkimcj7yXLKIMbA2EwdXN2Gjp4jGovzk46bpMGsxBm8+RYhxONTJM2iLqPQfJ9J Rh39I2hn/xjT2KgHvlXmkbz/wBgpRgNwjzOC1qBag6Y44QNd4wMW/sOWMQSDc91mlH Q260z921WkCeN2y0x1rmh+Vk/lRymcY3TAV/VK4/3l1lYDIGb9TOesWQ1Vjj79mgHw Y5+bo2k8bNEeuWiVP42+r4ULgd120vKnqNj7KYPUtIATBS2/JKPFQLvj6lW6/xab57 GqLhkJKagNVO2OYkNBJMXtyFJRD9LtcXs8/UNYitsw6XLHVDo3klUIeNZS/G0y6Z5k WvRts7dICAfzA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 06/27] kconfig: write Kconfig files to autoconf.cmd in order Date: Sat, 3 Feb 2024 00:58:04 +0900 Message-Id: <20240202155825.314567-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803540637599274 X-GMAIL-MSGID: 1789803540637599274 Currently, include/config/autoconf.cmd saves included Kconfig files in reverse order. While this is not a big deal, it is inconsistent with other *.cmd files generated by fixdep. Output the included Kconfig files in the included order. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 7 +++---- scripts/kconfig/lkc.h | 1 + scripts/kconfig/parser.y | 4 ++++ scripts/kconfig/util.c | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 7f0aa39b68c1..f6a96fdddb7e 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -20,6 +20,8 @@ #include "lkc.h" +struct gstr autoconf_cmd; + /* return true if 'path' exists, false otherwise */ static bool is_present(const char *path) { @@ -972,7 +974,6 @@ int conf_write(const char *name) static int conf_write_autoconf_cmd(const char *autoconf_name) { char name[PATH_MAX], tmp[PATH_MAX]; - struct file *file; FILE *out; int ret; @@ -993,9 +994,7 @@ static int conf_write_autoconf_cmd(const char *autoconf_name) return -1; } - fprintf(out, "deps_config := \\\n"); - for (file = file_list; file; file = file->next) - fprintf(out, "\t%s \\\n", file->name); + fputs(str_get(&autoconf_cmd), out); fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name); diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 5cdc8f5e6446..8616ad83be6d 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -40,6 +40,7 @@ int zconf_lineno(void); const char *zconf_curname(void); /* confdata.c */ +extern struct gstr autoconf_cmd; const char *conf_get_configname(void); void set_all_choice_values(struct symbol *csym); diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 625224973c51..611038c502fc 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -480,6 +480,10 @@ void conf_parse(const char *name) struct symbol *sym; int i; + autoconf_cmd = str_new(); + + str_printf(&autoconf_cmd, "deps_config := \\\n"); + zconf_initscan(name); _menu_init(); diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 92e5b2b9761d..958543bb0a37 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -25,6 +25,9 @@ struct file *file_lookup(const char *name) file->name = xstrdup(name); file->next = file_list; file_list = file; + + str_printf(&autoconf_cmd, "\t%s \\\n", name); + return file; } From patchwork Fri Feb 2 15:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp524568dyc; Fri, 2 Feb 2024 08:02:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4oVljR8IU0cR84OgHOa1x5BYQ2Yb8m4PGsB4J9gZiMvfFIKSVFPSNsgrn+LIvuCCpmrCf X-Received: by 2002:a05:6a00:6a05:b0:6df:f362:f961 with SMTP id hy5-20020a056a006a0500b006dff362f961mr2559172pfb.12.1706889761058; Fri, 02 Feb 2024 08:02:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889761; cv=pass; d=google.com; s=arc-20160816; b=Nx08ktfkrV7gCSOD5CTnFlB3CI0Or+GmNLuoJkIzFCl0ek/2nuuCGvs8lSrGQgyG4r gLCeFX22DiS8uaf54x0aXtm6c2Pa1OtZiFVIEgT+ihT+/XB6sAVrTTWgcvPO4pjNpo81 yfqKKDTL5nt6z1mGTxoq8WMW4gfEKm1t+BmkKU0tOgKnQUFfk1AsDGwTiMT50krGTiFw VpVbK0drLgUy/EBSWRiEtOR4SIRDb9O8oPHVT52kRxs8UkrQ8onlWBKJMpqGCtpsAA4K KftkgclkpQsGagtv+oHdYW/WNrk8iXVPhTZoKCCFiKO4U5me1YGqw9V/T6JhkkEn9s/z cFQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xFdfeiSlO2bbOFkNP4exziW+LkA5yJj/gKQazAE8sK0=; fh=NC5Iyl4+HpFBsLoRsf6m9AIPalNFo5alz0ogpLDSB/U=; b=0mZiE8tW/PUy5EJyD4kTkBnZxsRxD6S88Y9wIb+k/saB9Ul//P8QfL/32Gz8a7GiOv UA7/cAh5q2ty4hgv3w7YnDfPZJCzYNUKZIflc2Oryx3awZj7SoWrPQ5CRoanzuZdYErT VdSYvntEv5RX2WAeorMnyUa6Qoe8EyxS6qkhvQT7FDaaj2Qotj90hTx7vaAr2HsH24g3 ce72U9CFJk7cBMwff5+4f/pmN3GGON2yrlWPwT57Iy6xLY2dwTrqaksExgsrPLcMHM+r Mi3AeUdtfd15jV7pZIzSfN9msqcT05VaFL3zV0nZ5k3CAyZJgbZ3eODSb5tl8oRX3+qv 9YVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iNYxlaze; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW4AYOQL08E+aYAIXnl0IWWIE2ZqAZKAEo4WDiCIn9Zd/g6uqeAxQzSIti7HdcpphC2kWJ82c6Ch+0fC7rLjKg/t5gCBw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e18-20020aa798d2000000b006dde31b3c82si1680668pfm.350.2024.02.02.08.02.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:02:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iNYxlaze; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50067-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3784028E231 for ; Fri, 2 Feb 2024 16:01:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A44514A0A0; Fri, 2 Feb 2024 15:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iNYxlaze" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC6651487D3; Fri, 2 Feb 2024 15:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889519; cv=none; b=liqUIMJlxlNi6InJ/rxUdHgFhyA7stYJBzad3NDohcBepiArlJprw1YDwXgz1my3ytbm9KPUOjy/tnT/VNanWC9eG1wBlkbj8/5/uFJx+7ZjmoTvEZyu8mtaSbea/4afdAhuNNzfc0MczMBUdwSH9vg/fJNs97fzuVwRH26+Y/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889519; c=relaxed/simple; bh=R/ud+/692kalgVHV0nqCoalOnQuqYPYP1Bs8zxfM520=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Knxhn2bUoDQZDT3rO/CGKv0vmYR/403atT9R6OvbPsOf8nNRg47zJD7+jVLgIKyV91fylm210Lb/84KwZYkqOne5sPKWnijfsj0sTuWjBg9+Q/oEZFqwTFG4QanXRJsog5CwfX5wRAubKe0ajkGcFnO9obg92c5NQolEyiqOh4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iNYxlaze; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE71C433F1; Fri, 2 Feb 2024 15:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889518; bh=R/ud+/692kalgVHV0nqCoalOnQuqYPYP1Bs8zxfM520=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNYxlazejOtTkfIDYgKVtb0w3qXSn/htZNacZR08Yz1ZnsDAGDrl5dXkTmKgew4+b 7B93InMSKi1t4t0iLFaJ+uxVy9U5i2I0za3d3Npy24JTbWAfzrfqPCDhIe9FCZ5jXJ xGYJ9mtlROeoV8AorAayvblqUmYHca3/iYwRqzFKXnTlfDSWyvTWhyZyYfvT6ot97w JemRdBbueOE0dyP/pCulU4fiN8qJ8/OvaeGlMkNFMkdEBGmhKVayu/MksxLyrvFjis HTPwIcxrzvhVgCOzYBp89Bn0+7ctPJNCrDn9ntOhDzKS/iXVlc3cgOWRl5V6kWpHA+ tbIAJNf1RGBfw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 07/27] kconfig: call env_write_dep() right after yyparse() Date: Sat, 3 Feb 2024 00:58:05 +0900 Message-Id: <20240202155825.314567-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803638090656735 X-GMAIL-MSGID: 1789803638090656735 This allows preprocess.c to free up all of its resources when the parse stage is finished. It also ensures conf_write_autoconf_cmd() produces consistent results even if called multiple times for any reason. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 8 ++------ scripts/kconfig/lkc_proto.h | 2 +- scripts/kconfig/parser.y | 9 ++++++++- scripts/kconfig/preprocess.c | 11 +++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f6a96fdddb7e..dafc572e7b7e 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -994,14 +994,10 @@ static int conf_write_autoconf_cmd(const char *autoconf_name) return -1; } + fprintf(out, "autoconfig := %s\n", autoconf_name); + fputs(str_get(&autoconf_cmd), out); - fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name); - - env_write_dep(out, autoconf_name); - - fprintf(out, "\n$(deps_config): ;\n"); - fflush(out); ret = ferror(out); /* error check for all fprintf() calls */ fclose(out); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index a4ae5e9eadad..85491d74a094 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -46,7 +46,7 @@ enum variable_flavor { VAR_RECURSIVE, VAR_APPEND, }; -void env_write_dep(FILE *f, const char *auto_conf_name); +void env_write_dep(struct gstr *gs); void variable_add(const char *name, const char *value, enum variable_flavor flavor); void variable_all_del(void); diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 611038c502fc..cfb82ba09037 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -482,7 +482,7 @@ void conf_parse(const char *name) autoconf_cmd = str_new(); - str_printf(&autoconf_cmd, "deps_config := \\\n"); + str_printf(&autoconf_cmd, "\ndeps_config := \\\n"); zconf_initscan(name); @@ -492,6 +492,13 @@ void conf_parse(const char *name) yydebug = 1; yyparse(); + str_printf(&autoconf_cmd, + "\n" + "$(autoconfig): $(deps_config)\n" + "$(deps_config): ;\n"); + + env_write_dep(&autoconf_cmd); + /* Variables are expanded in the parse phase. We can free them here. */ variable_all_del(); diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index d1f5bcff4b62..b9853d4a891c 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -87,14 +87,17 @@ static char *env_expand(const char *name) return xstrdup(value); } -void env_write_dep(FILE *f, const char *autoconfig_name) +void env_write_dep(struct gstr *s) { struct env *e, *tmp; list_for_each_entry_safe(e, tmp, &env_list, node) { - fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value); - fprintf(f, "%s: FORCE\n", autoconfig_name); - fprintf(f, "endif\n"); + str_printf(s, + "\n" + "ifneq \"$(%s)\" \"%s\"\n" + "$(autoconfig): FORCE\n" + "endif\n", + e->name, e->value); env_del(e); } } From patchwork Fri Feb 2 15:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp523606dyc; Fri, 2 Feb 2024 08:01:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhQDr/h38D2sLNkmS0tKiwvgyzIQypcQ5aGKB3F2yFxu6B0hK2b1Rm/cwuWLy3S3DhrPMW X-Received: by 2002:a05:622a:248:b0:42b:f649:ea5c with SMTP id c8-20020a05622a024800b0042bf649ea5cmr5287651qtx.14.1706889693509; Fri, 02 Feb 2024 08:01:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889693; cv=pass; d=google.com; s=arc-20160816; b=tAp8mWUA40Rn9/Sn2D9Cln3zIS09DDWgupUTxujfZvCv3hTWlmFGaEjD8jcXJTgEec WAYafc+0bEx08BviGP6yUhI5TAIAJAdiW3CUHXfRWzwCONf3WOVhzOM6xD6PnvLlJwss nHI2WC4xJFxZpx+yqQxx0g0MD+ClDirp2CLp2XWu56YAx1P4Pg4oFtD2pi/PXYxyGKBT 3ZeHXB9aNQHIk4TwRQPjrz6cTVFKnuM2ZhIhQCn0tneiu3evsKd7TMo1O4DXDK5Ul3v+ lengIJMnZCmZtBVS0AT41XpsXBmjrxkQfyD+Bc0jwD5i+DT0ZXYtVJmQl9E6R2eDHCFy gQSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HL+0Ax/mBl4sIeBqc9DicVsFSr6E2E2mC1nZPChb/cU=; fh=HOrrLOOoVl3h4JCcGkmbWM2dEE/6LZX5K1ucGLTNGf0=; b=F2Bx3/Dsp/upY5ZpT0lUIOKNXkYtIE9Ipxy+rQf+J7WmgWCzwcD4PAA8kV3DaF50x9 LoAHy6uXoxGOqa1E4qxEpEiv5657Onb6Su8g0a3I8v4xDmdckIdYtrrEvflFQCNyai/G /SyjFO9UxuCC97V2hTYXXZpr8CKT9eGte+XAKBMHI0JOTKlyDvmJ88Kl8pFYsHhIFe77 HgZfREcYyrn+3fQdFEP8g4Z+rZMqENy1qhfapGja4C2lB0ZyWvXP39En61KO9qbzSb3W h1qvYtlqs/LMJGg1nLXHekqyJ0oFkfGSI6+TNcAVx1X/wr95uy1IRsCmOr6p1A1ohHcj ceNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="M43/Ok1/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50068-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50068-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVIzTMizr6m6RSQTJOg11JglMKgqWvPslV9LSpkcx46BFEnt9ui7B2EG9qs6RasUOOpi5TzTcXQbA+OMj9n4Cg4FXbktw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bp37-20020a05622a1ba500b0042c0b72fb09si112207qtb.139.2024.02.02.08.01.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50068-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="M43/Ok1/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50068-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50068-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 478A51C20BC8 for ; Fri, 2 Feb 2024 16:01:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B050914A4CD; Fri, 2 Feb 2024 15:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M43/Ok1/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA55A14A0AB; Fri, 2 Feb 2024 15:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889519; cv=none; b=JEJTQAqbeePQQDES1nGgrr55vwOz+047CdiSkyCqqKyM6dkQGTa0MBeui+wLicsJTnlgdvkfw1cpmBNBo7ettQc2cIRn3UQaoyiQATcKzgWAZDNBoxk2SKdPGYZRQuSN30RkUD2iT7blAv0eqmHLqmC/zSSDQ1r5J8XdGFjCtLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889519; c=relaxed/simple; bh=6fgo0sRjNFgx+31jjBB4hfJzesvi3QurT2SN9+UQZOc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZgrIK0BBf1wdfNKG+0qspwYpos49k23xKJxK38cXpcDlcilBzVnnxHVIQbib3appwI1IkfHBDa28XheiZS53tydQ4TBTRUHVRZoZD+U3CmBKqy0izU58yjfNzWXLYiZjyz5kIHrFlQf/7INsjNbNNkjdZdJHZPPad0k02M6rAPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M43/Ok1/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBA29C433C7; Fri, 2 Feb 2024 15:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889519; bh=6fgo0sRjNFgx+31jjBB4hfJzesvi3QurT2SN9+UQZOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M43/Ok1/EiL895vytxYLJICTMw4tmYih6gGNoN69mxCxzVNpA6pNFX1yIxYTv8AV3 CuINhA4h/5ghM8yLCdurI9dqa9wXeR/ATg8CMBFoYnHkQkCHbQHCQbp3FJqdI9aTkV tAWPnJAFNDTNA0VdPTf3knNglwkR3axa6PQMcXCLkv6RNEaKym4ATEjupRa+yKdTxv IljyEMvCDvsPN1FoG4w8JklfWerggQiNk51ykC4cbGrmwT+Q+gSiJh9DMbFqw8FNf/ 90O9NnmcTQLZcR5ye35mjXIhS9IgTbjepWMcBmHqZC/bhlr2nJ0ah1nC/cRv6/PUxl QTN+OBYS9ZYJA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 08/27] kconfig: split preprocessor prototypes into preprocess.h Date: Sat, 3 Feb 2024 00:58:06 +0900 Message-Id: <20240202155825.314567-9-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803566929238496 X-GMAIL-MSGID: 1789803566929238496 These are needed only for the parse stage. Move the prototypes into a separate header to make sure they are not used after that. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lexer.l | 2 ++ scripts/kconfig/lkc_proto.h | 13 ------------- scripts/kconfig/parser.y | 1 + scripts/kconfig/preprocess.c | 1 + scripts/kconfig/preprocess.h | 19 +++++++++++++++++++ 5 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 scripts/kconfig/preprocess.h diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 5f1bc3320307..1bb372868ecf 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -14,6 +14,8 @@ #include #include "lkc.h" +#include "preprocess.h" + #include "parser.tab.h" #define YY_DECL static int yylex1(void) diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 85491d74a094..94299e42402f 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -40,19 +40,6 @@ const char * sym_get_string_value(struct symbol *sym); const char * prop_get_type_name(enum prop_type type); -/* preprocess.c */ -enum variable_flavor { - VAR_SIMPLE, - VAR_RECURSIVE, - VAR_APPEND, -}; -void env_write_dep(struct gstr *gs); -void variable_add(const char *name, const char *value, - enum variable_flavor flavor); -void variable_all_del(void); -char *expand_dollar(const char **str); -char *expand_one_token(const char **str); - /* expr.c */ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index cfb82ba09037..ff68def09a2b 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -13,6 +13,7 @@ #include "lkc.h" #include "internal.h" +#include "preprocess.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index b9853d4a891c..12665b981c3e 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -11,6 +11,7 @@ #include "list.h" #include "lkc.h" +#include "preprocess.h" #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) diff --git a/scripts/kconfig/preprocess.h b/scripts/kconfig/preprocess.h new file mode 100644 index 000000000000..a7e4a550638c --- /dev/null +++ b/scripts/kconfig/preprocess.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef PREPROCESS_H +#define PREPROCESS_H + +enum variable_flavor { + VAR_SIMPLE, + VAR_RECURSIVE, + VAR_APPEND, +}; + +struct gstr; +void env_write_dep(struct gstr *gs); +void variable_add(const char *name, const char *value, + enum variable_flavor flavor); +void variable_all_del(void); +char *expand_dollar(const char **str); +char *expand_one_token(const char **str); + +#endif /* PREPROCESS_H */ From patchwork Fri Feb 2 15:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp523831dyc; Fri, 2 Feb 2024 08:01:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEceJSxU3K+vdmsJELIzpmpKKWh4hR+V5nz3wPTL24a6YzPMi1RJDScHjKD3x43hDcX17L7 X-Received: by 2002:a17:906:58f:b0:a36:4908:1dcc with SMTP id 15-20020a170906058f00b00a3649081dccmr1824968ejn.29.1706889709766; Fri, 02 Feb 2024 08:01:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889709; cv=pass; d=google.com; s=arc-20160816; b=QHBrNnapIPwVEjNZo6StfciSaXDoVHzlgCVlQSaA0rnojWvxCbdcQc7DCOX0qA93IE YTHUWG4r56VmXes5SWgp/MjlZPfK//mCmwE2rzBb3UF9YYeZZDUZih9C1pFC0RB2vFWw EmJ8R+3wy4MK9spF400sPYrYa3LD74a/wP5csHM98Q3Do447/CNTFfbuErycICCp61Ko 75jAfTO3NX2flgWaIiWw+bPH0AK7/NhjyEmH5oxPo8/yzBiyd+z43TTnviN4G2OuO/Ej X9bSbNErElXhj5lh2hCErMSW6smJEno5n8u9e0LHm6/N2ZbJkBd341IDklF5Gjy0JD9m Hmxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dlQ7d85NLEC0EOGfUhi7jE2eHoVaWLZ3lGUOc/ffu+U=; fh=agHhKXeL7FArZBspE1ypzoDNnjalKbYpDJntXhZgbag=; b=jtjHYOShMwSeZcXJJ7iK7Ix1jnDOjrOmIVt0HNavzzxUzURV9bFti7R1w6u6GCM4SU uA9Am0YJPKwPIEKs5lY8o9Xwf7AZbdFJnKD7GdgV7AC5eQwPx4PjyoAeCWpw4C8gknc1 7uTJZOdua05oyUQLmQzLUSCnbv5TUBQ5dirnOYq2gq3N0SmKDrFs76WzYaNDL6d5xPCQ F/v+vylfDjJRNLNqkIvUz02ZT1N1+4OY83Z5omQvnSJwfIf4n4Kk5oGibCGy2u+/kAMG RO4H7UND20nHOxF+0JhrLUbU5MN5Cfa8HEbc8zfHkPJXHDNHZnqBV07o6u+Fhhcl8hAx HgoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EtAWmj2G; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50069-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50069-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW36vCGHTTWUoT1bxxDAJ0JDlLjTcskpAUglRkgpjoPX+HtM9kla3q83wIEs4oeVq8n136WXYOK3T6FnbZ0XpjpnfOExw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l18-20020a170906079200b00a3661c8ad2fsi956933ejc.605.2024.02.02.08.01.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:01:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50069-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EtAWmj2G; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50069-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50069-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E7891F2117F for ; Fri, 2 Feb 2024 16:01:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA33A14AD12; Fri, 2 Feb 2024 15:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EtAWmj2G" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A7A614A4D0; Fri, 2 Feb 2024 15:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889521; cv=none; b=LUEmCLpak0qYw3CAaad0CUhZZlBkMGa4F0EbzEMHIGn/qd/HL2pp3nd2IP8Dibha24tW/L4UIVQfqzZRYcjwZ+W89Qi2bQ2X9iFFzY1wpiH5Gb8AtBqwtBhQaNxltOpaQ1DhryfOxaV46hBkr9IV47laTxyHxU3fRKW0jJjWty0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889521; c=relaxed/simple; bh=8wkF4aCE3aM2rNs899RXOTttKfK3DnuDTaZdLUAKOrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JDq4Xyy14MPvM0t4SgDZDev0qqOjj47pVmeu6NrZwpstMQ8AA8Sqcy5/HdoERLp4jreXrNTVvnLVrNjg0TapXopVzzYvmWuUNb3YXu/M8q4Ge3nehjpXc/lrHlJhGZUtqa5KyFt3F+8a12CqJeB1NY5NuVi8/DYxBL7ZiQqKm0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EtAWmj2G; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56A0C43394; Fri, 2 Feb 2024 15:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889520; bh=8wkF4aCE3aM2rNs899RXOTttKfK3DnuDTaZdLUAKOrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EtAWmj2GnZ9LalaqkZJtJmN54oRDwbsmKa3ZSy+feXm/bK+8miHaLi8rLJ0KlGz17 svTAIO0xE2Ik+DZ2Vvhrag3+bOCH48ienK0/8htM5PaL0gs/4SmRNRCcqTmsZGnvmI LjGUl8x2/UgxL8QW1gPMExpWq8jy6eFZSIGoHFBRetJti4/kVh6XkllGlRcWqEmF76 f9OCQdGw4j8ILqN5FZ49QYK2qSBpAkAh4C5ZHwi+qUX7Yzp+0XBYRmMtoJj2whcAG6 qWi7q5Dw0nbZtiNhex0wQs8RI/D6n1342U+psgnRSa1g9ZRQtgK9WojsAjbTHX9+cn 85Ml7qSR1H2ew== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 09/27] kconfig: replace current_pos with separate cur_{filename,lineno} Date: Sat, 3 Feb 2024 00:58:07 +0900 Message-Id: <20240202155825.314567-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803584492978268 X-GMAIL-MSGID: 1789803584492978268 Replace current_pos with separate variables representing the file name and the line number, respectively. No functional change is intended. By the way, you might wonder why the "" fallback exists in zconf_curname(). menu_add_symbol() saves the current file and the line number. It is intended to be called only during the yyparse() time. However, menu_finalize() calls it, where there is no file being parsed. This is a long-standing hack that should be fixed later. I left a FIXME comment. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lexer.l | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 1bb372868ecf..540098435a3b 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -22,10 +22,14 @@ #define START_STRSIZE 16 -static struct { - struct file *file; - int lineno; -} current_pos; +/* The Kconfig file currently being parsed. */ +static const char *cur_filename; + +/* + * The line number of the current statement. This does not match yylineno. + * yylineno is used by the lexer, while cur_lineno is used by the parser. + */ +static int cur_lineno; static int prev_prev_token = T_EOL; static int prev_token = T_EOL; @@ -279,9 +283,14 @@ repeat: * of each statement. Generally, \n is a statement * terminator in Kconfig, but it is not always true * because \n could be escaped by a backslash. + * + * FIXME: + * cur_filename and cur_lineno are used even after + * yyparse(); menu_finalize() calls menu_add_symbol(). + * This should be fixed. */ - current_pos.file = current_file; - current_pos.lineno = yylineno; + cur_filename = current_file ? current_file->name : ""; + cur_lineno = yylineno; } } @@ -462,10 +471,10 @@ static void zconf_endfile(void) int zconf_lineno(void) { - return current_pos.lineno; + return cur_lineno; } const char *zconf_curname(void) { - return current_pos.file ? current_pos.file->name : ""; + return cur_filename; } From patchwork Fri Feb 2 15:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp538043dyc; Fri, 2 Feb 2024 08:20:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IF97ptOONS1AkkV3xq7lG5qYozD/1DUDSiewzZw6NDueMi+eg/2wZoYUs7cRBX9gDS2wUJJ X-Received: by 2002:a05:6a20:1930:b0:18b:902f:892 with SMTP id bv48-20020a056a20193000b0018b902f0892mr7470154pzb.40.1706890826206; Fri, 02 Feb 2024 08:20:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706890826; cv=pass; d=google.com; s=arc-20160816; b=lPlEUMZLEoChicQOWXk2LOwtvGYS5rh/xnzKz1aP1cD7lWjgc0a5LJq1JnJwKoKcN+ TadjPgxmwH44Xj60hK1MnTBCOCqx0+7+XRcFV+wPf7IYhGBJASAGBkYqmARM4ivZG91w S84amHN84Efc4IxuNFYdyeQVGTGEH4lp/1jpgP8yHeZwjVzD6w7l57fgyi4RQjaz6H3l vjRqdOusvzON7pHi8ge5e788gHB9ItlhWPzqWC1z8yV/tR2+an9WT5u/WTf1GOCTwKG9 AmkLRArznMCy2c2bCBp6+Nw5Q7kBKn1+xdqjpW+z0BgpaI+Zu8MdJIx6uMUSmh5CAgT8 +cQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=E5IKiyrPssKzg9XtkxXIt010Jc6ZzrtM+iQ2J8oaPBM=; fh=8G0bXN2Vdmn/D0uyAA8CnMP0gwbpN7oO3kBIpFseRqE=; b=KqRd6xkTuVipiTeaWa/TgtqORahjKNGIBPCvpbPGRCfEVsa2Jqx53Wf77ffkYp0qMw stOoT4qRQWXLV3q0g/U49iYFarXC52LByMWoV9RLVo81ORR8QJ7+87BItBqfF8l7EJR7 M35vp6SZf2tSarBGyURPiJsil0XL07pp0HWs6pZtn0a7imnjKi/HW4OxT3kGKicPyefX L3e+TWwdI0DIXMskZpXR743rlSM3UvEkM6xlBZLO1Fmh/+K+Gc/aeetoTTYqr0vdUjXS buzzsnmiW2TkCgqtC3qfIdb+2yMM4mId3B5RpYep3l9DgS6xUKQRE+MAaj394RMjYuRj Si1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p0C4So1+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50070-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50070-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW1+S17Ymir04yt7abCnHuRn1rHlm7GtyQT8jZtZjdawiTIjBhGVx5O/AInePU75LhCel3c1HKG+t9cMSID0uj5KMVtEw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d3-20020aa78143000000b006dde4453540si1738146pfn.258.2024.02.02.08.20.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:20:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50070-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p0C4So1+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50070-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50070-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A968EB26C39 for ; Fri, 2 Feb 2024 16:02:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7200414C59B; Fri, 2 Feb 2024 15:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0C4So1+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C096514A4E0; Fri, 2 Feb 2024 15:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889521; cv=none; b=kDGYq9YA7x8lUd8gkpjjwHaEseP5zkq3XGQjqBiSsjP1dKnxUVsreB2gzCIEumqaDZZ/wunVc/1YnysJhOCraeTGt58ONux5lWcdqtV26Vd2cpoTef7pKTj37Qml27Ci6tRk1gm62Q4IubknJ9KJm5dV9qaSVcBoRy1+6+jN4Xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889521; c=relaxed/simple; bh=iHM8Es9wLEFNU6sshaQjaQFTw2pijimnR0FYXBXj7F4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QSsW0SaU3mLatyyPpeLLHf/leJCCxemvt95ecdqevRhzH33idUWqyBMUxqMXu7iDKWS+dSogpEYg2FDwMCD/ytqqK+7H1lC7oRx+HbjikLCpdqaBRDuq/ccsL/aF4GOchBOKEv3oqzPhCKtJn1TsTdNQta7HZeqrn2k82KHvN+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p0C4So1+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF894C43399; Fri, 2 Feb 2024 15:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889521; bh=iHM8Es9wLEFNU6sshaQjaQFTw2pijimnR0FYXBXj7F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0C4So1+9VMNvuKisbwVe9z+KtLjpJDVG3acEzCU05Uj8F1wvC/Fw8tuA5QU9jOAU 9XRyExVSBzroC+XcUNTaRbvP7KnjxQ0fuAzCFg4BMdP1tyPLHbHjrWJLO5d9Cb55PO OLYALwt+X9PS1cMve7NS7URkvy8ehpyqfD6/CwXtQQkHWBIvnPiOYeKen1movyXNje hNmsmqb2XBB0kdxtIbe7ST8q6zHBAN1yYCdt3zFiv/37NsgJtAQwRrIA2rgRwB7cgq rT70758KUI1Y5VyHS8MN+sWZzNB1iIU0Vc9c7JR9DYYFfq0Bo1a7rGn7nlgtRz4L4V V7q4EpNBL5TWA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 10/27] kconfig: remove zconf_curname() and zconf_lineno() Date: Sat, 3 Feb 2024 00:58:08 +0900 Message-Id: <20240202155825.314567-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789804754633453070 X-GMAIL-MSGID: 1789804754633453070 Now zconf_curname() and zconf_lineno() are so simple that they just return cur_filename, cur_lineno, respectively. Remove these functions, and then use cur_filename and cur_lineno directly. Signed-off-by: Masahiro Yamada --- scripts/kconfig/internal.h | 3 ++ scripts/kconfig/lexer.l | 20 ++++--------- scripts/kconfig/lkc.h | 2 -- scripts/kconfig/menu.c | 4 +-- scripts/kconfig/parser.y | 59 +++++++++++++++++--------------------- 5 files changed, 37 insertions(+), 51 deletions(-) diff --git a/scripts/kconfig/internal.h b/scripts/kconfig/internal.h index 2f7298c21b64..788401cd5d6f 100644 --- a/scripts/kconfig/internal.h +++ b/scripts/kconfig/internal.h @@ -6,4 +6,7 @@ struct menu; extern struct menu *current_menu, *current_entry; +extern const char *cur_filename; +extern int cur_lineno; + #endif /* INTERNAL_H */ diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 540098435a3b..3b3893f673dc 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -23,13 +23,13 @@ #define START_STRSIZE 16 /* The Kconfig file currently being parsed. */ -static const char *cur_filename; +const char *cur_filename; /* * The line number of the current statement. This does not match yylineno. * yylineno is used by the lexer, while cur_lineno is used by the parser. */ -static int cur_lineno; +int cur_lineno; static int prev_prev_token = T_EOL; static int prev_token = T_EOL; @@ -187,7 +187,7 @@ n [A-Za-z0-9_-] \n { fprintf(stderr, "%s:%d:warning: multi-line strings not supported\n", - zconf_curname(), zconf_lineno()); + cur_filename, cur_lineno); unput('\n'); BEGIN(INITIAL); yylval.string = text; @@ -423,12 +423,12 @@ void zconf_nextfile(const char *name) yyin = zconf_fopen(file->name); if (!yyin) { fprintf(stderr, "%s:%d: can't open file \"%s\"\n", - zconf_curname(), zconf_lineno(), file->name); + cur_filename, cur_lineno, file->name); exit(1); } yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); - current_file->lineno = zconf_lineno(); + current_file->lineno = cur_lineno; file->parent = current_file; for (iter = current_file; iter; iter = iter->parent) { @@ -468,13 +468,3 @@ static void zconf_endfile(void) current_buf = current_buf->parent; free(tmp); } - -int zconf_lineno(void) -{ - return cur_lineno; -} - -const char *zconf_curname(void) -{ - return cur_filename; -} diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 8616ad83be6d..d8249052f2e3 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -36,8 +36,6 @@ void zconf_starthelp(void); FILE *zconf_fopen(const char *name); void zconf_initscan(const char *name); void zconf_nextfile(const char *name); -int zconf_lineno(void); -const char *zconf_curname(void); /* confdata.c */ extern struct gstr autoconf_cmd; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 2cce8b651f61..ddca95879631 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -54,7 +54,7 @@ void menu_add_entry(struct symbol *sym) menu->sym = sym; menu->parent = current_menu; menu->file = current_file; - menu->lineno = zconf_lineno(); + menu->lineno = cur_lineno; *last_entry_ptr = menu; last_entry_ptr = &menu->next; @@ -135,7 +135,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr, memset(prop, 0, sizeof(*prop)); prop->type = type; prop->file = current_file; - prop->lineno = zconf_lineno(); + prop->lineno = cur_lineno; prop->menu = current_entry; prop->expr = expr; prop->visible.expr = dep; diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index ff68def09a2b..b9d7e26fc160 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -144,19 +144,19 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL { $2->flags |= SYMBOL_OPTIONAL; menu_add_entry($2); - printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name); + printd(DEBUG_PARSE, "%s:%d:config %s\n", cur_filename, cur_lineno, $2->name); }; config_stmt: config_entry_start config_option_list { - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); }; menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL { $2->flags |= SYMBOL_OPTIONAL; menu_add_entry($2); - printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", cur_filename, cur_lineno, $2->name); }; menuconfig_stmt: menuconfig_entry_start config_option_list @@ -165,7 +165,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list current_entry->prompt->type = P_MENU; else zconfprint("warning: menuconfig statement without prompt"); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); }; config_option_list: @@ -178,15 +178,13 @@ config_option_list: config_option: type prompt_stmt_opt T_EOL { menu_set_type($1); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), - $1); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", cur_filename, cur_lineno, $1); }; config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL { menu_add_prompt(P_PROMPT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno); }; config_option: default expr if_expr T_EOL @@ -194,27 +192,26 @@ config_option: default expr if_expr T_EOL menu_add_expr(P_DEFAULT, $2, $3); if ($1 != S_UNKNOWN) menu_set_type($1); - printd(DEBUG_PARSE, "%s:%d:default(%u)\n", - zconf_curname(), zconf_lineno(), + printd(DEBUG_PARSE, "%s:%d:default(%u)\n", cur_filename, cur_lineno, $1); }; config_option: T_SELECT nonconst_symbol if_expr T_EOL { menu_add_symbol(P_SELECT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:select\n", cur_filename, cur_lineno); }; config_option: T_IMPLY nonconst_symbol if_expr T_EOL { menu_add_symbol(P_IMPLY, $2, $3); - printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:imply\n", cur_filename, cur_lineno); }; config_option: T_RANGE symbol symbol if_expr T_EOL { menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); - printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:range\n", cur_filename, cur_lineno); }; config_option: T_MODULES T_EOL @@ -234,7 +231,7 @@ choice: T_CHOICE word_opt T_EOL menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); free($2); - printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:choice\n", cur_filename, cur_lineno); }; choice_entry: choice choice_option_list @@ -246,7 +243,7 @@ choice_end: end { if (zconf_endtoken($1, "choice")) { menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", cur_filename, cur_lineno); } }; @@ -263,27 +260,25 @@ choice_option_list: choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL { menu_add_prompt(P_PROMPT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno); }; choice_option: logic_type prompt_stmt_opt T_EOL { menu_set_type($1); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), $1); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", cur_filename, cur_lineno, $1); }; choice_option: T_OPTIONAL T_EOL { current_entry->sym->flags |= SYMBOL_OPTIONAL; - printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:optional\n", cur_filename, cur_lineno); }; choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL { menu_add_symbol(P_DEFAULT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:default\n", - zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:default\n", cur_filename, cur_lineno); }; type: @@ -305,7 +300,7 @@ default: if_entry: T_IF expr T_EOL { - printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:if\n", cur_filename, cur_lineno); menu_add_entry(NULL); menu_add_dep($2); $$ = menu_add_menu(); @@ -315,7 +310,7 @@ if_end: end { if (zconf_endtoken($1, "if")) { menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:endif\n", cur_filename, cur_lineno); } }; @@ -331,7 +326,7 @@ menu: T_MENU T_WORD_QUOTE T_EOL { menu_add_entry(NULL); menu_add_prompt(P_MENU, $2, NULL); - printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:menu\n", cur_filename, cur_lineno); }; menu_entry: menu menu_option_list @@ -343,7 +338,7 @@ menu_end: end { if (zconf_endtoken($1, "menu")) { menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", cur_filename, cur_lineno); } }; @@ -358,7 +353,7 @@ menu_option_list: source_stmt: T_SOURCE T_WORD_QUOTE T_EOL { - printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); + printd(DEBUG_PARSE, "%s:%d:source %s\n", cur_filename, cur_lineno, $2); zconf_nextfile($2); free($2); }; @@ -369,7 +364,7 @@ comment: T_COMMENT T_WORD_QUOTE T_EOL { menu_add_entry(NULL); menu_add_prompt(P_COMMENT, $2, NULL); - printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:comment\n", cur_filename, cur_lineno); }; comment_stmt: comment comment_option_list @@ -384,7 +379,7 @@ comment_option_list: help_start: T_HELP T_EOL { - printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:help\n", cur_filename, cur_lineno); zconf_starthelp(); }; @@ -409,7 +404,7 @@ help: help_start T_HELPTEXT depends: T_DEPENDS T_ON expr T_EOL { menu_add_dep($3); - printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); + printd(DEBUG_PARSE, "%s:%d:depends on\n", cur_filename, cur_lineno); }; /* visibility option */ @@ -548,7 +543,7 @@ static void zconfprint(const char *err, ...) { va_list ap; - fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno); va_start(ap, err); vfprintf(stderr, err, ap); va_end(ap); @@ -560,7 +555,7 @@ static void zconf_error(const char *err, ...) va_list ap; yynerrs++; - fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno); va_start(ap, err); vfprintf(stderr, err, ap); va_end(ap); @@ -569,7 +564,7 @@ static void zconf_error(const char *err, ...) static void yyerror(const char *err) { - fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); + fprintf(stderr, "%s:%d: %s\n", cur_filename, cur_lineno, err); } static void print_quoted_string(FILE *out, const char *str) From patchwork Fri Feb 2 15:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp537936dyc; Fri, 2 Feb 2024 08:20:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoGTmC3mE/ZeRCp0nNlKMkoHYiiGWCse5vrLTdoYiuRkBnEpHk8/LI2Mu/mltfRXXIagaU X-Received: by 2002:a05:6358:278f:b0:178:71c0:b27f with SMTP id l15-20020a056358278f00b0017871c0b27fmr6258509rwb.28.1706890818357; Fri, 02 Feb 2024 08:20:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706890818; cv=pass; d=google.com; s=arc-20160816; b=JHOCkCCMMLULoEIhiBRY8RfYEUS75LDQdDDTLD0ViqxVA22ZmvXd/JVuI2z3T04skf fO3evrfIXK0bBJTy0xW4glL0+gs/bSOlb+IqEdZBM/A/zqjH6c6dlvSoAhj0BSp7aeJP TO6Z8Ta1r4hqTsRaOES1UIUk0TkrWxLv3BOvwsQGXOtp8eAmgIKkC/YhXyH2vcTYyeAS LOx4U6UXN9IjaDvoWFQnBHM1EnJcVCCdn1xtrLYcOvKqU/YC2dODEYc7p1LW+t+aAtM4 a38lGluEKYwnSdBNC0E1+ZgFpKT/xNlXZhMMXmL8WOy5ag9KC744hDMGxEKpjbQI/sQD 3rJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AGuz+NfzjKtq/JN/Kz8Trwc+4jC4oRk7bdjwacx2PfE=; fh=3sn6zj9yzEQWe01CTpOPJXU5qZZBcL84oi+zH9hOvhw=; b=a8vixeQJli2Eg1BJC3NKJWTFJK52HmTbzX0uILZixYWs4Ayd245uvTLylWs1hNZYM3 YzTsts/vZkyl+CrSX/xRuavbEDCXgkL950SGpesBl8mbOQTzdwWxbS5hBctXfJM9nx3/ c12UTtnpnMJ8xG2nylEhRWQ8GjNPbjurTlZusH8dtam6t3VSY4BAXOleYNKjEC3di3iu Okv4RQeNhGpzMRbo7It+iJ6Z6NzGsC3xDR3pxr8F1zAddlsP4XDOVGWFQ+5uzGn2BNns t+8N736A5YVjKERURvcfGtiqE/PfsRgMcmFzoafhBX+LFm4AS65dwQ2fk8Lo3lq6mPN6 inQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hyfdaKcq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUIe1yi41kWZEddo0wB7sCzrIJm2SO3aQM295Oj+GRNGplqUQSk9cIMkxmlLYwC3PkgCLUuRs3N2W9JZmK3nFKsMZcYBQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 20-20020a630c54000000b005cf58862d6asi1863240pgm.223.2024.02.02.08.20.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:20:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hyfdaKcq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1A922B270DB for ; Fri, 2 Feb 2024 16:02:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47C5114AD34; Fri, 2 Feb 2024 15:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hyfdaKcq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D60C14AD07; Fri, 2 Feb 2024 15:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889523; cv=none; b=RvoqhVaLgtpxkO14FFwlM3hFVPcgLzquhcEMX/gT0FeY8cBxOZdgMUc160bv3DgjKPGfhD3deaXXkPf6IusVOM+MOw19cXQZcexYIeYAHjsEDvU80Ae52iQsounXydxIVPRHmABQoHTUFYHq6B1rxcczP4tDL63s57nZOvMnoVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889523; c=relaxed/simple; bh=wpEp8jr15Z5cgoxaTgBZwBu3BqThuXxxzR4c/RRAaAI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BzuiSEDWgeThtnFb5yPm2h4Xp98YztDWMXFTOp7W1vvzEWP4r/jSBDO6H8GBat0w4TqfWkPrx/+tD8nRk27Y/B8T5YZBErjeVZvvVlVV8ebqbn2sFzVa6H5grAiw7sX9XXrcl9Jy8fr14zTPI//KI7nOAxEAziwOdOmeaBFC/sA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hyfdaKcq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14412C43394; Fri, 2 Feb 2024 15:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889522; bh=wpEp8jr15Z5cgoxaTgBZwBu3BqThuXxxzR4c/RRAaAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hyfdaKcqQxLrNJo8GO3fCAQwWA2hLH6RKVOD9Yek0w0JvBTyi0Wr6x8T0I/GBZnVl M3G+Sn7WXe1yuNQVzLl7zOEDh7l4xyJBBFL9Gj3VSZu+SFEfw9lq8h3VUCKZWjABzM GYRyLDk2OgBcQOLV6qxx34vA3S8c/8UcrF6k4hqYXKl0bhFtKPp4n1E44Up2/PBsfD vSqH8WQ8jMxgVZqnvoEnwWjTdaUDUGmQeGVDlVZifUCQHPMteja/qqEpnA/MFGlyg+ 4Hqa6qLughKdhv8jbpdZA9VK1Zi5xh4jkmBJRkjNdpL8nwgUVF6JZ5FYYylyFXFQ2U YA/LanjiXGH/A== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 11/27] kconfig: associate struct menu with file name directly Date: Sat, 3 Feb 2024 00:58:09 +0900 Message-Id: <20240202155825.314567-12-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789804746511485112 X-GMAIL-MSGID: 1789804746511485112 struct menu is linked to struct file for diagnostic purposes. It is always used to retrieve the file name through menu->file->name. Associate struct menu with the file name directly. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 2 +- scripts/kconfig/menu.c | 6 +++--- scripts/kconfig/parser.y | 6 +++--- scripts/kconfig/qconf.cc | 2 +- scripts/kconfig/symbol.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index e0d866569155..e8fc85d98cdd 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -256,7 +256,7 @@ struct menu { char *help; /* The location where the menu node appears in the Kconfig files */ - struct file *file; + const char *filename; int lineno; /* For use by front ends that need to store auxiliary data */ diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index ddca95879631..5ad4d2b9fb82 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -23,7 +23,7 @@ void menu_warn(struct menu *menu, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno); + fprintf(stderr, "%s:%d:warning: ", menu->filename, menu->lineno); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); va_end(ap); @@ -53,7 +53,7 @@ void menu_add_entry(struct symbol *sym) memset(menu, 0, sizeof(*menu)); menu->sym = sym; menu->parent = current_menu; - menu->file = current_file; + menu->filename = cur_filename; menu->lineno = cur_lineno; *last_entry_ptr = menu; @@ -676,7 +676,7 @@ struct menu *menu_get_parent_menu(struct menu *menu) static void get_def_str(struct gstr *r, struct menu *menu) { str_printf(r, "Defined at %s:%d\n", - menu->file->name, menu->lineno); + menu->filename, menu->lineno); } static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index b9d7e26fc160..d1d05c8cd89d 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -101,7 +101,7 @@ struct menu *current_menu, *current_entry; %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", - $$->file->name, $$->lineno); + $$->filename, $$->lineno); if (current_menu == $$) menu_end_menu(); } if_entry menu_entry choice_entry @@ -527,11 +527,11 @@ static bool zconf_endtoken(const char *tokenname, yynerrs++; return false; } - if (current_menu->file != current_file) { + if (strcmp(current_menu->filename, cur_filename)) { zconf_error("'%s' in different file than '%s'", tokenname, expected_tokenname); fprintf(stderr, "%s:%d: location of the '%s'\n", - current_menu->file->name, current_menu->lineno, + current_menu->filename, current_menu->lineno, expected_tokenname); yynerrs++; return false; diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 620a3527c767..c6c42c0f4e5d 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1058,7 +1058,7 @@ void ConfigInfoView::menuInfo(void) stream << "

"; } - stream << "defined at " << _menu->file->name << ":" + stream << "defined at " << _menu->filename << ":" << _menu->lineno << "

"; } } diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index e9e9fb8d8674..7647e3e87cd5 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1045,12 +1045,12 @@ static void sym_check_print_recursive(struct symbol *last_sym) if (sym_is_choice(sym)) { fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", - menu->file->name, menu->lineno, + menu->filename, menu->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); } else if (sym_is_choice_value(sym)) { fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", - menu->file->name, menu->lineno, + menu->filename, menu->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); } else if (stack->expr == &sym->dir_dep.expr) { From patchwork Fri Feb 2 15:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp538152dyc; Fri, 2 Feb 2024 08:20:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV0Vlvt/FySj400yFcTblBBMIuV/r6Lx53DSfrCMOcwzzmVa2lIvdzw4OOZwYGFyUFa1hD X-Received: by 2002:a05:6a00:4292:b0:6da:c8b6:6dc8 with SMTP id bx18-20020a056a00429200b006dac8b66dc8mr4521544pfb.13.1706890835106; Fri, 02 Feb 2024 08:20:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706890835; cv=pass; d=google.com; s=arc-20160816; b=gEfIsdXd6IatcQo1L+HtyEtFEV1ZfC2U0Ge28YcIsGS7e6/fu1KFoQV0WGViA8y9cY VdhOhzkMgSVZWnyCTYoFhtT5stugO2ZfGGe+8oIgswW9X+UnsGWGWAP7sehGNNQPkaPh aNJIV/LVa2Bx40W9WtcuBXMx/1Os9+40qqR53CJdrWKo+nQe0vZxGr6iHRXhO3BidXzl eWKeGGJcd226ig2j3jpfdYB9HUlrgofpm6N7G966oFa6UJZZcgm5mQ1L4x3mEj+dENYe L3M+ssqadu3RiYdmuUsWPydemrpHJklWB5lljgc0tqm3SqVOan3sJiUdlix9uD8Lkpam /7rQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LQ5mO9jjweDBTwE1eAdqMX6S5tXU/G0Srf5ZpL13tBU=; fh=tO85BFdM8ksQn4VVl9OeEqFMOCLRh5G5zxBIokf+D20=; b=FsT/DeHoZg54g79SPhmQSVrOfGFtCREOzCffZMGFtuaC9Td+micQnp79FhIglQi/LU hngJoLdLwkcoIBmTkbUUfzkrECUmrtBXPIh7rJGEUiG4GQaTr9FBtDkoHnuKOHdSNpnJ tct3BjzcHhMWyja3Qz3Pw6sthv8ojnQZsgZD5yTDtWhCuqY7aHaMzvmCrwPxjJ7wGrrv FNLwtoDqELvdMxLQO8KzMHZS6FeEWQcCSlaxAkk/tsE9dZiOI5xNPCLl/2ODKEJEciBb ld8ZIP7Z2SD05E1ZQXC+sGJOsikCv2i2cCy99mdJaTdDrxWm2cSqeRZDpnA24chKyC+Y s/eA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=haZEUMwo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50072-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50072-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVaZ5CLV4m7t+bCEPexW1PY5Z+U/d7YHWwt5TGXPMRFFS4BKniHBIsA2G7fqvj8a9i86Gg2e+knWx+J2RWs3sjja0cTlQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j21-20020a63cf15000000b005cee03a5355si1739782pgg.518.2024.02.02.08.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:20:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50072-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=haZEUMwo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50072-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50072-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D011CB27085 for ; Fri, 2 Feb 2024 16:02:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D295C14C5AA; Fri, 2 Feb 2024 15:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="haZEUMwo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0083314AD17; Fri, 2 Feb 2024 15:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889524; cv=none; b=MG6skY22OZ76jO0rLClWViiGwSWXs4IG7/JieSuqbVI8wp2Ag+iyMWGnpf/eFsrsj04L/VR0i2Ye7XaxQRNyEteQ3Y9LHhR61vkrVfbyQFs1PYqXv1wLv9VkWRh/UGSwJhEhYeMY90vaTE9o0A13fZRgXSq9PlmrvHshsbI0Jeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889524; c=relaxed/simple; bh=gxW0tHjrvGhvoRdxh0sVyK7nLpSQS+pdJ3RujiPPaL8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i1xKyf51bpgxxbrfrpDaznc+B0puwNgrOLBseI6OcISVL42sQvyic2Ty05zu+nlm9+3kMNzrmiT0kpJuVBtEmNaqDA5RnyI3xfp7BuFoTtmJc46wGQGsSXeRhqGufZj5DokQ4p22BpcIG4nq0N+Q9l6ux+rnMZUWv0+KSvm7Kfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=haZEUMwo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EF78C433C7; Fri, 2 Feb 2024 15:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889523; bh=gxW0tHjrvGhvoRdxh0sVyK7nLpSQS+pdJ3RujiPPaL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=haZEUMwoK2qxyOJAE+WGgjaRtCm2pJJSqqFFaOAutj0bG88g+6wRlPQqUJsaKOjho sJ5q8YkizICQyuM6iy/ibz2PR5eT7sIZYPVROWbeAlDPal6ev/DUJRhOIs7MZuWCTN z3ZCPFcP7rTtGFZylp5Lce3S0Yxpuj3lJju4ho5cf4j5kstVpUITCMNvpX2DHxZjsY 6gxP3/s5LbXCxUjvhF/QiMkzHBGNXsiGNhvHpBWiQntJ1II2SZY9zJf59uAkV50JZJ FwpVEnypXXQ4EGtXP3nBV+R/zReZNiLh0mcekvV5vU5lVR3ZFa8w9qXBDYqb1Hwoaq hrgOdTIp0+HQA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 12/27] kconfig: associate struct property with file name directly Date: Sat, 3 Feb 2024 00:58:10 +0900 Message-Id: <20240202155825.314567-13-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789804764509044927 X-GMAIL-MSGID: 1789804764509044927 struct property is linked to struct file for diagnostic purposes. It is always used to retrieve the file name through prop->file->name. Associate struct property with the file name directly. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 2 +- scripts/kconfig/menu.c | 4 ++-- scripts/kconfig/symbol.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index e8fc85d98cdd..037db39c5bf0 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -195,7 +195,7 @@ struct property { struct menu *menu; /* the menu the property are associated with * valid for: P_SELECT, P_RANGE, P_CHOICE, * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ - struct file *file; /* what file was this property defined */ + const char *filename; /* what file was this property defined */ int lineno; /* what lineno was this property defined */ }; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5ad4d2b9fb82..0ded0b1830d0 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -33,7 +33,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno); + fprintf(stderr, "%s:%d:warning: ", prop->filename, prop->lineno); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); va_end(ap); @@ -134,7 +134,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr, prop = xmalloc(sizeof(*prop)); memset(prop, 0, sizeof(*prop)); prop->type = type; - prop->file = current_file; + prop->filename = cur_filename; prop->lineno = cur_lineno; prop->menu = current_entry; prop->expr = expr; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 7647e3e87cd5..dae630a74e50 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1041,7 +1041,7 @@ static void sym_check_print_recursive(struct symbol *last_sym) } if (stack->sym == last_sym) fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", - prop->file->name, prop->lineno); + prop->filename, prop->lineno); if (sym_is_choice(sym)) { fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", @@ -1055,28 +1055,28 @@ static void sym_check_print_recursive(struct symbol *last_sym) next_sym->name ? next_sym->name : ""); } else if (stack->expr == &sym->dir_dep.expr) { fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", - prop->file->name, prop->lineno, + prop->filename, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); } else if (stack->expr == &sym->rev_dep.expr) { fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", - prop->file->name, prop->lineno, + prop->filename, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); } else if (stack->expr == &sym->implied.expr) { fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n", - prop->file->name, prop->lineno, + prop->filename, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); } else if (stack->expr) { fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", - prop->file->name, prop->lineno, + prop->filename, prop->lineno, sym->name ? sym->name : "", prop_get_type_name(prop->type), next_sym->name ? next_sym->name : ""); } else { fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n", - prop->file->name, prop->lineno, + prop->filename, prop->lineno, sym->name ? sym->name : "", prop_get_type_name(prop->type), next_sym->name ? next_sym->name : ""); From patchwork Fri Feb 2 15:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp524784dyc; Fri, 2 Feb 2024 08:02:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYjotDCLlsxU7NL/FAD+J3tNJRqH5QKY44KiGgNDqVsyFMXI31itqo1tm0GsOH5OXcdH5e X-Received: by 2002:aa7:d497:0:b0:55f:6b8:b2fb with SMTP id b23-20020aa7d497000000b0055f06b8b2fbmr82953edr.1.1706889776963; Fri, 02 Feb 2024 08:02:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889776; cv=pass; d=google.com; s=arc-20160816; b=ogpZW3t/TqgwBE6YZusBno4GFKrIgovyc60AjHNht+/zme8gdwnUnKGkP6+V08hu3l pVfDHRY/+3QfCOt3q8Bcc7uew0DF48CumhNpzuJUrwYl7NwTI1u8w0vPkYTPWLvuURga YNgz/LAkR+/Y8ULsSq/nfEqF2RCeXjOFobv85RRlU12Dxng4bhFHzFtfdqd5tqPolUfV i3FDF93wpvWlkbv3PkH59idW9hnuv6VRc4iaTsYvER2BHZMYSczM3WEvTmAjhH2GaAG2 38EpsehUg+lY6DWrkmdn0jfjsbdMW6P40ZJ01VcnhPAKYcBom5TVFMmVunXhn4RhA/ZK GJ7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cmkvO66yCzqBLo7bvX4MPYC6PO1rABxxI6afIsfoo2E=; fh=G8A8T3N7eB0jrAf5QTAdmp2IdzTXjw9BmSDv6M28ANM=; b=rt++T7B/LXr9x85m1jjBOX7voWfsMhEaoQGxfNwtEMfzwH3zyEUr8lx87YNUFhJVmx /hY624qJfAKKngr20k1vNkAOq6vNwmLhWZcY1FO/JXAYlH8SfqB/pBiXuEkzpwN84I0o LT+tiC2w7OS0Wn6nUA9gzX6Ygoh69agKJ784tPbcKXOK/5tEeJAIMxGowVxeK5Lqbchh 59gZLB2HQHTrsXbvOWEAp9JehiyiRcqTnJB1PDdlI0qoY8xZUEkZvVQImC1RfAz0uz2Q Bv9YQguxtpdWLg1kUSd6fD/6Eegv5jOR4hNSsvCSRIR0rFzEQSnHQrl28tRWovJ+d3Cz P+rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lt21hQpl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50073-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCV8CtF+9u4pQve/N0KxQTzneI2D15Zrq2OBBoqArCyLSE0PcZi/jCybY764GmgRDjtW34jSVnla3hJbw1YOPEkg2uwbGQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b5-20020a50ccc5000000b0055fa3cf748csi889826edj.175.2024.02.02.08.02.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:02:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lt21hQpl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50073-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C7B31F2279C for ; Fri, 2 Feb 2024 16:02:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B25714D43E; Fri, 2 Feb 2024 15:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lt21hQpl" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79229146916; Fri, 2 Feb 2024 15:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889525; cv=none; b=jJSjd8Z/hae/rwvbIzxusJF9/yFHKFZ4DCYdwJs8MTtYBE3/2Q77gLMgCmX2hZ9sTfF+5LhdTVn1NGqtqeel5qM0JuGj3GvfvWaA8LfuyWkUWlqszWeBwKCeXRjJmkxTrCm0sqJYl/7TQNhTHANDZYQYIBF1i3NrDlv0Ee85UJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889525; c=relaxed/simple; bh=3mNf0ZSZTDvEBfE5C19X3m4Dwgk1+kn+7smzF28GagI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s9nkBG7it1P5pDRky9Moqmflh2YkpbWO+Cbh+m820nwk/+5UJafvRrsUqiclou+15T8T49QELilj5Jza/aEjsnRjrJ3o55ElQP3vphIhE8FKG/hgcI3PQ9kcGmPgqsMZVEFOs3R1Y2sBAu0Qd7lmDbL/iArY/l/HyNiIuWOfVds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lt21hQpl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49ECBC43390; Fri, 2 Feb 2024 15:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889524; bh=3mNf0ZSZTDvEBfE5C19X3m4Dwgk1+kn+7smzF28GagI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lt21hQplVb5hpQcN3B1YGxA27O40fqtkxEjJknCLhtioRhIMsTNmsb2AaIeWKOaTB Y4f8jNCpoET6elOnrKzGV5o19M3YyeAiJn872n6ngh9D6m8QOMm2wtlai2wuap1aGN oV9tD0Ny4rsv+vCq6fY69G2Zy4vxnoy9SRRlu8A7PpDB0pJDom37XqBJxtiEGzv/Nw K4oM3fpAH+dRbd+SBKgTOsk31SoNWBy98uCB3uuvDPxt5s0kF4J+RzkrME80gtZlNi 1ZC+5LmxzFpsP/d7YNQ0cXArHQ2TR90yD/q+IJgRda+P0tOJPTReTHSsenHzpME11d sMjETBZ+AetuQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 13/27] kconfig: replace file->name with name in zconf_nextfile() Date: Sat, 3 Feb 2024 00:58:11 +0900 Message-Id: <20240202155825.314567-14-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803654607412525 X-GMAIL-MSGID: 1789803654607412525 The 'file->name' and 'name' are the same in this function. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lexer.l | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 3b3893f673dc..35ad1b256470 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -420,10 +420,10 @@ void zconf_nextfile(const char *name) buf->yylineno = yylineno; buf->parent = current_buf; current_buf = buf; - yyin = zconf_fopen(file->name); + yyin = zconf_fopen(name); if (!yyin) { fprintf(stderr, "%s:%d: can't open file \"%s\"\n", - cur_filename, cur_lineno, file->name); + cur_filename, cur_lineno, name); exit(1); } yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); @@ -432,17 +432,17 @@ void zconf_nextfile(const char *name) file->parent = current_file; for (iter = current_file; iter; iter = iter->parent) { - if (!strcmp(iter->name, file->name)) { + if (!strcmp(iter->name, name)) { fprintf(stderr, "Recursive inclusion detected.\n" "Inclusion path:\n" - " current file : %s\n", file->name); + " current file : %s\n", name); iter = file; do { iter = iter->parent; fprintf(stderr, " included from: %s:%d\n", iter->name, iter->lineno); - } while (strcmp(iter->name, file->name)); + } while (strcmp(iter->name, name)); exit(1); } } From patchwork Fri Feb 2 15:58:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp524919dyc; Fri, 2 Feb 2024 08:03:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfY0r2CILc5zABwciYsm+i1+NA7DAI73Yti+kbbuGNgZkvVh81hJuq5SvJ8wPQttXMu0xL X-Received: by 2002:a05:6214:240f:b0:68c:45ad:4bb5 with SMTP id fv15-20020a056214240f00b0068c45ad4bb5mr10917212qvb.46.1706889784725; Fri, 02 Feb 2024 08:03:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889784; cv=pass; d=google.com; s=arc-20160816; b=m70h5Iph5kOwkjnb5yaQ+JGScDeaRwZWWWtC3EQMn+tq1matKSaJTAiFXJI0X+trPd rOHhrqiUFq6Bz/wf1+E8YeXCTm8tGAZYw1MpPQ4LDNoz7+HTDrjIMvDsAPl+25xKRH7o y0tgmK2Hx5IdN15aiaD6GlkkPe9nmNlYr4jQ/giNoogiayYR9X2DUKub2GANUILgqtap 714tWfwbPcNTZ/Oh2TOusP5JRIV2swK6v1N9GcP9danjQIEZFRud3W4xDVLD7q3nqR8B 4IPPlTwNaCDup7uIFp2gqeDeJ/ykei6w01spA/mt9bgwq7sD0ldWKVrYxCS8su7gmtE/ 6yUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cd1qjeS/p6DU56G0uFPeHWezvGWFbQdflShpN0xZwbs=; fh=mQAt89bPpm8iAERMU+9nv14LW0qmMucqqrPjhkAgEZQ=; b=wf6aH3W03rBsaNLPfp/f+tl38wSEBLJm4nM3RQT6n2bjWZyAR149P5843cCRWwCy21 GcVB2/d5ovTQzkgElGeejw1XQA2nqukiMFIjETyrlObFc1qWGO8DT/ffsBjQAX1qQXpo 3i9NjeohBQIvdzlsVDRQRb3pYyC7AiCrDF83jQTsmSPu7+eLYIvA29WSmc+hx7Brs3ou zcgg9VOa6mbuJ7RynN0s1C2bdm+1BiLZmymCKueymRSkmcl08y5OrXyUppQylSeVbBbo eS64dpG4cWmW0NDkdToJFuSoe5eLNfGuZes2gTRLJ3/e2bP2MXd5nU/3y90WQAjRx0yq OGVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JCMA1Rn8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50074-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50074-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCU3xsRYuNe1e8tfYQofTQxt+swvYzqqYuYOJm8Smqy4Z40VdpLqIq640o/xMRnKKPnpEqpyyOrWFjZ1v3jU52yFtdMBag== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cp14-20020ad44aee000000b0068c4a759f9asi2153374qvb.586.2024.02.02.08.03.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:03:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50074-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JCMA1Rn8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50074-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50074-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 800561C21BE8 for ; Fri, 2 Feb 2024 16:03:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFFE9146916; Fri, 2 Feb 2024 15:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JCMA1Rn8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 363DE14C592; Fri, 2 Feb 2024 15:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889526; cv=none; b=OdcD5WW3hss7KKmdx7z45yWZKSCpZV3Mahjaxeamc3T/PJAmzbslRHnXGP5s+X8Pa0BhHQkEnnqKNgABBIBH2gTFukYJLmzceZD8kyjCrBWk7/7fIGjHjjulVNljNZAF/s6X/BiEPJBLBdWtCfNyoZclQOv9xmH/fmcibXQl3DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889526; c=relaxed/simple; bh=wHVLJm31U+fA47auTd9+uU0toq5m5ICZ6w8E0bowFB4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oIYcfXroHojkMMwMJ1BtujEeGeVhzhUNuz2fs3jCODmHydDrl0GNGzs7jK5U5L2lJyhKuyiCtgk2IOTww6o4eBqmGSnGqZ1+R0AAgRY/Q4++D3JiQ9DKy8x3i3p4172xcik9dXKspT3Abc58wzM7T6rvpt3is39L3orhVxG/IJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JCMA1Rn8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64F8AC433F1; Fri, 2 Feb 2024 15:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889526; bh=wHVLJm31U+fA47auTd9+uU0toq5m5ICZ6w8E0bowFB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCMA1Rn8MXKR7+56P3lyywwXtbccGzQZOw5FBgWPErFILpiZ0uSjyFghWApxHNGUh OnOktXn61WWGGT3uDO99/3EFVQYYBcbIoTL2aLOR5EDjiyw87BMO9+/VwdE7ZdgAfU TFIJHl0crcCB3RnriYixGgQsGJXfHQ24eIvWa34KW57CP4dk0WibbrU/kqjMWRuojw lDDzqTjr5thlDu/8kvZsSzjVmtk6m14f60pqLOglw1INbYZkKqZhEUP8UplL5bXun7 eIZauYpw3kewrzGTmRpu9jIEx3PRp+bnL3UD8esWOXjPvwIY74JvMssFZoU9x1z9Bz zXynzYixu/vNA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 14/27] kconfig: do not delay the cur_filename update Date: Sat, 3 Feb 2024 00:58:12 +0900 Message-Id: <20240202155825.314567-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803662635203691 X-GMAIL-MSGID: 1789803662635203691 Currently, cur_filename is updated at the first token of each statement. However, this seems unnecessary based on my understanding; the parser can use the same variable as the lexer tracks. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lexer.l | 17 +++++++---------- scripts/kconfig/parser.y | 8 ++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 35ad1b256470..28e279cd5a22 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -274,24 +274,17 @@ repeat: token = yylex1(); if (prev_token == T_EOL || prev_token == T_HELPTEXT) { - if (token == T_EOL) { + if (token == T_EOL) /* Do not pass unneeded T_EOL to the parser. */ goto repeat; - } else { + else /* - * For the parser, update file/lineno at the first token + * For the parser, update lineno at the first token * of each statement. Generally, \n is a statement * terminator in Kconfig, but it is not always true * because \n could be escaped by a backslash. - * - * FIXME: - * cur_filename and cur_lineno are used even after - * yyparse(); menu_finalize() calls menu_add_symbol(). - * This should be fixed. */ - cur_filename = current_file ? current_file->name : ""; cur_lineno = yylineno; - } } if (prev_prev_token == T_EOL && prev_token == T_WORD && @@ -407,6 +400,7 @@ void zconf_initscan(const char *name) } current_file = file_lookup(name); + cur_filename = current_file->name; yylineno = 1; } @@ -448,6 +442,7 @@ void zconf_nextfile(const char *name) } yylineno = 1; + cur_filename = file->name; current_file = file; } @@ -456,6 +451,8 @@ static void zconf_endfile(void) struct buffer *tmp; current_file = current_file->parent; + if (current_file) + cur_filename = current_file->name; if (!current_buf) return; diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index d1d05c8cd89d..e58c24d2e5ab 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -488,6 +488,14 @@ void conf_parse(const char *name) yydebug = 1; yyparse(); + /* + * FIXME: + * cur_filename and cur_lineno are used even after yyparse(); + * menu_finalize() calls menu_add_symbol(). This should be fixed. + */ + cur_filename = ""; + cur_lineno = 0; + str_printf(&autoconf_cmd, "\n" "$(autoconfig): $(deps_config)\n" From patchwork Fri Feb 2 15:58:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp525111dyc; Fri, 2 Feb 2024 08:03:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/bxFH0u2r1KrrW+lcKrfWAMByVjiYCA7mBfVu9g59DbIzYnLAqY92pVpdiRycN5okvJG1 X-Received: by 2002:a17:906:1f07:b0:a35:34c0:e1bd with SMTP id w7-20020a1709061f0700b00a3534c0e1bdmr1817762ejj.67.1706889800803; Fri, 02 Feb 2024 08:03:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889800; cv=pass; d=google.com; s=arc-20160816; b=oFzJNOOZSr9fWhGSOrXrUt8W22r5rkXxE32FMLcLMXsnnWVBdcJ+sJ4szWnjHfId+L 3WS+4I6V9RiEcVtGd+cN4+X1g/9um78hc+qDDG8APXJAYAxN6C1CFWF1VTC6CLeDrNu+ iRWtoRiMOSljegGUJ8ZRTBNVeN2WE2vY3ERMTxur1qPMU+YoZhpNqZJvCwxgi7gO0n/n qs7FCwjMb0CmC2rup9w1Ud+dc4VHknKHNyUZvMtIUZ/UOgY421GFYw3+hPlDUMPrNFeD MbRqJbLuRwMGpVEg6sc/cvkaGKv25RIRAUvZP9pGkUP/F1GXrumKb3BSqivYzWzs5Ibr g2Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WWu3G3HIhWVf6gf3vW6uwq7D5j1SQkeriVAIgn0F1mM=; fh=y0PvVvJZCTm/wpkFbS+zGwbOht9zpZ3b0gfSVPfDwsA=; b=Uod55wsJI+aAap1urV79I25lqsRyjwodUg9wMyXr+QSNODOUOmSYceat+3UXS7qH2b JVZlbokKCHaDBT95Gwi8Erem2SHRV5u9bZ+FSThAUDPtTXLjfSXxL8DAXC/C1iJQFIQg G32JeTIG51DuMNbZlROjHwtA2jJI67IcXjlR6l2K1JdM91rNf356rddk44SQ7sCjAcNJ Yenl5uA4yF/4Zrn+yqW59Q+wLyVMvzpRMjTU1iq9893vvPgTdv6MD3XEakt1jd8Y5Ods dYQd0eXBfmkA+YTInQKqTgNe6QqohKZB2U4mcaYGXpDLEl/xhxsPI+rZuor4bO2Uwcfw Yt6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+pSyziy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50075-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50075-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW7UjlUtQ81R8mgQTvyb0HnqJmzlF5f9IHPFL+uZ3urzbQ+dmVmNZLpl2X5IxbiI7mTQazDa7+dYqm0KTySRodNUHtMIQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j24-20020a170906255800b00a31c7cc9cf0si912767ejb.384.2024.02.02.08.03.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:03:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50075-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+pSyziy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50075-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50075-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5F9301F217AD for ; Fri, 2 Feb 2024 16:03:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 131D214E2D9; Fri, 2 Feb 2024 15:58:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q+pSyziy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5000F14C5BA; Fri, 2 Feb 2024 15:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889527; cv=none; b=o4+wSrR1oYYrWqMFB9/ziEqKH+o0+OTc5tcWMUQm543MCiRsBPvc39OthNbHYyH7BD3Nwn48vHfU+2r8XdUWKsgW+2jDFtFzQIGdsx7+uSAee681jQKBr5bVDKBRbYREmGTzU3vICf2F8yp43cGBG+MGkafoQsGjv1di3XQU7qs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889527; c=relaxed/simple; bh=iQfJFbCfo6g+jL93vYCPjdUyp6aRJx+Zc0bUp6Uw6sQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A4f5E0y/wi7hBk17YH/EaMLHnAdhIrL1shc6NesxIN7WL0YY09H5QHqjRtqJFKt3gbYkGv443fuuMLgp9Dv8kYiE9CvI2AkJ1qj86xVuBR2XULVEtBgEBT6w4AoX8UOyfMZMUOB8WtSXZGMLYN0iJyCNuF4LV1iPVqYHj46cpLM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q+pSyziy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80171C43399; Fri, 2 Feb 2024 15:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889527; bh=iQfJFbCfo6g+jL93vYCPjdUyp6aRJx+Zc0bUp6Uw6sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+pSyziySnu8Lju8MA/luc1F9M6N3CrRz4pHXOEMWnZXGqN5iYhwHBWgOktnOqE1R i7dHfKfihIoTBvE47kKMInfeaDOLQFPHdA7vWX5tRq/la63RVmqdPI6ZIHe+0dbnR9 pooakkKDIAc6ljG1mZYRr0EzjLN5HimPYRGQDubE7IGx4iIrlH21Jx5wN+8QU42Qnn W+x3w+87KpYfsRei5OI5Z5Z9VqcWUFgUTHWIGWtDs11PHQHGiR3f/4Q0FkAmBjCjQU ie3gcXs2gKlaO+DIylXw+TCj7MKXYrZLsZ6NLU3aK4uipyrXRjUJ2O2GoUGQvXl7ui YOz6a36G4Z9Fw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 15/27] kconfig: replace remaining current_file->name with cur_filename Date: Sat, 3 Feb 2024 00:58:13 +0900 Message-Id: <20240202155825.314567-16-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803679706354253 X-GMAIL-MSGID: 1789803679706354253 Replace the remaining current_file->name in the lexer context. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lexer.l | 4 ++-- scripts/kconfig/preprocess.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 28e279cd5a22..db2397c4e343 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -84,7 +84,7 @@ static void warn_ignored_character(char chr) { fprintf(stderr, "%s:%d:warning: ignoring unsupported character '%c'\n", - current_file->name, yylineno, chr); + cur_filename, yylineno, chr); } %} @@ -253,7 +253,7 @@ n [A-Za-z0-9_-] if (prev_token != T_EOL && prev_token != T_HELPTEXT) fprintf(stderr, "%s:%d:warning: no new line at end of file\n", - current_file->name, yylineno); + cur_filename, yylineno); if (current_file) { zconf_endfile(); diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 12665b981c3e..69b806a6d8b7 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -9,6 +9,7 @@ #include #include +#include "internal.h" #include "list.h" #include "lkc.h" #include "preprocess.h" @@ -22,7 +23,7 @@ static void __attribute__((noreturn)) pperror(const char *format, ...) { va_list ap; - fprintf(stderr, "%s:%d: ", current_file->name, yylineno); + fprintf(stderr, "%s:%d: ", cur_filename, yylineno); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); @@ -123,7 +124,7 @@ static char *do_error_if(int argc, char *argv[]) static char *do_filename(int argc, char *argv[]) { - return xstrdup(current_file->name); + return xstrdup(cur_filename); } static char *do_info(int argc, char *argv[]) @@ -185,8 +186,7 @@ static char *do_shell(int argc, char *argv[]) static char *do_warning_if(int argc, char *argv[]) { if (!strcmp(argv[0], "y")) - fprintf(stderr, "%s:%d: %s\n", - current_file->name, yylineno, argv[1]); + fprintf(stderr, "%s:%d: %s\n", cur_filename, yylineno, argv[1]); return xstrdup(""); } From patchwork Fri Feb 2 15:58:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp526835dyc; Fri, 2 Feb 2024 08:05:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjFJoOIRVz4lVXR2Sk+b1nAF4zjVnFs8wpSJH//VCF1wXtvms0opb/6Ns01wGIDvzwkZvR X-Received: by 2002:a17:902:d58c:b0:1d8:ee41:a825 with SMTP id k12-20020a170902d58c00b001d8ee41a825mr3307800plh.37.1706889915046; Fri, 02 Feb 2024 08:05:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889915; cv=pass; d=google.com; s=arc-20160816; b=AGY4lVdcv2mJsVTpPl7nApVAx72m5th1iCZeMCR1trHenv4QHSuHY02InfTxG8vOj7 Yc2zjpmGjAHQfsDXPxeO0QpsfianPx55ZNSBq9wtvzUL57DFMgeN5QrE+HHDo8tbAmLi yGKfJg6oR2Jf6jSNsGtFzPRL0Iw4xzRjJHwlK4l7Lo/eTMqUvf3qOw01RtZkqQ3+uNL9 e1FUZYq8FlgNKNqCyrQRTzcDflk3Vy6xxx7oYyAakTlYqxMFMNoRdwAxcDnNV1SsHL7G 3mbwwZVuj4vuLrQdmjMxQH9KY/XWI4s2wZvb3WVhWCa8JQwsXRpY9UFbq0bsrgfInAF2 8WOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1TI7xBYL3AWKUo2RVm157M/whRDFy0+OCYXNeMoY93I=; fh=qbu7gs4z9Z4rG2EegggUdLH1KsGJOYFf79J3RQJ6r0U=; b=odoP8yjlxEOrAvJBPkCMwWnLFaQ6AS4CbCaSIIsjgYpYlvDOoLQg4LJGxF09JpikOr PZ6iwoFiZNiv44rt/lQRdlj8x53qLeDvB9rKX5ApQGdShEOwZDvoP+8OiKFkCfj36UE7 wGbFRsxS/B2Hb2MQ6wLdY/LZanwmSAVa5QoM0eNGEui8HUuhtRascdeoSsL3vVffhuq5 XXo1QNwItLrh+R+taMJN6UwTnFiWWEJDRcCdqcYgyZIZVA2ATHpSfVwbxNO9sc6vm/iL smcHewnqSGfUzW4/qhA3gDpKnsT+W3pUxPpW+k3WkZLEpTkOjmTE0vZgHP149m49aai/ UmwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dzabgXpC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50076-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50076-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXJnACIy58HFGg507MSfXPZu6SydRYADf4poMqF+n8eOJ6KXPd4q8CfLehPdsaT3e3On8kj0Dq3jcQvgLAQJ1VZrMWgFw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q9-20020a63d609000000b005cdffe116d0si1700793pgg.532.2024.02.02.08.05.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:05:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50076-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dzabgXpC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50076-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50076-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CAB2828B4C6 for ; Fri, 2 Feb 2024 16:03:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6102150985; Fri, 2 Feb 2024 15:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dzabgXpC" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C060D14D44A; Fri, 2 Feb 2024 15:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889528; cv=none; b=vGlH9TsSE/tRJ+ywiiaT5NYZj8a4j0EykBecXIyKxZKtutsXWJJjJGLglRVN1MoHuDuuaTGVU+tv5U4xDgCsPnCxG9rN0TEPS4727OX6iBeulwELS/IjTpjl+w4w0rjK5CBzlpecCfqOol/EKCfYPKtfEiPHYAQ8ubkkRa1HMjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889528; c=relaxed/simple; bh=XGcvVEbpwvjpyVs7c6B8hKp1bvuUZzxnFMzXDLqk/JQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VPNiRrLPU/jPSnV/SCOyBZ6g22DKKGTKBYabJ/orl5DZJAVcuTGTZMV9ilqb/G3JzoMIwumxTYCI+iJHs77HK5p4CvHLlHR3Uje0HfHKTYpGTOec67tQsS+ECwYwkwJhlovnTd3ZeaZO3hJhEf3ToRRdpozwpp4W0j/L1CgWWHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dzabgXpC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AD2EC433F1; Fri, 2 Feb 2024 15:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889528; bh=XGcvVEbpwvjpyVs7c6B8hKp1bvuUZzxnFMzXDLqk/JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzabgXpCqPZGOOmY2HjYfoRaQDHhH7gXNlUAfg2P6hpRiGf6F3shxQfVIzl6C6H8V H629bnB/SwuPIYgpAW4laXhFoErIRoCJPjwTxtVtFuyk/mgAtUpgucIM5BRtFg5ihl R3bhViG2PdiimUVEWaF5M/Alv8ybNbdikVc7M2dh0dxaGtMZgRbrRlF3KTXnF2EIdn L392q5NJZ8paAoI1TBlbTXvE+uFQ93YTVTdEmxTGWUBKtP2pUhfXjBGyV0E1HNe3tG tJ/A4brR7IGKyHS7OII9DgpSZlCXigSn0aZ80ULa8jqLimKyMY7jtqLi14Y0Kch4uu owQfRWCOAHwEw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 16/27] kconfig: move the file and lineno in struct file to struct buffer Date: Sat, 3 Feb 2024 00:58:14 +0900 Message-Id: <20240202155825.314567-17-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803799387475273 X-GMAIL-MSGID: 1789803799387475273 struct file has two link nodes, 'next' and 'parent'. The former is used to link files in the 'file_list' linked list, which manages the list of Kconfig files seen so far. The latter is used to link files in the 'current_file' linked list, which manages the inclusion ("source") tree. The latter should be tracked together with the lexer state. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 3 --- scripts/kconfig/lexer.l | 50 ++++++++++++++++++----------------------- scripts/kconfig/menu.c | 1 - 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 037db39c5bf0..85e0d1ab3c8a 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -19,9 +19,7 @@ extern "C" { struct file { struct file *next; - struct file *parent; const char *name; - int lineno; }; typedef enum tristate { @@ -278,7 +276,6 @@ struct jump_key { }; extern struct file *file_list; -extern struct file *current_file; extern struct symbol symbol_yes, symbol_no, symbol_mod; extern struct symbol *modules_sym; diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index db2397c4e343..71f651bb82ba 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -40,6 +40,8 @@ struct buffer { struct buffer *parent; YY_BUFFER_STATE state; int yylineno; + const char *filename; + int source_lineno; }; static struct buffer *current_buf; @@ -255,7 +257,7 @@ n [A-Za-z0-9_-] fprintf(stderr, "%s:%d:warning: no new line at end of file\n", cur_filename, yylineno); - if (current_file) { + if (current_buf) { zconf_endfile(); return T_EOL; } @@ -399,19 +401,20 @@ void zconf_initscan(const char *name) exit(1); } - current_file = file_lookup(name); - cur_filename = current_file->name; + cur_filename = file_lookup(name)->name; yylineno = 1; } void zconf_nextfile(const char *name) { - struct file *iter; struct file *file = file_lookup(name); struct buffer *buf = xmalloc(sizeof(*buf)); + bool recur_include = false; buf->state = YY_CURRENT_BUFFER; buf->yylineno = yylineno; + buf->filename = cur_filename; + buf->source_lineno = cur_lineno; buf->parent = current_buf; current_buf = buf; yyin = zconf_fopen(name); @@ -422,45 +425,36 @@ void zconf_nextfile(const char *name) } yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); - current_file->lineno = cur_lineno; - file->parent = current_file; + for (buf = current_buf; buf; buf = buf->parent) { + if (!strcmp(buf->filename, name)) + recur_include = true; + } - for (iter = current_file; iter; iter = iter->parent) { - if (!strcmp(iter->name, name)) { - fprintf(stderr, - "Recursive inclusion detected.\n" - "Inclusion path:\n" - " current file : %s\n", name); - iter = file; - do { - iter = iter->parent; - fprintf(stderr, " included from: %s:%d\n", - iter->name, iter->lineno); - } while (strcmp(iter->name, name)); - exit(1); - } + if (recur_include) { + fprintf(stderr, + "Recursive inclusion detected.\n" + "Inclusion path:\n" + " current file : %s\n", name); + + for (buf = current_buf; buf; buf = buf->parent) + fprintf(stderr, " included from: %s:%d\n", + buf->filename, buf->source_lineno); + exit(1); } yylineno = 1; cur_filename = file->name; - current_file = file; } static void zconf_endfile(void) { struct buffer *tmp; - current_file = current_file->parent; - if (current_file) - cur_filename = current_file->name; - - if (!current_buf) - return; - fclose(yyin); yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer(current_buf->state); yylineno = current_buf->yylineno; + cur_filename = current_buf->filename; tmp = current_buf; current_buf = current_buf->parent; free(tmp); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 0ded0b1830d0..b879576d1ab4 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -17,7 +17,6 @@ struct menu rootmenu; static struct menu **last_entry_ptr; struct file *file_list; -struct file *current_file; void menu_warn(struct menu *menu, const char *fmt, ...) { From patchwork Fri Feb 2 15:58:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp526950dyc; Fri, 2 Feb 2024 08:05:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2S/4NzO/DSyzT/JjIWTUqjvhbRGf5SUz/uX/QAlVKVaKC+uPGnkL2PivqtWQ4D0j/+48e X-Received: by 2002:a05:6359:1585:b0:178:c7b6:b563 with SMTP id jv5-20020a056359158500b00178c7b6b563mr5015548rwb.15.1706889921676; Fri, 02 Feb 2024 08:05:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889921; cv=pass; d=google.com; s=arc-20160816; b=mAhO+ASuUXmHUhN1ju5bIqceh0MXzywmVGMxzqMYLU2ErvP58OJp0Q6LvUUYAn4hYX X5vREi5bSovJUhuD5aVz95j8c6uyYDMhGoldBjDHOpTmpZydzvDGlW2dOj44Q0LxNapL HyHu9S2832RihEtSz8l86E3rUK1nTnh+oTN85oUnTnwM+43fTXtteSspAK8riHrk9bYm zFFV1N7tFBomZOfr/Tck8Z6BxHhFoQTFUTJGGqzdHANjQuUBEvo/TgBn0Lw65fs/DHF4 Sk+UVixypQuRQsKSlbNX1Fkow0W9Fuct4YslNv5/09IgXjRZU48g1TfSNAOBJQibuj9q NCnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HWmeTPA/Ax1NyR/7++x0YsmWZu/yoNEoSMQEnvO7fJs=; fh=XvXBAVkG9Wf5gfAkxTJkpKjfwRX03goNR7v4Ue5DiUA=; b=hBHp1dto0C8sekiYM6xs/egXS4QDUPA5XY/QCfns3BrJqzXMiqL47Kq01rL3zhDPbw 6IKClscyPHtVt2ZWphP6JfqblNWwAWfxu9mUn6WzbTrmb13xOR/LbIkn6xThWWoPIMJQ 692dn03sV7ibWXNJj0Ume4DbqHWbsKYZFefgZwE7RsTlwwrfsJfwyPLMshPBvp/YN3do u69PnzPK/NL/27puYZTXl/hBKZ1ygaSliur6VuIUzt8WiBx3CgOTdzsU9P7n9GMBqHrs LL+c0AtoYvSJIfMe+uJwizV7nrIMDyylkbOIVnLzVRHOluyH7ltRIcYxCM0+yhn/294r ra6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZpRuZ5dP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWqisqqmsD7kE2wMyrF7ciD0d3U+YxxPk4xuEh3d8fA/zJ7Zy1SZ/9GrnlQuSEKYYFKJW8MP3Q4r7HWLwksqxcCpP9XcQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c22-20020a634e16000000b005d2eea210fesi1780369pgb.887.2024.02.02.08.05.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:05:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZpRuZ5dP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5891628BB9B for ; Fri, 2 Feb 2024 16:03:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9287914E2E9; Fri, 2 Feb 2024 15:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZpRuZ5dP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB4E214C5BF; Fri, 2 Feb 2024 15:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889529; cv=none; b=JV9SaGvZUcvdXrWK32GMP4F4/MgNjQ5Jxm7NO9bxuvYFzWBm2eLAHMf+dJxtUAPeJb4qS+v8mTrpU65aJtP5siauzOyfqBTZHeeNoL8exUQNEPt1o5j/TP8wka99tFgnezC6ux7yrM5NHWxcf6+EpqDwuX7GJA92xPAOI7qKJYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889529; c=relaxed/simple; bh=6HFGjcFafgAEeyFv5246DWk9iueSVCKM1qtHrZhaPSg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p/Jjm0lB/o/H3az7EboYsMqQC0BG3drg4/3TNsltXpOKtGzBjpekIfzpMCgA534pLNi0Q9vMiy3dKW1aaQGhJ1KnSqPCxV5OwNWy6MyHDzI6e1kB+86HlnUOwGR9NYzvgAK4nk+6nrB/DrSGeHZ45nzowo+4UxGDqXIHjrMTnZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZpRuZ5dP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2705C43394; Fri, 2 Feb 2024 15:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889529; bh=6HFGjcFafgAEeyFv5246DWk9iueSVCKM1qtHrZhaPSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZpRuZ5dPoGqLFy/mD0TUPIugrzKvZNC3pn/xuM5uXOnMUEqeAnO4mP8J8AHOovi2e V9bv0V1t/dUZRfMyT4NzZyNHZMzVHge3oW8tFHgt00Ksh1X3PvC+4dmZYbcJBhXUG/ gcsT67VmRc4T6xM/t/Ax5DuasRogKbT6srB21N5znhBBAnURVRBwa6AM+Rndjg7ToG RbRqnyuADceWcSz5Mc2mJAsN55XxxsNFrtEicOnr2TmRRo+jXuh9lI1chiuVFMNbcE jISsQmgtU8+B5ipXmnnXFbx7nN30wzCHwCpSfLoYghJRfeUrjNLQI6tnvWRrtVOf3q rw+/eJ5ierp4Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 17/27] kconfig: make file::name a flexible array member Date: Sat, 3 Feb 2024 00:58:15 +0900 Message-Id: <20240202155825.314567-18-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803806811611421 X-GMAIL-MSGID: 1789803806811611421 Call malloc() just once to allocate needed memory. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 2 +- scripts/kconfig/util.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 85e0d1ab3c8a..760b1e681b43 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -19,7 +19,7 @@ extern "C" { struct file { struct file *next; - const char *name; + char name[]; }; typedef enum tristate { diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 958543bb0a37..2636dccea0c9 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -13,6 +13,7 @@ struct file *file_lookup(const char *name) { struct file *file; + size_t len; for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { @@ -20,9 +21,11 @@ struct file *file_lookup(const char *name) } } - file = xmalloc(sizeof(*file)); + len = strlen(name); + file = xmalloc(sizeof(*file) + len + 1); memset(file, 0, sizeof(*file)); - file->name = xstrdup(name); + memcpy(file->name, name, len); + file->name[len] = '\0'; file->next = file_list; file_list = file; From patchwork Fri Feb 2 15:58:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp525836dyc; Fri, 2 Feb 2024 08:04:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfKpRYpl1srbYvM7USwsoilUC6bBVvgL8xIL8XWtnMABztQx5VVHABsJz/2YEb8WWdfgzl X-Received: by 2002:aa7:d482:0:b0:55f:84a9:9000 with SMTP id b2-20020aa7d482000000b0055f84a99000mr75813edr.3.1706889849860; Fri, 02 Feb 2024 08:04:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889849; cv=pass; d=google.com; s=arc-20160816; b=Gp0pyBxS8bPCNaj1gwhOl6UXmh4Ipk7o0ActhhuIg9FUhQ8FVhsYNdw1htkMDSDSQb AkkuTVrtLsYl7onZHFwYMiS/35MgXHHNGFa94II3ofOuGN5+637MquLj8jN2E2QIRcn0 kG2o17MdweuVSMMFOFD3EN4qYtXuXT6uA+xb3GHJl6lvs65mXqQX6GUiPA0uFu9fHrQu d2qWjqWfgM5z5pfWSJrMdWqrffqHiCTAWCgY6yWujKnZlTgyLeh1H7BX3UpwAUIL9GO3 YXw7I/c4SDl4VeZxAwd9fpvNHHO753+OQGVQxtcPcq0qY/wCMZmufAp7m69AwQ+6RbR5 4n3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M6sVzujSK+4WBQOJFHZdT/t/h22RZuPbcdrGbVKqQgc=; fh=D+j4CM3pQg5XNakmP9O1XuZyyWGOiM6jzSb4Ts9xKWw=; b=Opzuhrs9WDLtDrXsYqh/76glKjsRMBh+e67C/ivLSOw0yF34TzBlq0vz0OCFMJA05D g25/DTMkxyv1vXLKOI6l4iZa7xJTq4Xw7yb7d5BNeIWafubyZFzex/tpl2CGRRPyZQ4z /bOCROZNHHypX2vM5gqA65kR/SbtCQKxCIoSxTNxENRqoLsKQaDt3dHwzFuJDoudeJmz RyWXP4MpIGcRxetBkBD0sOc7HSYpEZZeaRLezMpWb1GxXSFYiufT/vuH9UGKhB0135I7 I9NhN+dJhQdTANEcSzIre2lWoWlhqq2fwm9ajnWBUU2fxZupGElcYBYO1SzrUNwbi5Zr chHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U5hexQDB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50078-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50078-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWOaKauw07ZNkAi+HBM4LNc+QXHAtxzK+yjc1vcPRSbPjUa9CO4WcjkpT4sABqjmWFPx2U6puwlnybuF1y3xXIsjM+/kA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ck8-20020a0564021c0800b0055ff3c80869si627190edb.362.2024.02.02.08.04.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:04:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50078-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U5hexQDB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50078-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50078-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7441A1F213DB for ; Fri, 2 Feb 2024 16:04:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 702AA150986; Fri, 2 Feb 2024 15:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U5hexQDB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C1C91474CF; Fri, 2 Feb 2024 15:58:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889530; cv=none; b=Df1xGNeHmxIjyKq0I4aOVqjnordNutv5/neGb0ffFABc9qdJ2ua0Mb37u668Tg8q2d3uhNhd07xpxck9/yc0j5EuRzvuvL+jgIdJZsMO13LpRy+Np/4IilIte1N53/SgFGxqZGPYXVbmy7L0D4VHNXkegkmEOlTmyMUl/YRTxVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889530; c=relaxed/simple; bh=peshsf7E5lCNRV8+zJr6/ajkl2ZpyVwBUVUkykrK4Hk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kvUatAVbEJtOdqoQ00CNq6i24+RtTI94e6F5nGjJttEgQu3X0Q5Auqf8UoFcIMBBLJnvNWvqbC1BcDUowlW3MDOhJscU7GRDebwD1GuBPEkjycJkLBMFs7MUkFubvYCI0hZnMuty/aArzdXmguyYwWRs95oV1GQlFHca2VxZYrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U5hexQDB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB573C433F1; Fri, 2 Feb 2024 15:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889530; bh=peshsf7E5lCNRV8+zJr6/ajkl2ZpyVwBUVUkykrK4Hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5hexQDBI2JZxNkl1U0WzrOHVbWR5yUFkSZTnMNyoaK8jpz1fbdNxgWRsdrmPwsfO zFI416IPRWrUvtONVxEcRpvdV4mG1sLe67QTZfl0CvfZaYUD+fiR3Rgl18uRev9PwF 4lf1/A3btCeCMr1UeU+QRIvM6rk8M8QEk4aKbMIDlcL3P8nlI8GfQs047swEzMCd4+ OP9xrDGEDxTll/Uc5M+eNoaRX5nrQBKAuxSnuxjhsquX1zAyqyYQK4Nb3loZZ1kTJ/ ZNhRs7f9yBhhD1K6yqYruJVytpWNyaCHaWBvWBYFz1dwA+4E3X+YMJUXSN2SQDgJuG fYmvHc9upPitg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 18/27] kconfig: change file_lookup() to return the file name Date: Sat, 3 Feb 2024 00:58:16 +0900 Message-Id: <20240202155825.314567-19-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803730993805924 X-GMAIL-MSGID: 1789803730993805924 Currently, file_lookup() returns a pointer to (struct file), but the callers use only file->name. Make it return the ->name member directly. This adjustment encapsulates struct file and file_list as internal implementation. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 7 ------- scripts/kconfig/lexer.l | 5 ++--- scripts/kconfig/lkc.h | 2 +- scripts/kconfig/menu.c | 2 -- scripts/kconfig/util.c | 13 ++++++++++--- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 760b1e681b43..d667f9aa041e 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -17,11 +17,6 @@ extern "C" { #include #endif -struct file { - struct file *next; - char name[]; -}; - typedef enum tristate { no, mod, yes } tristate; @@ -275,8 +270,6 @@ struct jump_key { struct menu *target; }; -extern struct file *file_list; - extern struct symbol symbol_yes, symbol_no, symbol_mod; extern struct symbol *modules_sym; extern int cdebug; diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 71f651bb82ba..89544c3a1a29 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -401,13 +401,12 @@ void zconf_initscan(const char *name) exit(1); } - cur_filename = file_lookup(name)->name; + cur_filename = file_lookup(name); yylineno = 1; } void zconf_nextfile(const char *name) { - struct file *file = file_lookup(name); struct buffer *buf = xmalloc(sizeof(*buf)); bool recur_include = false; @@ -443,7 +442,7 @@ void zconf_nextfile(const char *name) } yylineno = 1; - cur_filename = file->name; + cur_filename = file_lookup(name); } static void zconf_endfile(void) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d8249052f2e3..71afcbd56273 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -52,7 +52,7 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) } /* util.c */ -struct file *file_lookup(const char *name); +const char *file_lookup(const char *name); void *xmalloc(size_t size); void *xcalloc(size_t nmemb, size_t size); void *xrealloc(void *p, size_t size); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index b879576d1ab4..f701382f8a69 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -16,8 +16,6 @@ static const char nohelp_text[] = "There is no help available for this option."; struct menu rootmenu; static struct menu **last_entry_ptr; -struct file *file_list; - void menu_warn(struct menu *menu, const char *fmt, ...) { va_list ap; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 2636dccea0c9..610d64c01479 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -9,15 +9,22 @@ #include #include "lkc.h" +struct file { + struct file *next; + char name[]; +}; + +static struct file *file_list; + /* file already present in list? If not add it */ -struct file *file_lookup(const char *name) +const char *file_lookup(const char *name) { struct file *file; size_t len; for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { - return file; + return file->name; } } @@ -31,7 +38,7 @@ struct file *file_lookup(const char *name) str_printf(&autoconf_cmd, "\t%s \\\n", name); - return file; + return file->name; } /* Allocate initial growable string */ From patchwork Fri Feb 2 15:58:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp541198dyc; Fri, 2 Feb 2024 08:25:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA+YPGcW5Wnki0lo7J2WbtlingwXBlzQb2z9atzAxXC/F9LTO/6qCoT3rk+vrqYEhjc+5h X-Received: by 2002:aa7:86c3:0:b0:6de:1d4a:c22c with SMTP id h3-20020aa786c3000000b006de1d4ac22cmr2773143pfo.0.1706891139038; Fri, 02 Feb 2024 08:25:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706891139; cv=pass; d=google.com; s=arc-20160816; b=NSzwe0vdQUoy7JfNRpbFUgaXx7MKEe7MZt57BkOOJRHVyRcCxrB+Q8LH0kcgdcZQ8X DvJWYjrmvPUF9WTnNPzg/pImIy7Y+343T0T4ujc13lB6WU68brJKMoOlJWtcTTDfwx8J u7oPWCCjKEgR/owjPrAU5/fwkhWu7nGeFC+q+Hal7Y5eWYNY+lrtZof/WNkkHuxYygPa EYGvNxEW4NoIEXoHCowXASEyHDpyv6WRNr/dsMyr/tOa/toZtwRSivReAc0Hv4A69gF0 HZXzLQqy4riwivBpIPdy/QROGtU6psQMIE5lijktAcOuePE4q7fAzP2h7DaqdlWF6Q+g kLQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wo/5+3KQxNpABeOm4NcuKYxrewGTOP6QGEug97RfVMY=; fh=/g3OZhXh7lRqkpIAAsiyDN5xsSc6hOv4dUe/fQ8mb3Y=; b=wipmscImotDkRtdpi6a1bvH9GBnSjPK4grXxws1MeX9wb2TPG7qURW3ea4k2aR6qgP 2FKsZpgMLdXfPl2cILeXaTDOP9UbtV8RLoF5+Rw2kWJHhpF9Bk8aCgjPAllQAZ1aN2Wd b2Mmz5ryPyROoKLGeWL8RZiicOoTla3umfHsBNA+g8rTL970kui9WIzQ20xLvtJo0Qgq fdhfmi4pWnjiOYTLjdaQdZxDTBT9YJVV1HJ/Uxkg8rFIy6xTsf3f80hCP2ZHDiEYZ9tO njZtMGoNjts1L1D/s7i7S+vT2ScnTPhwSXPo3nNcXYXocgO30xKuCEpSQhZSSs0vUEE4 hi0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=poIKS+Vs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50079-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUClZFeBMKSI1fEoXcR/RhzgyJziOQNYk5hyMQQMhDd9Y+LmPHfy9TBFMzaYNStjZTBgZj1tKRz/0Wh0YPqweNSp0wYbQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x15-20020aa79a4f000000b006de3bedded7si1726958pfj.3.2024.02.02.08.25.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50079-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=poIKS+Vs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50079-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BDD25B20B9E for ; Fri, 2 Feb 2024 16:04:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC01C15144B; Fri, 2 Feb 2024 15:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="poIKS+Vs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18D66150990; Fri, 2 Feb 2024 15:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889532; cv=none; b=pq/5SxPv+g6M8jDAhCcArW55f3akWTKaXdJJxMc2k/zb2WpFDtvsNdYA37fRZ7BABpnH7tEzrmZ8gUryBVwbPmccd/nqQ+DpbE4l+Jg0afwUkV0ng8ekbm5M6jrJU4YmxyAw6cSvqXgUwaAlQ+wn98K/RG4V9iKF566qIoMZunw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889532; c=relaxed/simple; bh=76DEmVP3xis53Bi0cuns0W32xsS7/RdTiZMSnNHJaCY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fB8YxU3rUNkbncfzCXGTQzCfYpY8Y1DbSf4F97qq5HyEO8AkrPiSF3E0z1J5jCFDruuUg3x11ElEXD2vBF82YID6N9VS3foF3iMwMbVGOkaImTuw6WVmAdcb6cL20mK6Vu+xnGCSbzWAExOnz7rEERUpLgFQR73Hr48mdNzeR8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=poIKS+Vs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5C4CC433F1; Fri, 2 Feb 2024 15:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889531; bh=76DEmVP3xis53Bi0cuns0W32xsS7/RdTiZMSnNHJaCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=poIKS+VsPlvvmjlBlcFPyftfEr6ROrXS/D7HBZpDXhc2SiwfqLnd8vhSq8OMXQBuD tEddaSQ4LJuXxSnHq07B2WVPqAstQPOuqcdvGQL8uYWAiBT9ifHZ2vFKCOVya+fZ4m BJfwGDFN+UcVh30jigSQ7DmJ2+pNZOV4MsSNXr2pZYyYAl4bq7URsKIIzwQHt3+gxh +wmXglxNZCyNJPhq0jZZ3xH4jsaEzkljvqH6ODzZW1R6D7v6oNClxUqE94o/ysDKvO 0TzLdQIHdOXdCcVNbLzgxtHxkWH8/ZbMEMtH7yhUZ/M0C/IhGwodLouk9576sDJoyZ zSHjrQAE5ow1w== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 19/27] kconfig: split list_head into a separate header Date: Sat, 3 Feb 2024 00:58:17 +0900 Message-Id: <20240202155825.314567-20-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789805082915418711 X-GMAIL-MSGID: 1789805082915418711 The struct list_head is often embedded in other structures, while other code is used in C functions. By separating struct list_head into its own header, other headers are no longer required to include the entire list.h. This is similar to the kernel space, where struct list_head is defined in instead of . Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 2 +- scripts/kconfig/list.h | 8 ++------ scripts/kconfig/list_types.h | 9 +++++++++ scripts/kconfig/mconf.c | 1 + scripts/kconfig/menu.c | 1 + scripts/kconfig/nconf.c | 1 + 6 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 scripts/kconfig/list_types.h diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index d667f9aa041e..dd3350aed302 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -12,7 +12,7 @@ extern "C" { #include #include -#include "list.h" +#include "list_types.h" #ifndef __cplusplus #include #endif diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h index 45cb237ab7ef..babed0baf4ae 100644 --- a/scripts/kconfig/list.h +++ b/scripts/kconfig/list.h @@ -2,6 +2,8 @@ #ifndef LIST_H #define LIST_H +#include "list_types.h" + /* * Copied from include/linux/... */ @@ -20,12 +22,6 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) - -struct list_head { - struct list_head *next, *prev; -}; - - #define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ diff --git a/scripts/kconfig/list_types.h b/scripts/kconfig/list_types.h new file mode 100644 index 000000000000..32899f424983 --- /dev/null +++ b/scripts/kconfig/list_types.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef LIST_TYPES_H +#define LIST_TYPES_H + +struct list_head { + struct list_head *next, *prev; +}; + +#endif /* LIST_TYPES_H */ diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 5df32148a869..f4bb391d50cf 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -19,6 +19,7 @@ #include #include +#include "list.h" #include "lkc.h" #include "lxdialog/dialog.h" #include "mnconf-common.h" diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index f701382f8a69..696803d944e0 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -10,6 +10,7 @@ #include "lkc.h" #include "internal.h" +#include "list.h" static const char nohelp_text[] = "There is no help available for this option."; diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 1148163cfa7e..9d22b0f3197b 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -11,6 +11,7 @@ #include #include +#include "list.h" #include "lkc.h" #include "mnconf-common.h" #include "nconf.h" From patchwork Fri Feb 2 15:58:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp527395dyc; Fri, 2 Feb 2024 08:05:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZAZQ9eu7aHjMgtHRNa+cGxYNZhkizUBaxpS7sOlfCA2s+6e9ZmdLw3HayeiAHKmE8RFnn X-Received: by 2002:a05:6a20:93a1:b0:19c:a1d5:ac66 with SMTP id x33-20020a056a2093a100b0019ca1d5ac66mr11547664pzh.4.1706889949071; Fri, 02 Feb 2024 08:05:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889949; cv=pass; d=google.com; s=arc-20160816; b=pj1LReZdm/LDstz0nMspyplmllQ4eLMyI/Vt1XQZv+dIoSCRz+M7R0Rc0Cm6NXDXBu XINS7NjNvjwX32G7oloGLw2w91ZJX5YEvPMuXDINe4tj4jsZEyNYz+UK17U5XnCFnpGg 7INR4r2wSi/H9fBLIXrJmYKn3PB/id3Jzm3j6ZdPPe06G3ypbvwUhpPfIEEIA4ZtuTgI SjStDEYpLbzRw+CrZQ/VQPen8JCqZ1aXG36fi8NJBgTL/75RAFGkAAbIzJnk7TsikM9V HYI6XYgkp+87xzLfO0issbSULfR1qm33w3ioVsu71HgFIfYrd3lR3tBVPF0osrlMzRHo LQiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FvWS8k0TnywP/ISWP+lwbCfLBicfe628UNfkCb70x4A=; fh=oXxmZ+L99xHtcvjF1Ho9VrHlVb3hZPDOogFBC/sOqCI=; b=tH5sTvwTRgBRuRpUvxUiK6tAwP0nl9Wh/AVD9sKaMpZiP/B57QT8zThnhU1MlVrjnS 3GHtFCZ5GvBNnsobktpiW60ayeQS4McWngbV93TCSXDEpKICIlcRBUGf7LiON6J58RTJ pBeMkVgRRJbBvrThddakAAN5LiqoHHjEvmasCaIlghsyKrWB2h9lV5+vQ/0CzkGW7nqD IgrpuBIO6tQ+3J+xkBEHL3RA34E14K+J5nLCNEyvHFhNFIKssdReUyYtWplcYplt4EH+ YTCCNofoeJFRbh5EjaE7uoUbP+bFHNoM7PPA2nX1vs9GQTHTKS5GWEFGbQ+UuBHtBiaZ V5Og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b48Qze55; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50080-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50080-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUJw/vi/WqPhCJLbF26+4drh650FqUEYG2KD0XfDIbIemAiJLz1ofWz+MYaZiVE2/nEj20IGX1NCUzMZu6OwrM4RtD1pw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y1-20020a056a001c8100b006d983f1fce5si1717366pfw.276.2024.02.02.08.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50080-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b48Qze55; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50080-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50080-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A489B2861C5 for ; Fri, 2 Feb 2024 16:04:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97FAE15147C; Fri, 2 Feb 2024 15:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b48Qze55" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFEB01509A2; Fri, 2 Feb 2024 15:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889532; cv=none; b=Zc29EWufiwbkQ4Tspsnty2XzouPgYO18e2CH1980Eq+yvwrqyPvEZaPLo1jAIk4v3UQezwY3pgyF+j48gQNSNs1aHck0a+FOKw9oWzEjo+9KoFVPUqAToP7nfgH6F1Zp4+WL11FNQDIdqcFBNVCcsW3NmNJSOYw5MHSAUcq8vtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889532; c=relaxed/simple; bh=3UkbuV1BdSBeEq4498jv1YQWyekAl1uueQ2UBHUrDPo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XkmkRz5tNLliQ1rOkwpHLQJHTv2hXG069cdaVfJsuCQU7ukhHOpj2pmhJ3Vks34FCGCPgYsEmgHkL1NWpPd8QwXkqVC7TCQADlbzwPgGMAzFl+L3kkQzjOqeIadFtTkruwJ8P7zLCo3ITMZRWJI/yRjfCiqq5N4xw6Uc7zvEQPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b48Qze55; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B1F4C43399; Fri, 2 Feb 2024 15:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889532; bh=3UkbuV1BdSBeEq4498jv1YQWyekAl1uueQ2UBHUrDPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b48Qze55ui0AZMZDN8tdq1p44477owiSB94LCs/NNUhjwkhvi2bS+otpr7oq8u4ij Lnzu5zW8M8V/JF7ilIatMHRzKbujx72Iszg8VmvFKQzgPnjAf/8LYSDBlYPCYXN6ZR xUy9Bz8V9vImondApHcZHomvaRc0WUzES8KrtIOg8idxUefSb0OkO17UWMRylooKrs MnbjBn0NmczTJYZATmCVhBelTf6OOEHP3auGicWFDPZ+Jkw+aWx9kjAQsX7qUg7/U4 Kc4GZn5Y80ej3cbbOLlqnwgRr8msbLfhOTBHcyETErPNJw1pUs/Lkvv/UDf7Ys78j3 60aAx0zEjkLtg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 20/27] kconfig: resync list.h Date: Sat, 3 Feb 2024 00:58:18 +0900 Message-Id: <20240202155825.314567-21-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803835262366513 X-GMAIL-MSGID: 1789803835262366513 Update the existing macros and inline functions based on include/linux/list.h. The variable name '_new' can be reverted to 'new' because this header is no longer included from the C++ file, scripts/kconfig/qconf.cc. Signed-off-by: Masahiro Yamada --- scripts/kconfig/list.h | 183 +++++++++++++++++++++++++++-------------- 1 file changed, 121 insertions(+), 62 deletions(-) diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h index babed0baf4ae..2bce2b8f21d1 100644 --- a/scripts/kconfig/list.h +++ b/scripts/kconfig/list.h @@ -2,25 +2,39 @@ #ifndef LIST_H #define LIST_H +#include + #include "list_types.h" -/* - * Copied from include/linux/... - */ - -#undef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +/* Are two types/vars the same type (ignoring qualifiers)? */ +#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) /** * container_of - cast a member of a structure out to the containing structure - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. * */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) ({ \ + void *__mptr = (void *)(ptr); \ + _Static_assert(__same_type(*(ptr), ((type *)0)->member) || \ + __same_type(*(ptr), void), \ + "pointer type mismatch in container_of()"); \ + ((type *)(__mptr - offsetof(type, member))); }) + +#define LIST_POISON1 ((void *) 0x100) +#define LIST_POISON2 ((void *) 0x122) + +/* + * Circular doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ #define LIST_HEAD_INIT(name) { &(name), &(name) } @@ -28,45 +42,16 @@ struct list_head name = LIST_HEAD_INIT(name) /** - * list_entry - get the struct for this entry - * @ptr: the &struct list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_head within the struct. + * INIT_LIST_HEAD - Initialize a list_head structure + * @list: list_head structure to be initialized. + * + * Initializes the list_head to point to itself. If it is a list header, + * the result is an empty list. */ -#define list_entry(ptr, type, member) \ - container_of(ptr, type, member) - -/** - * list_for_each_entry - iterate over list of given type - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_head within the struct. - */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) - -/** - * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_head within the struct. - */ -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int list_empty(const struct list_head *head) +static inline void INIT_LIST_HEAD(struct list_head *list) { - return head->next == head; + list->next = list; + list->prev = list; } /* @@ -75,14 +60,14 @@ static inline int list_empty(const struct list_head *head) * This is only for internal list manipulation where we know * the prev/next entries already! */ -static inline void __list_add(struct list_head *_new, +static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { - next->prev = _new; - _new->next = next; - _new->prev = prev; - prev->next = _new; + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; } /** @@ -93,9 +78,9 @@ static inline void __list_add(struct list_head *_new, * Insert a new entry before the specified head. * This is useful for implementing queues. */ -static inline void list_add_tail(struct list_head *_new, struct list_head *head) +static inline void list_add_tail(struct list_head *new, struct list_head *head) { - __list_add(_new, head->prev, head); + __list_add(new, head->prev, head); } /* @@ -111,8 +96,11 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) prev->next = next; } -#define LIST_POISON1 ((void *) 0x00100100) -#define LIST_POISON2 ((void *) 0x00200200) +static inline void __list_del_entry(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); +} + /** * list_del - deletes entry from list. * @entry: the element to delete from the list. @@ -121,8 +109,79 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) */ static inline void list_del(struct list_head *entry) { - __list_del(entry->prev, entry->next); - entry->next = (struct list_head*)LIST_POISON1; - entry->prev = (struct list_head*)LIST_POISON2; + __list_del_entry(entry); + entry->next = LIST_POISON1; + entry->prev = LIST_POISON2; } -#endif + +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_head within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + +/** + * list_first_entry - get the first element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_head within the struct. + * + * Note, that list is expected to be not empty. + */ +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) + +/** + * list_next_entry - get the next element in list + * @pos: the type * to cursor + * @member: the name of the list_head within the struct. + */ +#define list_next_entry(pos, member) \ + list_entry((pos)->member.next, typeof(*(pos)), member) + +/** + * list_entry_is_head - test if the entry points to the head of the list + * @pos: the type * to cursor + * @head: the head for your list. + * @member: the name of the list_head within the struct. + */ +#define list_entry_is_head(pos, head, member) \ + (&pos->member == (head)) + +/** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the list_head within the struct. + */ +#define list_for_each_entry(pos, head, member) \ + for (pos = list_first_entry(head, typeof(*pos), member); \ + !list_entry_is_head(pos, head, member); \ + pos = list_next_entry(pos, member)) + +/** + * list_for_each_entry_safe - iterate over list of given type. Safe against removal of list entry + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_head within the struct. + */ +#define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_first_entry(head, typeof(*pos), member), \ + n = list_next_entry(pos, member); \ + !list_entry_is_head(pos, head, member); \ + pos = n, n = list_next_entry(n, member)) + +#endif /* LIST_H */ From patchwork Fri Feb 2 15:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp527434dyc; Fri, 2 Feb 2024 08:05:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGFrVnGiwXSCA6bhLBxRWVfqHLdV38ID8wlGi2+04CpclHNvX1scy2kPECKZYdU8DVxTd5 X-Received: by 2002:a17:90b:2397:b0:296:5219:bbf7 with SMTP id mr23-20020a17090b239700b002965219bbf7mr883220pjb.7.1706889952721; Fri, 02 Feb 2024 08:05:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889952; cv=pass; d=google.com; s=arc-20160816; b=fBORsu0/1EypWN8xyKfrQMDrzfoWOQr2S50WkLSNOE+uZsXqqaiphs3XKF5DhY/b+5 9fFIGik0tnp6uSF6/THubHcqZyZUhzYrtN+lj730KRD9xPZW1X8gunHin8lpCSLX2Id8 txX+b/I5Yq+8lHOSnvf+uKbnQYQphDphZbVFu+wyxdTCY7dStC6seD1OLGTy2GrUAxGA WlcaUybBX+Wd/0E/BqMXmnBMKfCYGdOXL+ya61RGnSzyRpfGdKjVgyE7THaGUGHyrk4k BW3EsH6YH3cQ7wY31vE1RsUyVveKE/BW131e4s2GXq7ps2aoiPNpfH03ppqmaTVWU/KY El6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OJMTHrb6k7HiiJX5n4dSfDnrUVYspQvdZe4Nzjm+u/s=; fh=D8CZTk1hfZ4PNw+QOIYGBqkWFcFik46YlrPI6vkcx8A=; b=gJHIjpKL3WCtkRjWREP59Ycse5wblHw6y604lSbBmT/Mdfn48aqKW6UTw/UO96Z6ZK cgC0pPC6JtA1vvqFIA7Dr32ipTREeVJ5OxUnMU20/6L6XoR1WYzS07c8KC3Vmo/5aSX6 0d0EBkNqQwpVAJg/Nfxw0NSp+bu7eHk/fxAgUMq8sIBJdiVOZHwiQDpIfV8g9tt/Xh4A Y/bPVJtNMATa/aIU/79mSjP4yfo8i6EZppUhhkpDSDhgvtui2OQbBgC6Dr4vcGOMWXAm hHtwimE52tLgk6NYKjPPMpiZYT+MBsgs2AISIMeiy4y4I6R3+lOAxuaQ7o53Xa/zDcKE bW6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/EWCSl2"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50081-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50081-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUqxYwD//e/sEq5R8UwMZA+rLMpOQCXQk0DRanz4RoS+q1XOtPQSOwHx4sJTAFA1K356G9ZgOtsj3aBbGOVhMJDCDkRxg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id gb18-20020a17090b061200b00296451f8c25si129888pjb.159.2024.02.02.08.05.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:05:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50081-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/EWCSl2"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50081-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50081-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0C2DC283519 for ; Fri, 2 Feb 2024 16:04:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06C60151CCC; Fri, 2 Feb 2024 15:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z/EWCSl2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46ED01509B6; Fri, 2 Feb 2024 15:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889534; cv=none; b=WJjUxp7D6m73b3lTXrqQatYbT2IarpHN06FwMaTys1ZDRdjxBnP1g5efcN6Y4qJP0IF7ZGPWvHBzbNMMh4tbEVgBuEJ4eKTl0PIIe+yaS1NWrSOu3Yf6F1SbZ5VkYLMFLROKy0N7ZUUcbsUcb6BC+2rvSOm9EO6/NGKSxaPk1Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889534; c=relaxed/simple; bh=2A96WogbH0kuSA8JLvJzBsQjD8uKlSboQJQx9UBHSVM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dwLW0oOugQKEeqTizwTgdNEsganYYeljTxjHshNnxpJFebweGUEoGB6feo636GNczjbR/W49urSaOQwPk5F60N1tAR+15eUKNGOiWG/po8cRRptUs0MEb4mRbEQXNWKTkXO/N1zaf9Jg1WWyWyPv5gh37cZs0N0Qfu2tecofvVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z/EWCSl2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2571CC43394; Fri, 2 Feb 2024 15:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889533; bh=2A96WogbH0kuSA8JLvJzBsQjD8uKlSboQJQx9UBHSVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/EWCSl2wBAICpgIpF3Sra8aDM769fUjPgXy22zP6Hnk9+HH6P6Em6GY9UF0trg1q REgk3P9wJ50M51fGTYcDUurjxWqD1JSZNM/yvU816xfS5+hrdnE3mPWZlnGwa3AjUo Kg/nybbp39tKyCbUUUX+L+6G2nfFbpZ+wbtDiUzXRgRu7QsgInG/eqxulvFbgQlmuF lvFy6cITEHYpaI61fN5F7FY+KTbUDpEItD0mdzs9DX2nkSNOF44+AwMMuYunEYdP3l oStfxAitf73WOmLaV/tL+jlkDf0s4brhojGMpbAVtBh3vsAW6VlIq8QVGYqoTGl+MG IpO7Hui4vz1Xw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 21/27] kconfig: import more list macros and inline functions Date: Sat, 3 Feb 2024 00:58:19 +0900 Message-Id: <20240202155825.314567-22-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803838947216644 X-GMAIL-MSGID: 1789803838947216644 Import more macros and inline functions from include/linux/list.h and include/linux/types.h. Signed-off-by: Masahiro Yamada --- scripts/kconfig/list.h | 69 ++++++++++++++++++++++++++++++++++++ scripts/kconfig/list_types.h | 8 +++++ 2 files changed, 77 insertions(+) diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h index 2bce2b8f21d1..882859ddf9f4 100644 --- a/scripts/kconfig/list.h +++ b/scripts/kconfig/list.h @@ -70,6 +70,19 @@ static inline void __list_add(struct list_head *new, prev->next = new; } +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + /** * list_add_tail - add a new entry * @new: new entry to be added @@ -114,6 +127,16 @@ static inline void list_del(struct list_head *entry) entry->prev = LIST_POISON2; } +/** + * list_is_head - tests whether @list is the list @head + * @list: the entry to test + * @head: the head of the list + */ +static inline int list_is_head(const struct list_head *list, const struct list_head *head) +{ + return list == head; +} + /** * list_empty - tests whether a list is empty * @head: the list to test. @@ -184,4 +207,50 @@ static inline int list_empty(const struct list_head *head) !list_entry_is_head(pos, head, member); \ pos = n, n = list_next_entry(n, member)) +/* + * Double linked lists with a single pointer list head. + * Mostly useful for hash tables where the two pointer list head is + * too wasteful. + * You lose the ability to access the tail in O(1). + */ + +#define HLIST_HEAD_INIT { .first = NULL } + +/** + * hlist_add_head - add a new entry at the beginning of the hlist + * @n: new entry to be added + * @h: hlist head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) +{ + struct hlist_node *first = h->first; + + n->next = first; + if (first) + first->pprev = &n->next; + h->first = n; + n->pprev = &h->first; +} + +#define hlist_entry(ptr, type, member) container_of(ptr, type, member) + +#define hlist_entry_safe(ptr, type, member) \ + ({ typeof(ptr) ____ptr = (ptr); \ + ____ptr ? hlist_entry(____ptr, type, member) : NULL; \ + }) + +/** + * hlist_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the hlist_node within the struct. + */ +#define hlist_for_each_entry(pos, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ + pos; \ + pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) + #endif /* LIST_H */ diff --git a/scripts/kconfig/list_types.h b/scripts/kconfig/list_types.h index 32899f424983..d935b7c5aa81 100644 --- a/scripts/kconfig/list_types.h +++ b/scripts/kconfig/list_types.h @@ -6,4 +6,12 @@ struct list_head { struct list_head *next, *prev; }; +struct hlist_head { + struct hlist_node *first; +}; + +struct hlist_node { + struct hlist_node *next, **pprev; +}; + #endif /* LIST_TYPES_H */ From patchwork Fri Feb 2 15:58:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp526934dyc; Fri, 2 Feb 2024 08:05:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpVo74TMlVOljBWIv9O6rz2/hwXxfLDEq/6DxgxBjzVs4sFlUSAJQAJG+0ZFU1fYEq7Z1v X-Received: by 2002:a17:906:80cd:b0:a36:c327:e60d with SMTP id a13-20020a17090680cd00b00a36c327e60dmr1786255ejx.48.1706889920991; Fri, 02 Feb 2024 08:05:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889920; cv=pass; d=google.com; s=arc-20160816; b=lRyyw8boKwzsuZqRLbgNa3c1TleKyznWYETSiaw22Xbj+2Yl1LrqrNps2TUvKjmjhw W+UNe0EMrBAzvteHDRSnkQRpUAxxDq+brq/kFVcjP5cup/D3ec+U4dg2+KKiBak/2K+/ 80+6P+0PErR4a2N3kv9Ovd+uRhorx9ppCS7kmzLctH5DJfYGm3Tb59GwwLVptXcSJoM9 BRRBGx6W2F/4CzPpjc3j3PO3DJz19kYgij754O5ybBpZgrzAVBQdEuFAAwZIwamNYIcK Vz+WQOR3m1uwl4w9SWRoDxtrJzAD98IyjEJLUG1wvq0t80piIFmeqOMJYjKz0a8WjJcx ITNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zEpA+n7tBnfdGTW91LeK8gqMnIGkW7qPWmvAaghg1Vs=; fh=9KLThC6YtJFpDQkQ7Z4YZC4A/B3D4UwC7swEWmjlkrk=; b=DJUukAQIRb+mXfdluysSuPkvFWviP0tDbnTnYAy+T6uErQaH5X5ZMZ32sjocBdaqqj iTMH196dG92UV8xHlmHdgvXzsg1Fc5YdYHnsVdkFkjpJA2/dp/IEQil5aWahVpwjt4ma iwOXfIIjRjoDSNXd5WLQRZMpOXPxrsKgNaZCkrqqs8UxG6zGjqTs5tb7+uiz4ONgnGfw qwmox4S+VsydYpx1ZHUVSKmpOmBmA6uN7y3p8eosiTPC0iThuKC/2eb3+UVo0A8gJiMY AWOaz7cD5aMkbRKid304eFtZcs0TZB3pm7rHj3VaxDofFNKMI0WJDuCHXMIM2YuZSlVB i84Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EBF3HzlA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50082-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50082-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXqeqeHpMt7HoqjWFwG9bvqK3BGw04gkB8Gdrm5jnMH6XzxF44RNrM50ZG7Ps2FI5XMGCoaCcuGHPk1vzaDLc+9Uxq99A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kj19-20020a170907765300b00a35990c2b5csi890575ejc.407.2024.02.02.08.05.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:05:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50082-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EBF3HzlA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50082-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50082-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 986291F25C84 for ; Fri, 2 Feb 2024 16:05:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50F95151CF9; Fri, 2 Feb 2024 15:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EBF3HzlA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F57415145C; Fri, 2 Feb 2024 15:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889535; cv=none; b=SMDrsfJQnlR7I1E+QClkzpZGyN/ubYzKjosspx3jy8FuBS5jXaWy4nokCBwjnVe/bflcciiMw9NbYZ3aYb5Ywm9XvosvnFHpJkxJi+K2gNOPmZ/arlbvwALPb4qIeMagTy1HYjiTQVSieZznRrxBPYeWp1DabBuiwgjdIfq/fC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889535; c=relaxed/simple; bh=D8GL5EXe9NsGs57qE1qR40Cel+KA+fOzcvMaeqYSUEw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P0m0N8myx7OS7i9ICujsQ26zdhLHNmrS9MySJRHTZCVrg5s3pr/jiAwrgdHFKFxh2qSMZrpKYDygMqrXvA6u6/l8yYGBDJaplIZR0CFsJhVOl3eE06W0nmZ65lLi5MITKAMwR7lWHmgPRE0jxV+wS24I8cFlniv0lD/Ny+czE/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EBF3HzlA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42F38C43390; Fri, 2 Feb 2024 15:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889534; bh=D8GL5EXe9NsGs57qE1qR40Cel+KA+fOzcvMaeqYSUEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EBF3HzlAFciTdheF83e/1eXRxiduLLwv7xiG/VW0468UcO70fbmYmNr88vjefwNE/ SMaRjSDnRn/8dmgujdNwDVC87ZzyK0IgHEPPoOt9vl/zu/WKNWprM/nnTaqQ+DzQdC 6r4xE1FWm720uABImbWFlj94W0NKEPyvaCp9bhVEL2Fvz52Cuumv+7vq7+4wZo7mI3 Q4ltRD9xYxwqYw+ej/rSXoc9kfgTQE24MArka8C/bYrJvbNy0B41v0B/6V1WnSvrTb FTHSo268/7veL8X3gOHnCl7KOzJeEIzUmq9YkYSm5/mBmsIOczTbcgbV9/xUm8WIWM prX8q2XzQWUPw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 22/27] kconfig: add macros useful for hashtable Date: Sat, 3 Feb 2024 00:58:20 +0900 Message-Id: <20240202155825.314567-23-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803805337010726 X-GMAIL-MSGID: 1789803805337010726 This is similar to include/linux/hashtable.h, but the implementation has been simplified. Signed-off-by: Masahiro Yamada --- scripts/kconfig/hashtable.h | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/kconfig/hashtable.h diff --git a/scripts/kconfig/hashtable.h b/scripts/kconfig/hashtable.h new file mode 100644 index 000000000000..71724800d178 --- /dev/null +++ b/scripts/kconfig/hashtable.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef HASHTABLE_H +#define HASHTABLE_H + +#include "array_size.h" +#include "list.h" + +#define HASH_SIZE(name) (ARRAY_SIZE(name)) + +#define HASHTABLE_DECLARE(name, size) struct hlist_head name[size] + +#define HASHTABLE_DEFINE(name, size) \ + HASHTABLE_DECLARE(name, size) = \ + { [0 ... ((size) - 1)] = HLIST_HEAD_INIT } + +#define hash_head(table, key) (&(table)[(key) % HASH_SIZE(table)]) + +/** + * hash_add - add an object to a hashtable + * @table: hashtable to add to + * @node: the &struct hlist_node of the object to be added + * @key: the key of the object to be added + */ +#define hash_add(table, node, key) \ + hlist_add_head(node, hash_head(table, key)) + +/** + * hash_for_each - iterate over a hashtable + * @table: hashtable to iterate + * @obj: the type * to use as a loop cursor for each entry + * @member: the name of the hlist_node within the struct + */ +#define hash_for_each(table, obj, member) \ + for (int bkt = 0; bkt < HASH_SIZE(table); bkt++) \ + hlist_for_each_entry(obj, &table[bkt], member) + +/** + * hash_for_each_possible - iterate over all possible objects hashing to the + * same bucket + * @table: hashtable to iterate + * @obj: the type * to use as a loop cursor for each entry + * @member: the name of the hlist_node within the struct + * @key: the key of the objects to iterate over + */ +#define hash_for_each_possible(table, obj, member, key) \ + hlist_for_each_entry(obj, hash_head(table, key), member) + +#endif /* HASHTABLE_H */ From patchwork Fri Feb 2 15:58:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp527128dyc; Fri, 2 Feb 2024 08:05:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDECs0xYV6PZ3QbbdBoRqP9xM5SI/cNNJHFU5pcTMvpdzLtE6R4uHi3fnyTWpjBBRtzptl X-Received: by 2002:aa7:c30f:0:b0:55f:fdd3:ffe9 with SMTP id l15-20020aa7c30f000000b0055ffdd3ffe9mr68949edq.34.1706889932006; Fri, 02 Feb 2024 08:05:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889931; cv=pass; d=google.com; s=arc-20160816; b=SH4js8SgVS/lbP3CB8c1FXuquMB+l35CQRO2wq5J8Z6OGHPCnvVWcPhjlag+xiPZXZ AZJwnGWRh4CD4xAJEiTiuhTBysdMHCP8JpkBHrQBeIAPrRbFAocOsjuJ/P4ZczIJhQ/Q rygBwaYjPTKuAGdzCuS6U3ZO0g8bOeeqizctXIICJeKLGo1Y5Nh/wq+tHVkkXuFxpLoQ lTBh/BdUB977C6aH2vndxrJbBdX/OJi2sG+KEmP+qLFbfMwwEl6UXMVxaeRJTt6fdk9w 6J9Vrk8CY0jNLA1eQJcHk9Vktofsp0zY5vMtvxki3DuZsjojuwFRAtydY3WekyGM5oz2 DV8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JN5yS+cv7xBWiUFCFeGwyWAspmZKD60ePXz+NQ6GwZI=; fh=08zWp6a3Fj0opPwQzaD0pcIvcNRmow508FfZyardDU8=; b=BmJw5oLoqAtb6MnXmTWj7GL85RAIIHXwUZQCmimWVBzP8xa9TBxd/wt5inEz2UniIP ccXGgvBujQCJHMXpiIU0tEnz3XhfxYb+vt5tjIMZi11lGmqkptB8aP8i7iwrzhSmLeP+ BhHgqkM/CLcm5VrWGQwEYIfGyoajz6iGlHeLaOHOBpi1z3WMweNPvmWBXfVnhTtuhs4D dv1QO8v8gCugjtJ2Uo5a9MzRA3nqsIdh8YJGvZ7gk0LGtbJ5yrekDbOIHk6B3VoXIfRr BXTMjViWSM4rZ0i3m+ISKd5QldxpEUZbZn8HSWyjAfuumvdodJl1TwnTU40IFjcHNru0 zhjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kkc9Q6OS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50083-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50083-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXGwYfBFpBIXLvDRopYcyo5pRVbGfYnKbrYV861qW715YUZzgi+QYSrtf9pg4wqI0r/8X5SUdQdJksKSF91jSg0JA+s5w== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b5-20020a50ccc5000000b0055fa3cf748csi889826edj.175.2024.02.02.08.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:05:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50083-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kkc9Q6OS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50083-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50083-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9DC611F27101 for ; Fri, 2 Feb 2024 16:05:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A46D15145C; Fri, 2 Feb 2024 15:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kkc9Q6OS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F8BE15146A; Fri, 2 Feb 2024 15:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889536; cv=none; b=KHPs+jMNNYWh/ls5ITFYvKqyZh8oZjnW/Nenk6hVzBOcSoIx11bwX7xigyrm9TCaWKmOtuGAaS8UJBTSljhwmCrqPOB25wAHmRXDtIrRsoz7+9WdJqtEgx4iCigBXwJ2aGSC+g9O+KS8z4QRFzaJfetGbeRmmQNzBpI06xBRoPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889536; c=relaxed/simple; bh=LeeYFsCIF6jDZaXspMRRLlPcTtCrfxsxcxXxfVfjmc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HIw0vTeqA0D/XXCm+xaCB/sq8kZZj4xMz0RCd0D8akkbcKjHjREX4DbIdYWCgP2BBS0Y3YkRAZQeROVB5rVA2bFfrDok3xz52jRsAN8NAzlImJolXD5vZHrmXQ5E4g4RWBnjKFwbkCGcPxSOgxdqNauJEqnfCaz62vggGxpTeyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kkc9Q6OS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61B4DC433F1; Fri, 2 Feb 2024 15:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889536; bh=LeeYFsCIF6jDZaXspMRRLlPcTtCrfxsxcxXxfVfjmc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kkc9Q6OSx+NQaYN1sXTTciCIjpY02DiMrnw3OleDHjk5VD+kSkBImHGMcgWf/1iDh sMgA/LQnwK3mdSpWUsvTs5dmDQwX7R0MBhkIVfBqvnX9Qwl59R+jg4bXCKPvgeZVak /S1sGv4hGcko/u24kLpl2bCnT5FLovzT5GUL0PWgbNme/msrogeqVc2S/NMxbCrvfw 1dTeNrlvZohRQ2iXm1aMuecrCBYziAbXPHt7e3bq/bDPD/WqW3XTAVfzK56Jkh/LO4 nolyr+Zxu2erGeuKFNyWtmzsTxP1ipokaw1q11yag58BiT0FBo+lby705ywg/QqqS9 p+LB6iGLYFwew== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 23/27] kconfig: move ARRAY_SIZE to a header Date: Sat, 3 Feb 2024 00:58:21 +0900 Message-Id: <20240202155825.314567-24-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803817627291018 X-GMAIL-MSGID: 1789803817627291018 To use ARRAY_SIZE from other files, move it to its own header, just like include/linux/array_size.h. Signed-off-by: Masahiro Yamada --- scripts/kconfig/array_size.h | 11 +++++++++++ scripts/kconfig/preprocess.c | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 scripts/kconfig/array_size.h diff --git a/scripts/kconfig/array_size.h b/scripts/kconfig/array_size.h new file mode 100644 index 000000000000..26ba78d867d1 --- /dev/null +++ b/scripts/kconfig/array_size.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef ARRAY_SIZE_H +#define ARRAY_SIZE_H + +/** + * ARRAY_SIZE - get the number of elements in array @arr + * @arr: array to be sized + */ +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +#endif /* ARRAY_SIZE_H */ diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 69b806a6d8b7..f0a4a218c4a5 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -9,13 +9,12 @@ #include #include +#include "array_size.h" #include "internal.h" #include "list.h" #include "lkc.h" #include "preprocess.h" -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - static char *expand_string_with_args(const char *in, int argc, char *argv[]); static char *expand_string(const char *in); From patchwork Fri Feb 2 15:58:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp527672dyc; Fri, 2 Feb 2024 08:06:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGS5/H92fxb6f3/+WDtB+V9EtjhcKyBzHK6Xm9RBFocDtVrQQMTEqlqbXOzMvHUcv1OXMYe X-Received: by 2002:ac8:7dcb:0:b0:42b:f599:a97a with SMTP id c11-20020ac87dcb000000b0042bf599a97amr6489165qte.15.1706889971061; Fri, 02 Feb 2024 08:06:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889971; cv=pass; d=google.com; s=arc-20160816; b=NpzDK4SqIogpp2Pb+4s0CpNwTknUYS+/7aJp/l2ZlNlSoxFTV2TpSe0QDzQfSdEGuX 532ObfjwdDWDig1ARds/+6nJFbb4Aywm1ZzVYH+Yoitl7+lwOsixr+IWNQN9zoqr8qUh shYvXTDm7HjG1C+evcuNOLSKX/QL8HBQz7frLFhm8diNW1vEaH+l7/KFm4LqfvtIbezi nG4sjxxp1Y1aMqyzproLfZUIt04P+2MzPd+f8B30+KapZ2LeeJXi4Y3fE5X4e+2jPhF6 lq2vriNxtivwo4UV+qIKitcL/VjAhSywPWw2HbFAwtbpy30wLhfOvGhB3w3jJj2ATep9 rExg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/KzLhjJwnfwarHFc9lrsX+yOG2Hnfrm40otz7wHubz8=; fh=XqugY3HhXIq3NKjjOeX0pnItdhr3n2sNIZNE1Ffcb/Y=; b=u01dUXPcHduQ/OwWatr3Q2f+I7NONHWTEPUaNrISTccglCuuqo7AxSERiIMcG9HJJn 0mZsMgOi1kodXvrYZcKpqvHskF1egWwKneGtRFPxRmvxzziklR7KL16EWtPyb8h1VW+8 DpWA6shrxWpCygXOnhBd6hZimaZnPeKmAxsp1mN6BssxMmfXwTeBMcU4DNJxqvEZZxS8 yTaAl0vwOSiJrpMTcsLimsfHPWX39yEoMUuhgxs08+3JfgAkX0a/m3l3Wa5dhRXFK+Lk JXNkRsR+K3LwKrhce3Te48EAs4CmUilHmLCrY702BBVCc7KjSRQqzMyz0q+Eff5evrPj d/5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KHPlvMni; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50084-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50084-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVR9qrbrJLK/5aPlsBrfeS3/EW4NuVVMmi+e72XW/QQ2IL74kSj5RmxsmCk6hB7HlRVAomezBlBkZOokmC04NGMeGPuJg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h1-20020ac87d41000000b0042a87f5c338si2286706qtb.63.2024.02.02.08.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50084-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KHPlvMni; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50084-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50084-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 435971C26039 for ; Fri, 2 Feb 2024 16:05:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12704152E18; Fri, 2 Feb 2024 15:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KHPlvMni" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AD66151CD3; Fri, 2 Feb 2024 15:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889537; cv=none; b=B+yYk13ajj21Y8aSFnnVtPInpO5FzQngu0YE9xc66qT0cTSBJt+nUTWxGEd5WIm9xJdizrNUXj0trXc54LRFPcNFhVn5jGM8cOta3NkN5/D9vAo2Z9Lu9um7rfuHg782E8xMd8WrTJ02f+NtGbH+g2HuMRlU+n0VJrMHTLWP5Vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889537; c=relaxed/simple; bh=FTcLV2NufTBnpOgxgoEZStajI6PRmkWD1yAMbETfinQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O2PNPCsHo3IaeaBL9f60AlIDXc+o/0YtJFVGbiE3Lb+UcUYGgQCVX/mz10guUfzqE4XdneuDAUTZmghlRzTpnGEsTF4FPEStFLFaYgAn04CAXeoCwPGCC23F4NTFswN3XvgLl/SnuURzF9tEO0ZC8xVCxfDobBEys4UsFp8t760= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KHPlvMni; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B232C43390; Fri, 2 Feb 2024 15:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889537; bh=FTcLV2NufTBnpOgxgoEZStajI6PRmkWD1yAMbETfinQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KHPlvMni4MDvKigZg2a8wQU1pSZK2Voh6N8Em4TtlyRxmzpFMuU4EaO2CaSoODtsO IDOo9X/Sdp2qfdXjJkyBaD9o3E5AzRuFcjXmmPXwxzeTi3L7d5jZE/ermuVdypYdfb 3oABKE31z5LET4VBmmqS/AINEF29sKD45qg0jh1n6at/aqMeGmpKQL+nuDP0plZ8OO 0C3JhMx//nm9vqD9v/gd1tvkFaWtmhTiogp5vpfnqZhCBhtQ0c/QRZqevxCuGU9iH/ ROLHvzYGKjTvem876+4Ly6jEJqMQnoo7acgzjItSPSKifOAd0Zett2SzkQIITOzArH aTPo0cn6B2qfA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 24/27] kconfig: move strhash() to a header Date: Sat, 3 Feb 2024 00:58:22 +0900 Message-Id: <20240202155825.314567-25-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803858270200392 X-GMAIL-MSGID: 1789803858270200392 Move strhash() to a header, so it can be used from other files. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 10 +--------- scripts/kconfig/util.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 scripts/kconfig/util.h diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index dae630a74e50..518977c525de 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -10,6 +10,7 @@ #include #include "lkc.h" +#include "util.h" struct symbol symbol_yes = { .name = "y", @@ -803,15 +804,6 @@ bool sym_is_changeable(struct symbol *sym) return sym->visible > sym->rev_dep.tri; } -static unsigned strhash(const char *s) -{ - /* fnv32 hash */ - unsigned hash = 2166136261U; - for (; *s; s++) - hash = (hash ^ *s) * 0x01000193; - return hash; -} - struct symbol *sym_lookup(const char *name, int flags) { struct symbol *symbol; diff --git a/scripts/kconfig/util.h b/scripts/kconfig/util.h new file mode 100644 index 000000000000..d4e35bee6450 --- /dev/null +++ b/scripts/kconfig/util.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef UTIL_H +#define UTIL_H + +static unsigned int strhash(const char *s) +{ + /* fnv32 hash */ + unsigned int hash = 2166136261U; + + for (; *s; s++) + hash = (hash ^ *s) * 0x01000193; + return hash; +} + +#endif /* UTIL_H */ From patchwork Fri Feb 2 15:58:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp527769dyc; Fri, 2 Feb 2024 08:06:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPu8qG1MIV+3c0ZN8anTUn9t6d6NaLgwmHzURRr5s+MmdGvYU5ECT1fhrcRK5VvFnVAevE X-Received: by 2002:a05:622a:1a09:b0:42a:4350:64c7 with SMTP id f9-20020a05622a1a0900b0042a435064c7mr2703646qtb.68.1706889977142; Fri, 02 Feb 2024 08:06:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889977; cv=pass; d=google.com; s=arc-20160816; b=bkY9LXqguYz/UBQXW+1kq/Fshn2xg08aZGz5QGx505F1/5H60hKUKtkwDLQ3uv5U6V D22k5k1LTLd7jhxs4pu+j3zta2nF2FJQ4cJSRhV3ZEH7R9tnlFcw13Hc8JngsrpDmb4r R7BkyoPtwGNYe40lCqJVqLZHh+TtjwZY4T7M/y3LMdbPYEcZHJqyZca5fuPjLNPiNbMl TrZ8cBB2jUe8T+rDYwP9UyBO/abtEb97VmFEtJOd85lYUHn7PlpXOqeDEgDgRmJ6iBEH mYKzzJmtViVSoZLbw0VVcJK91fgQDdQQdcClYb0DG10ofXBwUbcCd2VefnnRr9HbfHR7 RSlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gMxmTmFFHZc9BjIVn1FY+o0s5+6GqOc2ntS4B8JVFgE=; fh=u8aShW3KCbxmw+VDFad5nvR1xg5gyc/+a7Sl0zNK3bA=; b=khYF3AyfC9wNL0jRCsLGltmtKloJL3UhOlTklByM6Zdz8/wTEYjnlwVpJ5LtWteVMf GKtPmy0deg9QYEAh/UcUA9NQ6RKTubn1dG+QAIseB8j4B/Jjnlk7z+BKU8M1Wwd1E+hh 8vIXHOLYaL+NqiXQyy/dbjOl5fZbDbcZ3V+l6rotPdwfKQEsZZlrk3HXVA8f8WqcrJ19 zTwZiNQK1i6H1k6+eKRTwD72OkAMD8HJ+G8GsaAtXJrz3xY3ucM93nBrvGd094ZmlpdV p6CbTQ1gkbZnax0RHtprnv1mi/+Vnlfak3reiecPL2S9jRnUop12+t8uLyNMeykbAooW p6TA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ruhFwbtw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50085-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50085-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCX3jGCtKHrkieA4KOkzHt6AAU2acMKagTh9JWnjb/VJYAuMudDKTH4CaNOXYDHrccYcgDUbAG1LQpQqRnDM6/W1Z1YbdQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f8-20020ac859c8000000b00429c6bc50a4si2202422qtf.528.2024.02.02.08.06.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:06:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50085-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ruhFwbtw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50085-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50085-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 78A651C252CC for ; Fri, 2 Feb 2024 16:05:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17755153BE0; Fri, 2 Feb 2024 15:59:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ruhFwbtw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 662B5151CF4; Fri, 2 Feb 2024 15:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889538; cv=none; b=ZwFKWZmXplKlHChirBOhDFliu1r94yjwY/jYY/3zSLFpAw2q4iYHhncbQvV8RKGaSN6fB2McH+m4QiLL891xHxysoxfP88TMwOEGbifnP8WyBubwYU5CQ6a4pmff86TKFEzk6ftGJTjeSb7gecqiUhDnUzAQBgHYiUTjhTKS6jM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889538; c=relaxed/simple; bh=X8I9rXVeGCoi7QcnwK71myLC6oWao8zTKDKpyMAWvVo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q02AA6ixz2XkoF09bp+idYDM3ey6oXXHaJCRKcg6zOk6Sa9IUfGcrLDJkakwWYxMIyCJOk5h6vMx4Ns1Gr0/TZdP90mMrniU8Ec1uYFsCU4x9w5zf35Yf9zMFJKNpFQlNp05YHeqROwa0ex+faZgpsN3eh6X8SoN25EYB52j7xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ruhFwbtw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95B95C433F1; Fri, 2 Feb 2024 15:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889538; bh=X8I9rXVeGCoi7QcnwK71myLC6oWao8zTKDKpyMAWvVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ruhFwbtwadYQ+aNHjKCd11eXVlQ7wLThqD6C1mWZNU+jhMKHpQ2auVnO/eSPsB6+u 37fcPp48rAWE7w8tmgQYNgB205Io0CJL1RzBt5MN6MVDulVdvkZNXNS8yyzBeOD6dq 0Nuy2uyWp560OU3J+py8kfOlcsRxjitACuxs778wcKnhtQP4/ufG5yFAdmDGuoBFUy ZxBG8KGyl8XEzY4hpEvAmUzyXcrdsHLpFF4Wzscwb/kSbDEO62qKYMtqehjee25PRx 6yij5ztam2Vo9vMKZwrkOgVwit0UIp5GpPcAB4KTMVDWxZZVr0SljfNwNju0I5yHT9 8LliXU3QuTMug== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 25/27] kconfig: convert linked list of files to hash table Date: Sat, 3 Feb 2024 00:58:23 +0900 Message-Id: <20240202155825.314567-26-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803864443922570 X-GMAIL-MSGID: 1789803864443922570 Currently, a linked list is used to keep track of all the Kconfig files that have ever been parsed. Every time the "source" statement is encountered, the linked list is traversed to check if the file has been opened before. This prevents the same file from being recorded in include/config/auto.conf.cmd again. Given 1500+ Kconfig files parsed, a hashtable is now a more optimal data structure. By the way, you may wonder why we check this in the first place. It matters only when the same file is included multiple times. In old days, such a use case was forbidden, but commit f094f8a1b273 ("kconfig: allow multiple inclusion of the same file") provided a bit more flexibility. Of course, it is almost hypothetical... Signed-off-by: Masahiro Yamada --- scripts/kconfig/util.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 610d64c01479..abd697ed8de7 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -7,34 +7,37 @@ #include #include #include + +#include "hashtable.h" #include "lkc.h" +#include "util.h" + +/* hash table of all parsed Kconfig files */ +static HASHTABLE_DEFINE(file_hashtable, 1U << 11); struct file { - struct file *next; + struct hlist_node node; char name[]; }; -static struct file *file_list; - /* file already present in list? If not add it */ const char *file_lookup(const char *name) { struct file *file; size_t len; + int hash = strhash(name); - for (file = file_list; file; file = file->next) { - if (!strcmp(name, file->name)) { + hash_for_each_possible(file_hashtable, file, node, hash) + if (!strcmp(name, file->name)) return file->name; - } - } len = strlen(name); file = xmalloc(sizeof(*file) + len + 1); memset(file, 0, sizeof(*file)); memcpy(file->name, name, len); file->name[len] = '\0'; - file->next = file_list; - file_list = file; + + hash_add(file_hashtable, &file->node, hash); str_printf(&autoconf_cmd, "\t%s \\\n", name); From patchwork Fri Feb 2 15:58:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp528450dyc; Fri, 2 Feb 2024 08:07:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk5p+snazdZtXHEHfXJQfgwJxZrcZrSL7yOEmiJkTbMeIa+h9cGN2fLtzEfdhSLKUshEfW X-Received: by 2002:a17:907:96a8:b0:a35:b73b:e5f8 with SMTP id hd40-20020a17090796a800b00a35b73be5f8mr2236393ejc.55.1706890027662; Fri, 02 Feb 2024 08:07:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706890027; cv=pass; d=google.com; s=arc-20160816; b=eYYqhemoYKED/NOSsWF85C1pUoWdHQJejXZokx0Ne3yU4XQ9jsnp2pWDkCv3btOHF1 Hv9rIxz5Zg+z+3P5+pNgfV9tyaTLIJdf883yzrjPk0D+JUBBF/XrcUBEHUyvSJG6wW/o yl/9foHWDpPjcTWcj71HSnEGwPqIrNobPOPksEOA87sBkNa6QpCZiCRYceKTtigqJz0W D5HZfwYxHN3DGUx63WcCrQWbXiEwKi0sngPyOuxYBSsc3NGYtedMsPt3g6SXM6E+UXF/ /qjyPinesSx1Qlb4vfvied7B5qKSBjjXL9qyUFZpT9cHbSpalx9ItnK/5rTzy+LhNz9V wmMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VPlOmktQ6CVB8w85/HjiVzmVxIkLbwJoHUgTUebmAtM=; fh=4pKz4KXHQeAmXGwqqgSMz/26lzZFZhDv2sPZC+sg23g=; b=QQee+heTtkOvbuc/ZAnsXHEl4q9ZgbZ2YVllinfcCx7nL3fn6uP8T9t7z0+w4GkHjb ozmKWTC8YWD399K3qux/CvKEG/bO9uaWE0PVdX1IWsVTC9/G+vSX1a5taij/0r6LatOT b9B0P/7rYziXLTUJSz0eHBITk7Pfmy+m16ihX9ZD8nMmPh6yhvUWpvWgDu6+f+Pxr7SU 2oO5KrPkFLqHE8n2+FQKxHy6uTCocRrM8YpmgfKkqeGv2R97MyzKtjpXNzBpKdro4Nb3 +oR/XWTxP1WOLZwnYXVPUzdAlD/nHOVinN2NM2TDNeysU0OpyC+xYM3VO5RG4Tmt7fUf s/Nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eYqeowhx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50086-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50086-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXR0t1i9TtsO5M0TPdPkyZ1sKZ48JGx8Cz1Meu1EM94Fl0KU6K51yAn7k1/MqKG2DpotunIIvFhSwjNfGZZGRiWLL2N1g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mf5-20020a170906cb8500b00a31831fb5afsi883290ejb.385.2024.02.02.08.07.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:07:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50086-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eYqeowhx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50086-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50086-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 033A81F265AE for ; Fri, 2 Feb 2024 16:06:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4532315350E; Fri, 2 Feb 2024 15:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eYqeowhx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2396151CD9; Fri, 2 Feb 2024 15:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889540; cv=none; b=XgQ4U62xvrd3wKecJZnrIuB7Wt9++dXe0hXEn4TGoOTCWW6mNr2HHgszQfL7eX7I7Q+fdZP1VznWJOpchIZo5K4HbG/85WoaQcMQXlm+XkJIgXFlVZYCiXRbtY2sg8bAkZiU/adbWMZzU2rk8MUAy3tTadwMLHc74dlPselRz/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889540; c=relaxed/simple; bh=k9Sfj6G74FhB17Co2/07H2mwmXKZRLmR93bIQOS6wrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CAQnELQbF86QnuQG0s9SyB2pWiTA2JlfWR9IrqHjc99+LSWTAxAHyPeEm7cNElFdrnf3hU24Kr2WBOydN3oTsF/NnmevwN1a4+lsREzl88bGqwK8Dd0GF97YFexzM7b1qXhqHDa2tW8KZlyo9lInahLMgSLLiqcWj3Hs6qcKeyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eYqeowhx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B327FC43394; Fri, 2 Feb 2024 15:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889539; bh=k9Sfj6G74FhB17Co2/07H2mwmXKZRLmR93bIQOS6wrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYqeowhxfk0mGaeCDX4LInidLVKrblDFemMbSzO9p90R8KzMZhtZ6rt+KbL88mLHM 3c+y/y18m5psSDUS14JLyVs9MThe5pmyuE9BceKtpThf/4tEb7YuFIk66EEbcBsDT/ o73nmSoQbPvZvNqTgOA0hz0Bmi9J6sI48BTq4FGGNbcmP6B98vH/eYVTvDhV5/pu1z uC81v28M8BEAOZmUxIDpFPFnEKhylLXapPijRiAdZOxswFZ3rtgpLo4xsZFYm8j/Zv S6SpAzWPWpfXGND3Ndp2kkKZOlcfmNDoyPpIITXUMTzD7sYniQSS6+tDa5ae+6BKPl jG+h2ti3vNWiA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 26/27] kconfig: use generic macros to implement symbol hashtable Date: Sat, 3 Feb 2024 00:58:24 +0900 Message-Id: <20240202155825.314567-27-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803917767465675 X-GMAIL-MSGID: 1789803917767465675 Use helper macros in hashtable.h for generic hashtable implementation. We can git rid of the hash head index of for_all_symbols(). Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 12 ++++++------ scripts/kconfig/confdata.c | 25 ++++++++++++------------- scripts/kconfig/expr.h | 9 ++++----- scripts/kconfig/internal.h | 9 +++++++++ scripts/kconfig/lkc_proto.h | 2 -- scripts/kconfig/parser.y | 5 +---- scripts/kconfig/symbol.c | 22 +++++++++++----------- 7 files changed, 43 insertions(+), 41 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 662a5e7c37c2..b5730061872b 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -14,6 +14,7 @@ #include #include +#include "internal.h" #include "lkc.h" static void conf(struct menu *menu); @@ -171,7 +172,7 @@ enum conf_def_mode { static bool conf_set_all_new_symbols(enum conf_def_mode mode) { struct symbol *sym, *csym; - int i, cnt; + int cnt; /* * can't go as the default in switch-case below, otherwise gcc whines * about -Wmaybe-uninitialized @@ -226,7 +227,7 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) } } - for_all_symbols(i, sym) { + for_all_symbols(sym) { if (sym_has_value(sym) || sym->flags & SYMBOL_VALID) continue; switch (sym_get_type(sym)) { @@ -278,14 +279,14 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) * and the rest to no. */ if (mode != def_random) { - for_all_symbols(i, csym) { + for_all_symbols(csym) { if ((sym_is_choice(csym) && !sym_has_value(csym)) || sym_is_choice_value(csym)) csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; } } - for_all_symbols(i, csym) { + for_all_symbols(csym) { if (sym_has_value(csym) || !sym_is_choice(csym)) continue; @@ -304,9 +305,8 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) static void conf_rewrite_tristates(tristate old_val, tristate new_val) { struct symbol *sym; - int i; - for_all_symbols(i, sym) { + for_all_symbols(sym) { if (sym_get_type(sym) == S_TRISTATE && sym->def[S_DEF_USER].tri == old_val) sym->def[S_DEF_USER].tri = new_val; diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index dafc572e7b7e..c5b6487d68ac 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -18,6 +18,7 @@ #include #include +#include "internal.h" #include "lkc.h" struct gstr autoconf_cmd; @@ -322,7 +323,7 @@ int conf_read_simple(const char *name, int def) size_t line_asize = 0; char *p, *val; struct symbol *sym; - int i, def_flags; + int def_flags; const char *warn_unknown, *sym_name; warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS"); @@ -380,7 +381,7 @@ int conf_read_simple(const char *name, int def) conf_warnings = 0; def_flags = SYMBOL_DEF << def; - for_all_symbols(i, sym) { + for_all_symbols(sym) { sym->flags |= SYMBOL_CHANGED; sym->flags &= ~(def_flags|SYMBOL_VALID); if (sym_is_choice(sym)) @@ -489,7 +490,6 @@ int conf_read(const char *name) { struct symbol *sym; int conf_unsaved = 0; - int i; conf_set_changed(false); @@ -500,7 +500,7 @@ int conf_read(const char *name) sym_calc_value(modules_sym); - for_all_symbols(i, sym) { + for_all_symbols(sym) { sym_calc_value(sym); if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE)) continue; @@ -524,7 +524,7 @@ int conf_read(const char *name) /* maybe print value in verbose mode... */ } - for_all_symbols(i, sym) { + for_all_symbols(sym) { if (sym_has_value(sym) && !sym_is_choice_value(sym)) { /* Reset values of generates values, so they'll appear * as new, if they should become visible, but that @@ -862,7 +862,6 @@ int conf_write(const char *name) const char *str; char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; char *env; - int i; bool need_newline = false; if (!name) @@ -946,7 +945,7 @@ int conf_write(const char *name) } fclose(out); - for_all_symbols(i, sym) + for_all_symbols(sym) sym->flags &= ~SYMBOL_WRITTEN; if (*tmpname) { @@ -1016,7 +1015,7 @@ static int conf_touch_deps(void) { const char *name, *tmp; struct symbol *sym; - int res, i; + int res; name = conf_get_autoconfig_name(); tmp = strrchr(name, '/'); @@ -1030,7 +1029,7 @@ static int conf_touch_deps(void) conf_read_simple(name, S_DEF_AUTO); sym_calc_value(modules_sym); - for_all_symbols(i, sym) { + for_all_symbols(sym) { sym_calc_value(sym); if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name) continue; @@ -1096,7 +1095,7 @@ static int __conf_write_autoconf(const char *filename, char tmp[PATH_MAX]; FILE *file; struct symbol *sym; - int ret, i; + int ret; if (make_parent_dir(filename)) return -1; @@ -1113,7 +1112,7 @@ static int __conf_write_autoconf(const char *filename, conf_write_heading(file, comment_style); - for_all_symbols(i, sym) + for_all_symbols(sym) if ((sym->flags & SYMBOL_WRITE) && sym->name) print_symbol(file, sym); @@ -1136,7 +1135,7 @@ int conf_write_autoconf(int overwrite) { struct symbol *sym; const char *autoconf_name = conf_get_autoconfig_name(); - int ret, i; + int ret; if (!overwrite && is_present(autoconf_name)) return 0; @@ -1148,7 +1147,7 @@ int conf_write_autoconf(int overwrite) if (conf_touch_deps()) return 1; - for_all_symbols(i, sym) + for_all_symbols(sym) sym_calc_value(sym); ret = __conf_write_autoconf(conf_get_autoheader_name(), diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index dd3350aed302..3bc375f1a1cd 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -17,6 +17,8 @@ extern "C" { #include #endif +#include "list_types.h" + typedef enum tristate { no, mod, yes } tristate; @@ -74,8 +76,8 @@ enum { * SYMBOL_CHOICE bit set in 'flags'. */ struct symbol { - /* The next symbol in the same bucket in the symbol hash table */ - struct symbol *next; + /* link node for the hash table */ + struct hlist_node node; /* The name of the symbol, e.g. "FOO" for 'config FOO' */ char *name; @@ -124,8 +126,6 @@ struct symbol { struct expr_value implied; }; -#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) - #define SYMBOL_CONST 0x0001 /* symbol is const */ #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ @@ -150,7 +150,6 @@ struct symbol { #define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 #define SYMBOL_MAXLENGTH 256 -#define SYMBOL_HASHSIZE 9973 /* A property represent the config options that can be associated * with a config "symbol". diff --git a/scripts/kconfig/internal.h b/scripts/kconfig/internal.h index 788401cd5d6f..6c721c4cfd72 100644 --- a/scripts/kconfig/internal.h +++ b/scripts/kconfig/internal.h @@ -2,6 +2,15 @@ #ifndef INTERNAL_H #define INTERNAL_H +#include "hashtable.h" + +#define SYMBOL_HASHSIZE (1U << 14) + +extern HASHTABLE_DECLARE(sym_hashtable, SYMBOL_HASHSIZE); + +#define for_all_symbols(sym) \ + hash_for_each(sym_hashtable, sym, node) + struct menu; extern struct menu *current_menu, *current_entry; diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 94299e42402f..2807fa584c2b 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -18,8 +18,6 @@ void conf_set_message_callback(void (*fn)(const char *s)); bool conf_errors(void); /* symbol.c */ -extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; - struct symbol * sym_lookup(const char *name, int flags); struct symbol * sym_find(const char *name); void print_symbol_for_listconfig(struct symbol *sym); diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index e58c24d2e5ab..112831da4f44 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -28,8 +28,6 @@ static void zconf_error(const char *err, ...); static bool zconf_endtoken(const char *tokenname, const char *expected_tokenname); -struct symbol *symbol_hash[SYMBOL_HASHSIZE]; - struct menu *current_menu, *current_entry; %} @@ -474,7 +472,6 @@ assign_val: void conf_parse(const char *name) { struct symbol *sym; - int i; autoconf_cmd = str_new(); @@ -517,7 +514,7 @@ void conf_parse(const char *name) } menu_finalize(&rootmenu); - for_all_symbols(i, sym) { + for_all_symbols(sym) { if (sym_check_deps(sym)) yynerrs++; } diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 518977c525de..1290c6d2f8c2 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -9,6 +9,7 @@ #include #include +#include "internal.h" #include "lkc.h" #include "util.h" @@ -161,9 +162,8 @@ static void sym_set_changed(struct symbol *sym) static void sym_set_all_changed(void) { struct symbol *sym; - int i; - for_all_symbols(i, sym) + for_all_symbols(sym) sym_set_changed(sym); } @@ -476,9 +476,8 @@ void sym_calc_value(struct symbol *sym) void sym_clear_all_valid(void) { struct symbol *sym; - int i; - for_all_symbols(i, sym) + for_all_symbols(sym) sym->flags &= ~SYMBOL_VALID; conf_set_changed(true); sym_calc_value(modules_sym); @@ -804,6 +803,8 @@ bool sym_is_changeable(struct symbol *sym) return sym->visible > sym->rev_dep.tri; } +HASHTABLE_DEFINE(sym_hashtable, SYMBOL_HASHSIZE); + struct symbol *sym_lookup(const char *name, int flags) { struct symbol *symbol; @@ -818,9 +819,9 @@ struct symbol *sym_lookup(const char *name, int flags) case 'n': return &symbol_no; } } - hash = strhash(name) % SYMBOL_HASHSIZE; + hash = strhash(name); - for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + hash_for_each_possible(sym_hashtable, symbol, node, hash) { if (symbol->name && !strcmp(symbol->name, name) && (flags ? symbol->flags & flags @@ -839,8 +840,7 @@ struct symbol *sym_lookup(const char *name, int flags) symbol->type = S_UNKNOWN; symbol->flags = flags; - symbol->next = symbol_hash[hash]; - symbol_hash[hash] = symbol; + hash_add(sym_hashtable, &symbol->node, hash); return symbol; } @@ -860,9 +860,9 @@ struct symbol *sym_find(const char *name) case 'n': return &symbol_no; } } - hash = strhash(name) % SYMBOL_HASHSIZE; + hash = strhash(name); - for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + hash_for_each_possible(sym_hashtable, symbol, node, hash) { if (symbol->name && !strcmp(symbol->name, name) && !(symbol->flags & SYMBOL_CONST)) @@ -922,7 +922,7 @@ struct symbol **sym_re_search(const char *pattern) if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE)) return NULL; - for_all_symbols(i, sym) { + for_all_symbols(sym) { if (sym->flags & SYMBOL_CONST || !sym->name) continue; if (regexec(&re, sym->name, 1, match, 0)) From patchwork Fri Feb 2 15:58:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 195933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp527954dyc; Fri, 2 Feb 2024 08:06:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRCdzL+yUD/m+GDM5e+2RnXOC49LiEBGHu4n3MI64lcD0oZtt3ItQMuKvCTEHJEi9bvn43 X-Received: by 2002:ac8:7c44:0:b0:42a:8b20:bb2d with SMTP id o4-20020ac87c44000000b0042a8b20bb2dmr9284688qtv.22.1706889990960; Fri, 02 Feb 2024 08:06:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706889990; cv=pass; d=google.com; s=arc-20160816; b=09hSFMIEfm4NfI3VEatreyFXPn2mr2KyXUHiM0q0K4KVBzQKogHhGj7VsqFk8sk2ZY c1Vc+MVB5X2321mptX9tmyYfMlod4+ow2mE3YD+wHWIvalEbWLMQmjaWs+0GbWr0Xyof WP19+pq0jfIkFY16fVxI86NMdYttkD9jdA739c3Kmwvjg48ZIpRgxZAWqMV2Hq/UCAbz E+Fx/UMBCm224WlS6ro2CHAIqrvWh0/YKVMpg5A3F0d8USRtsIGmQRW2nPCiEmAhbj8O ZYvHAX/PWC+lYZRgSOLUWlGddk6v5GX1sc5r16gvPolcL6mmxSpbiMW/C7WWHjTRrlGY 20qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2Cbn1Gtq1JIdG5vP5amVc2bF2OzgkURvrvVUZykHRTQ=; fh=iGphcgvNlx6JFWU96V5D54LVyMLfRuHML6ErqNdAGPo=; b=EbgrRpBce8PXu2JWSmYh6K1KXGu6EWsYOmrpivsO/sp70+fx6JOzmiAAyNydImLZWu rgELBmebJb025UoKYZWdnzYBbqFs6hhRoyH1iLD9yM1efRLOG3LhUEqbiz8YVR5fC2lW JBkTUAVslcq4a8NX9bDUs5eYQStJnifG50qMH2nnhPz+iGEvP2tyABEH7W9LXcRNx40i FuA+F/V+hAG7V9wDwgb+g7BZ6tXgs+TqUTpaqWg9MEYlEReQuCaM36/g7jUh+BIdTc+C mSIPDQpt9RgGCpzMwZkwnErmLFVBh3pQsNZRme6qnIqfSXT16LTFgtSA5nKsc8oXHwR9 FG/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nn3YZR80; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50087-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50087-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXSLZjbCFy5Or/fHUj5msVzyo671uXTRsBTaeDb7dAhlpCLNCMk18PWW1nt4eMty6CHKiAj2W4JiJbx+svT/7jbwQAOUQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n16-20020a05622a11d000b0042bf0e27004si2227514qtk.558.2024.02.02.08.06.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:06:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50087-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nn3YZR80; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50087-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50087-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 495F21C24E76 for ; Fri, 2 Feb 2024 16:06:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 988DF153BED; Fri, 2 Feb 2024 15:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nn3YZR80" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E73D915350E; Fri, 2 Feb 2024 15:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889541; cv=none; b=VsuSThnnYomgWjk6JFcsg7/9mga9UFVFcAPqe4BagROxq+VptKycGF93SAN0C6PeDfOvmEGsIevuyE5uG04dRRb4B0Oj7AYPfz7owQwuxYTQr0gW5PxwBlh5BsuwgvGM2oitRCXWf4lnUaY7WSbnLdA1N9CFhWVByW/maD/G09I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706889541; c=relaxed/simple; bh=z4Cms56kmTfXRHkY+P++VOmPThXzhuLEMnCh+5t5LTk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XpBfO3kKOzjLLhS0sOJaEb1M3U4UQafTpl/PxSdxhs7Q+GBZ9hV95VtwRwXlXq5KPg4S+ACEw9TX5DO9tKQcPfrSF7VDR3RnW3ZPYG7woFyGzGNCKEayiG8tllvGvxSsMhENVpjhlHhOcWTyObbOkSeWwscp0JfCuo0Zi2y4SPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nn3YZR80; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBF86C43390; Fri, 2 Feb 2024 15:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706889540; bh=z4Cms56kmTfXRHkY+P++VOmPThXzhuLEMnCh+5t5LTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nn3YZR80OfoXt/sLgprXuYM20Lq3vti3Bsrk0CaUs8c7oU5QF7MwxAzEWpoAp9dGH 7rM06W06R0+Uc+bAhvFj+HuwDNJUXxXM12eCARlJH9by5rQqTStGZPzBilgeI/p5MJ zUr2e3hI5gBKtgGLvo9zFFSWMuLsr7zqWMjsTaS9/tncjCAYGRzRoJIwbQZVWRpYF2 lXgiuhMH+k5Kq7rgx3lRGc4eBztnQjo6zIwlPiwFSdQNnJ1XEPeLr792PFoXTrmEo2 ZOAn5mBQ+DSbMPqRfKYqqNjxjzNKH8fE+0IEAhaVFyPXRnJOxdwu19DP2OUWxbVUNg MmBYRI1Hd6Afg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 27/27] kconfig: do not imply the type of choice value Date: Sat, 3 Feb 2024 00:58:25 +0900 Message-Id: <20240202155825.314567-28-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240202155825.314567-1-masahiroy@kernel.org> References: <20240202155825.314567-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789803879356605316 X-GMAIL-MSGID: 1789803879356605316 Do not feed back the choice type to choice values. Each choice value should explicitly specify 'bool' or 'tristate', as all the Kconfig files already do. If the type were missing, "config symbol defined without type" would be shown. Signed-off-by: Masahiro Yamada --- scripts/kconfig/menu.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 696803d944e0..44465945d6b1 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -305,12 +305,6 @@ void menu_finalize(struct menu *parent) } } } - /* set the type of the remaining choice values */ - for (menu = parent->list; menu; menu = menu->next) { - current_entry = menu; - if (menu->sym && menu->sym->type == S_UNKNOWN) - menu_set_type(sym->type); - } /* * Use the choice itself as the parent dependency of