From patchwork Thu Aug 17 01:19:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13355857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41A14C2FC14 for ; Thu, 17 Aug 2023 01:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347478AbjHQBUu (ORCPT ); Wed, 16 Aug 2023 21:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347514AbjHQBUc (ORCPT ); Wed, 16 Aug 2023 21:20:32 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2362D61 for ; Wed, 16 Aug 2023 18:20:25 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6889288a31fso308674b3a.1 for ; Wed, 16 Aug 2023 18:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1692235224; x=1692840024; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FvyxeUS9fq0mQZuA1GzyXjv4L0y4/K/wnguyQj7Xykk=; b=ZqhzWxk7QJkOCT6R4F8pbFod5NEa31t3jfoj9cyNhZbDZlSWjNzEZNkZP91pJtdKZz DJ8iGvN+jqVUjpYFYGkugedlVfuVXGy20ThwkUrrGFC0alkvId7W7ueXvwrgFt5aUfIg zS8xWHv2v4/NdB2IlV1tuEiArplP9y41mKTZk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692235224; x=1692840024; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FvyxeUS9fq0mQZuA1GzyXjv4L0y4/K/wnguyQj7Xykk=; b=BJrjSotzBQTUPbL2P7tU7omFhgCBJDxKsaCG61Kj8IHRMvYKw9sD8Q+Um3n9RaTWQu m00Maspyohi4yVKV5v7361hhFghkbvffEXS46kQ0Pxhx6+rFeL91eC1A3kdx+CwPzzHz NYv4UuvxDnErhGLBVC/UFppmPKI0ei+yiJVSQ/0mDeB1EqsOA5T3npZay+cuWzL/2Lrt MdyQz10EP5G8kVIPlDluIE8vFXtVNEKZSlqQ5KivOsOMKwgO2XrxPE3j3kEOslMnGqoa E1nKaTe3c3c+lG8T6xRWMGA+3LJzIq4WiNPEVMUe++lQCk3lHhuCzfhkeH5Upnk9iqHc gU2w== X-Gm-Message-State: AOJu0YwgOD+SPXpoiEzwkpS9wfRoHOQH/3Sc6KW8L+6H4wF3e7itzQT1 ocuNxuI60AMRqKApDdXj48UNHw== X-Google-Smtp-Source: AGHT+IH2q4lepA7YmeqrxG50qPCrrMNlYPYTXjfU9Hysz7Q9VTKdqFH6EII6oO0fteuDCQNZi3P8/Q== X-Received: by 2002:a05:6a20:1448:b0:134:3a9b:4cd7 with SMTP id a8-20020a056a20144800b001343a9b4cd7mr1546893pzi.23.1692235224554; Wed, 16 Aug 2023 18:20:24 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:1601:f73d:719a:8de1]) by smtp.gmail.com with ESMTPSA id n7-20020a62e507000000b00686b649cdd0sm11593737pff.86.2023.08.16.18.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 18:20:24 -0700 (PDT) From: Sergey Senozhatsky To: Masahiro Yamada Cc: Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Jonathan Corbet , Tomasz Figa , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [RFC][PATCH] kconfig: introduce listunknownconfig Date: Thu, 17 Aug 2023 10:19:58 +0900 Message-ID: <20230817012007.131868-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.41.0.694.ge786442a9b-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The listunknownconfig option reads old .config and lists all unrecognized symbols. This is especially useful for continuous kernel uprevs when some symbols can be either removed or renamed between kernel releases (which can go unnoticed otherwise). A recent real-life example of such a symbol rename that quietly disabled some drivers after kernel uprev is MFD_RK808 rename. Example: Suppose old .config has the following two options which were removed from the recent kernel: $ cat .config CONFIG_DISABLE_BUGS=y Running `make listunknownconfig` produces the following list of unrecognized symbols: .config:6:warning: unknown symbol: DISABLE_BUGS .config:7:warning: unknown unset symbol: ENABLE_WINAPI Signed-off-by: Sergey Senozhatsky --- Documentation/kbuild/kconfig.rst | 8 +++++ scripts/kconfig/Makefile | 4 ++- scripts/kconfig/conf.c | 8 +++++ scripts/kconfig/confdata.c | 55 ++++++++++++++++++++++++++++++++ scripts/kconfig/lkc_proto.h | 1 + 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/Documentation/kbuild/kconfig.rst b/Documentation/kbuild/kconfig.rst index 6530ecd99da3..445c438dc741 100644 --- a/Documentation/kbuild/kconfig.rst +++ b/Documentation/kbuild/kconfig.rst @@ -29,6 +29,14 @@ To see a list of new config symbols, use:: and the config program will list any new symbols, one per line. +To see a list of config symbols that are not recognized anymore (e.g. +removed or renamed), use:: + + cp user/some/old.config .config + make listunknownconfig + +and the config program will list any unrecognized symbols, one per line. + Alternatively, you can use the brute force method:: make oldconfig diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index af1c96198f49..942316ddebd9 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -69,7 +69,8 @@ localyesconfig localmodconfig: $(obj)/conf # deprecated for external use simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ alldefconfig randconfig listnewconfig olddefconfig syncconfig \ - helpnewconfig yes2modconfig mod2yesconfig mod2noconfig + helpnewconfig yes2modconfig mod2yesconfig mod2noconfig \ + listunknownconfig PHONY += $(simple-targets) @@ -141,6 +142,7 @@ help: @echo ' default value without prompting' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' + @echo ' listunknownconfig - List unrecognized options' # =========================================================================== # object files used by all kconfig flavours diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 33d19e419908..e26aa491be00 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -36,6 +36,7 @@ enum input_mode { yes2modconfig, mod2yesconfig, mod2noconfig, + listunknownconfig, }; static enum input_mode input_mode = oldaskconfig; static int input_mode_opt; @@ -683,6 +684,7 @@ static const struct option long_opts[] = { {"yes2modconfig", no_argument, &input_mode_opt, yes2modconfig}, {"mod2yesconfig", no_argument, &input_mode_opt, mod2yesconfig}, {"mod2noconfig", no_argument, &input_mode_opt, mod2noconfig}, + {"listunknownconfig", no_argument, &input_mode_opt, listunknownconfig}, {NULL, 0, NULL, 0} }; @@ -712,6 +714,7 @@ static void conf_usage(const char *progname) printf(" --yes2modconfig Change answers from yes to mod if possible\n"); printf(" --mod2yesconfig Change answers from mod to yes if possible\n"); printf(" --mod2noconfig Change answers from mod to no if possible\n"); + printf(" --listunknownconfig List config options that do not exist anymore\n"); printf(" (If none of the above is given, --oldaskconfig is the default)\n"); } @@ -823,6 +826,11 @@ int main(int ac, char **av) exit(1); } break; + case listunknownconfig: + if (conf_read_list_unknown()) + exit(1); + exit(0); + break; default: break; } diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 992575f1e976..d387a4f08cef 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -341,6 +341,61 @@ static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) return -1; } +int conf_read_list_unknown(void) +{ + FILE *in = NULL; + size_t line_asize = 0; + char *line = NULL; + char *p, *p2; + struct symbol *sym; + + conf_filename = conf_get_configname(); + in = zconf_fopen(conf_filename); + if (!in) + return -1; + + while (compat_getline(&line, &line_asize, in) != -1) { + conf_lineno++; + sym = NULL; + if (line[0] == '#') { + if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) + continue; + p = strchr(line + 2 + strlen(CONFIG_), ' '); + if (!p) + continue; + *p++ = 0; + sym = sym_find(line + 2 + strlen(CONFIG_)); + if (!sym) { + conf_warning("unknown unset symbol: %s", + line + 2 + strlen(CONFIG_)); + continue; + } + } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { + p = strchr(line + strlen(CONFIG_), '='); + if (!p) + continue; + *p++ = 0; + p2 = strchr(p, '\n'); + if (p2) { + *p2-- = 0; + if (*p2 == '\r') + *p2 = 0; + } + + sym = sym_find(line + strlen(CONFIG_)); + if (!sym) { + conf_warning("unknown symbol: %s", + line + strlen(CONFIG_)); + continue; + } + } + } + + free(line); + fclose(in); + return conf_warnings; +} + int conf_read_simple(const char *name, int def) { FILE *in = NULL; diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index edd1e617b25c..bb60b1669750 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -5,6 +5,7 @@ void conf_parse(const char *name); int conf_read(const char *name); int conf_read_simple(const char *name, int); +int conf_read_list_unknown(void); int conf_write_defconfig(const char *name); int conf_write(const char *name); int conf_write_autoconf(int overwrite);