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; }