From patchwork Sun Aug 22 19:22:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ariel Marcovitch X-Patchwork-Id: 12451649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33664C4338F for ; Sun, 22 Aug 2021 19:22:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15ADA61262 for ; Sun, 22 Aug 2021 19:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232616AbhHVTXd (ORCPT ); Sun, 22 Aug 2021 15:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbhHVTXc (ORCPT ); Sun, 22 Aug 2021 15:23:32 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F69C061575; Sun, 22 Aug 2021 12:22:51 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id w5so32222912ejq.2; Sun, 22 Aug 2021 12:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0RIFHfz5yhdqSHvpEZZkV8wPjACBT6ytbsVRZozzO6g=; b=Xi+W25VC68NtwatKdL6p2mcQz6rCUo7v9s/e0itKwPk49/Br2yQig2YdSE6a//yHVA wwrzpAyfvxf7cRfbWIEXxvCqLngLW8sixQk4Fe4D2vZlhhHnFtRQJOQ5ax41bNMRQnYy wZSVFjl3+FYBLZtCK6TjPCVgm5czrpBE7C4dNo6E8RVNqcYu1jJ9XBlehv+gB982F9I3 00OqFZFudQOuWmjJWzgkP6yeU806Se+AFcrZy13uDNSHS0gfk/cetCHao7EwEMJOtuHx 7Kn5+BrSbl192TjfirYFTJBWEHJSHmEer9fZo0Y4WBBPLjkhteXyt7rspy4tBmJLSNcE OH6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0RIFHfz5yhdqSHvpEZZkV8wPjACBT6ytbsVRZozzO6g=; b=egHtL1QBexINA1igjJwnXQes3dmbGAzJs640OpnLNC7z5uUEbL8E04lI89YmRFJ2hl C/l40u/13uaDeG+Qr7As76WlHJYMdf6U0Gy7NP0a2Mq4Ne5AqpLxiTcs5wfk4N+dMR2V 0KpOcr4CV8Fw9R3p/ENbECAHnxLs/RTkAF+kEyfbzmy41Wujj8fPLw4BZl+shZYzB2U1 zWoEwYeDt7Jk7UNennIXvXHZFGr8GhZjGzeepfJ/QvpvuRgH4Tbxm23/oElXSApnrjnP jjVqfqfysOrC/p70R+z+ZOFBEZBnq+h3rcejdln1FJ6c9pI8OgPLSg39k6q6L4wsyNzA KIFw== X-Gm-Message-State: AOAM5300bSuRaXoxsw6PMx84noL1rpkbyg6tdQNJsi24joVfT+IYL6N8 HYoXNbCAYypuskKA93c3/R0= X-Google-Smtp-Source: ABdhPJz+8N+XqLOwFfb/ZJA5Kh7jD7negJZgs0PzpRuXzwKCYyCooWjoW0fX13kdaV8brr9ZD1xsBw== X-Received: by 2002:a17:906:3054:: with SMTP id d20mr19273410ejd.294.1629660169664; Sun, 22 Aug 2021 12:22:49 -0700 (PDT) Received: from localhost.localdomain ([147.235.73.50]) by smtp.googlemail.com with ESMTPSA id o6sm1577950eje.6.2021.08.22.12.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Aug 2021 12:22:49 -0700 (PDT) From: Ariel Marcovitch Cc: Ariel Marcovitch , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] checkkconfigsymbols.py: Fix the '--ignore' option Date: Sun, 22 Aug 2021 22:22:01 +0300 Message-Id: <20210822192205.43210-2-arielmarcovitch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210822192205.43210-1-arielmarcovitch@gmail.com> References: <20210822192205.43210-1-arielmarcovitch@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org It seems like the implementation of the --ignore option is broken. In check_symbols_helper, when going through the list of files, a file is added to the list of source files to check if it matches the ignore pattern. Instead, as stated in the comment below this condition, the file should be added if it doesn't match the pattern. This means that when providing an ignore pattern, the only files that will be checked will be the ones we want the ignore, in addition to the Kconfig files that don't match the pattern (the check in parse_kconfig_files is done right) Signed-off-by: Ariel Marcovitch --- scripts/checkkconfigsymbols.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index 1548f9ce4682..b9b0f15e5880 100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py @@ -329,7 +329,7 @@ def check_symbols_helper(pool, ignore): if REGEX_FILE_KCONFIG.match(gitfile): kconfig_files.append(gitfile) else: - if ignore and not re.match(ignore, gitfile): + if ignore and re.match(ignore, gitfile): continue # add source files that do not match the ignore pattern source_files.append(gitfile) From patchwork Sun Aug 22 19:22:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ariel Marcovitch X-Patchwork-Id: 12451651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05DFCC432BE for ; Sun, 22 Aug 2021 19:22:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6B9461284 for ; Sun, 22 Aug 2021 19:22:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232731AbhHVTXh (ORCPT ); Sun, 22 Aug 2021 15:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbhHVTXg (ORCPT ); Sun, 22 Aug 2021 15:23:36 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98B4BC061575; Sun, 22 Aug 2021 12:22:54 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id d11so32125427eja.8; Sun, 22 Aug 2021 12:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k+ZHwWAAohsZAJsgkPVSkbIuUTEMZCWegHO2zbiIHh4=; b=LRL20NM9k2d4LbTROqQT+Dm3dKt0LVfwE8O96A2DHPbkJim5z9SsFiVjDNZEy802VY YX8tlk99XMTfAyAvUP2fzVSc7ZjG/8ZsNFiz44hZauErVx7BxjklcVuYobmdIz4btTsJ bzS7Qv4yCb5ecsbzrFyYtDTaY77uX7FzRLNjODT3FxUAf/W5xVA9SKgOEK3TNfbVmXiP cr4bc6d5J+4YInMpa4/3gOBfSmmeS7/cKS0Zx+WSi1DjtGrmGIExO73gR0nNSFCJoVQc AkSR2KluoqpNtchwqMr3704CvgxwV4/ugTqwvVRKoE0iWq1QAjNULzn1FvfcV8cIRlEl 6Vzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k+ZHwWAAohsZAJsgkPVSkbIuUTEMZCWegHO2zbiIHh4=; b=Psy5LKqJ0BFx1O3jpMJd8Y9NrxIVQG4iYiLnvgTEdU42b231Fk2bIkIchbACaIZjmF gB8MS3ypi9REca5CgCWYFcMqpGSsgxRW+TB8fXrp3EtslV70LAGU5xGiwJ9Jya5M31SK cNhb698jcchLYxvFUh44LIq0G/0Vb3C290ef2QGEhoPeGYdVj+Axb5w7krj1RRNwBr9C zBbihjtwb1/GRQYlJLOQ6NcripPregmcE2AHfdVZ/XM/DgVWKFO2uv4TGakOoPLjTpIJ CYGkq2is7qLiyAePRK36n1pP+aPE3bmsC/5gp4NssLalE2ZepKBnpZamOJYH1FG63glG Jyjg== X-Gm-Message-State: AOAM533Qedsf5PzzWTg8EZJQc+wIodH5ckea/krasu86Jf/BN9bfNNgr n8pK1NrxV0uTVqIvaWTT1Q4= X-Google-Smtp-Source: ABdhPJwOdr6xdUEPYHUpb/+ujmfH1eFDwNAmicufdw2gj5qdu7kDZx+ZXmAa/xyrcD/BLzkfjtHSvw== X-Received: by 2002:a17:906:a382:: with SMTP id k2mr31814962ejz.454.1629660173239; Sun, 22 Aug 2021 12:22:53 -0700 (PDT) Received: from localhost.localdomain ([147.235.73.50]) by smtp.googlemail.com with ESMTPSA id o6sm1577950eje.6.2021.08.22.12.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Aug 2021 12:22:52 -0700 (PDT) From: Ariel Marcovitch Cc: Ariel Marcovitch , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] checkkconfigsymbols.py: Fix Kconfig parsing to find 'if' lines Date: Sun, 22 Aug 2021 22:22:02 +0300 Message-Id: <20210822192205.43210-3-arielmarcovitch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210822192205.43210-1-arielmarcovitch@gmail.com> References: <20210822192205.43210-1-arielmarcovitch@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When parsing Kconfig files to find symbol definitions and references, lines after a 'help' line are skipped until a new config definition starts. However, it is quite common to define a config and then make some other configs depend on it by adding an 'if' line. This kind of kconfig statement usually appears after a config definition which might contain a 'help' section. The 'if' line is skipped in parse_kconfig_file() because it is not a config definition. This means that symbols referenced in this kind of statements are ignored by this function and thus are not considered undefined references in case the symbol is not defined. The REGEX_KCONFIG_STMT regex can't be used because the other types of statements can't break help lines. Define a new regex for matching 'if' statements and stop the 'help' skipping in case it is encountered. Signed-off-by: Ariel Marcovitch --- scripts/checkkconfigsymbols.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index b9b0f15e5880..875e9a2c14b2 100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py @@ -26,6 +26,7 @@ EXPR = r"(?:" + OPERATORS + r"|\s|" + SYMBOL + r")+" DEFAULT = r"default\s+.*?(?:if\s.+){,1}" STMT = r"^\s*(?:if|select|imply|depends\s+on|(?:" + DEFAULT + r"))\s+" + EXPR SOURCE_SYMBOL = r"(?:\W|\b)+[D]{,1}CONFIG_(" + SYMBOL + r")" +IF_LINE = r"^\s*(?:if)\s+" + EXPR # regex objects REGEX_FILE_KCONFIG = re.compile(r".*Kconfig[\.\w+\-]*$") @@ -35,11 +36,11 @@ REGEX_KCONFIG_DEF = re.compile(DEF) REGEX_KCONFIG_EXPR = re.compile(EXPR) REGEX_KCONFIG_STMT = re.compile(STMT) REGEX_KCONFIG_HELP = re.compile(r"^\s+help\s*$") +REGEX_KCONFIG_IF_LINE = re.compile(IF_LINE) REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$") REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+") REGEX_QUOTES = re.compile("(\"(.*?)\")") - def parse_options(): """The user interface of this module.""" usage = "Run this tool to detect Kconfig symbols that are referenced but " \ @@ -445,6 +446,11 @@ def parse_kconfig_file(kfile): line = line.strip('\n') line = line.split("#")[0] # ignore comments + # 'if EXPR' lines can be after help lines + # The if line itself is handled later + if REGEX_KCONFIG_IF_LINE.match(line): + skip = False + if REGEX_KCONFIG_DEF.match(line): symbol_def = REGEX_KCONFIG_DEF.findall(line) defined.append(symbol_def[0]) From patchwork Sun Aug 22 19:22:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ariel Marcovitch X-Patchwork-Id: 12451653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEB39C4320A for ; Sun, 22 Aug 2021 19:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B30D361262 for ; Sun, 22 Aug 2021 19:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232882AbhHVTXo (ORCPT ); Sun, 22 Aug 2021 15:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232845AbhHVTXn (ORCPT ); Sun, 22 Aug 2021 15:23:43 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7ADC06175F; Sun, 22 Aug 2021 12:23:01 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id q3so22757822edt.5; Sun, 22 Aug 2021 12:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jdnBbcis2LRjQudu7rmiYqSfk0ZwyRk00EIcmbT2dtw=; b=LvvZ9fplj5UTmUNevRsgsFYSQfT5JNWjExroXKrez2z3oolTtazTk8vXwzWzn2CGAg hzO02jn0PQePSvej1UvWpItrJgNDulApXtGRL90xbGqVZb5aw2HstzxlHCDeS/wDTaxg 6ZAsN2+isQ9K56gtD8u8ZidJ5DsjyTts15b0vb6BMX09TBvbG6k1SJgsbofD7A0LgLXr 5qrBDBb566gYjoFJYmGI2ADEWclmH5aaJUXCwX0Y5+BBT5d12rTzSe3OVNEhOUwrs2cO +dQuhOl594T2ssWJuNaMT2gZ7cjtl1W8OBmbe1N8jdjS4b9+WSgMSdzQPVH12JV9OV9m f0+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jdnBbcis2LRjQudu7rmiYqSfk0ZwyRk00EIcmbT2dtw=; b=CQdZPH0x4W6nzTpFKwGvYAWGUiBaCK+Y2R0A/iQtNtGn2BROkEfGVHOCTXopm72+cj Ku8eUGmmW/oCDVU8/UztUGSV/vdQB1VU14ZbEYSA+DstZ6mhRH0qZmP70qEEyg3IUxP0 6EXm0lswxSTqGpqNhrJa6WGnhCZKdE8khXsimZJkvl3ZmtZXi/+7fuKwJaSZHUYwDd0t WB+MSBBsU4H5Gw/PegUnsEfJL5tBaBDpNs2Pwj7ui8/ztpJNL/+I5SDqEx8mdyJWtqjk 427GRxbCv9PdSLjOBuh8sVUNLfwhJ0607f/5msLTu5rzfZV2bm/6Gv1I2C63yNBi4NNQ 9z9g== X-Gm-Message-State: AOAM533EhooNZait4UD2n9B+RXDIM1f7ndtpBblJw8X7FQ7kq1286+yu QW87FoWwYA+VovbAiVsU34M= X-Google-Smtp-Source: ABdhPJzw4U8q5rbTZB4+t8IPMaGPN4XsSdfbVfzHaDlRF9s6uGKMK48Tr9YlkcxOHPhdpKwN2NPs3w== X-Received: by 2002:a05:6402:1c8a:: with SMTP id cy10mr4945814edb.112.1629660180229; Sun, 22 Aug 2021 12:23:00 -0700 (PDT) Received: from localhost.localdomain ([147.235.73.50]) by smtp.googlemail.com with ESMTPSA id o6sm1577950eje.6.2021.08.22.12.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Aug 2021 12:23:00 -0700 (PDT) From: Ariel Marcovitch Cc: Ariel Marcovitch , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] checkkconfigsymbols.py: Forbid passing 'HEAD' to --commit Date: Sun, 22 Aug 2021 22:22:03 +0300 Message-Id: <20210822192205.43210-4-arielmarcovitch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210822192205.43210-1-arielmarcovitch@gmail.com> References: <20210822192205.43210-1-arielmarcovitch@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org As opposed to the --diff option, --commit can get ref names instead of commit hashes. When using the --commit option, the script resets the working directory to the commit before the given ref, by adding '~' to the end of the ref. However, the 'HEAD' ref is relative, and so when the working directory is reset to 'HEAD~', 'HEAD' points to what was 'HEAD~'. Then when the script resets to 'HEAD' it actually stays in the same commit. In this case, the script won't report any cases because there is no diff between the cases of the two refs. Prevent the user from using HEAD refs. A better solution might be to resolve the refs before doing the reset, but for now just disallow such refs. Signed-off-by: Ariel Marcovitch --- scripts/checkkconfigsymbols.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index 875e9a2c14b2..6259698e662d 100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py @@ -103,6 +103,9 @@ def parse_options(): "continue.") if args.commit: + if args.commit.startswith('HEAD'): + sys.exit("The --commit option can't get use the HEAD ref") + args.find = False if args.ignore: