From patchwork Sun Dec 3 10:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13477229 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 E2BFE8F69 for ; Sun, 3 Dec 2023 10:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JDdpwq8W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2763C433C8; Sun, 3 Dec 2023 10:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701599134; bh=Oxu1+DS1jbu9WvPR52tw/o+GCX/xwK7ZLpJvE+EAR00=; h=From:To:Cc:Subject:Date:From; b=JDdpwq8WWdLnxwYRpZ9zuiYmg7je1V5eX0RzpdTO8N9MS94+aPjZl6kTXipw/ajTu 7hCG7YIl0KC54zLsWqFKb4Inu/Rc5yXLvNlaffKW/XOT3v3NwNvd5Znz8wcTF6klIY Ra8oxlSP02YlGDXRWxIk04+YC9mP6zYbNNdQogqINcMRf1ZoHWVC+BgQ5w3dILLAzv u8kgvR89ZNQuH7vPosKXWRD9/FL9yNYzeVikUZVRI21VhdlhLizwMcx1jkT0YU9iVg 5roj9FK3BZeWDqewZ/+6zHV4urJLlmlXiGzjXumU6ES6KIfbEeN2fheXTR5Fks71UF +QCtjziFXLrkQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] kconfig: factor out common code shared by mconf and nconf Date: Sun, 3 Dec 2023 19:25:23 +0900 Message-Id: <20231203102528.1913822-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Separate out the duplicated code to mnconf-common.c. Signed-off-by: Masahiro Yamada --- scripts/kconfig/Makefile | 4 +-- scripts/kconfig/mconf.c | 54 +-------------------------------- scripts/kconfig/mnconf-common.c | 53 ++++++++++++++++++++++++++++++++ scripts/kconfig/mnconf-common.h | 18 +++++++++++ scripts/kconfig/nconf.c | 53 +------------------------------- 5 files changed, 75 insertions(+), 107 deletions(-) create mode 100644 scripts/kconfig/mnconf-common.c create mode 100644 scripts/kconfig/mnconf-common.h diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 322c061b464d..7c025f82718e 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -174,7 +174,7 @@ conf-objs := conf.o $(common-objs) # nconf: Used for the nconfig target based on ncurses hostprogs += nconf -nconf-objs := nconf.o nconf.gui.o $(common-objs) +nconf-objs := nconf.o nconf.gui.o mnconf-common.o $(common-objs) HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) @@ -187,7 +187,7 @@ $(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags hostprogs += mconf lxdialog := $(addprefix lxdialog/, \ checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) -mconf-objs := mconf.o $(lxdialog) $(common-objs) +mconf-objs := mconf.o $(lxdialog) mnconf-common.o $(common-objs) HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) $(foreach f, mconf.o $(lxdialog), \ diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 3795c36a9181..5df32148a869 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -21,6 +21,7 @@ #include "lkc.h" #include "lxdialog/dialog.h" +#include "mnconf-common.h" static const char mconf_readme[] = "Overview\n" @@ -286,7 +287,6 @@ static int single_menu_mode; static int show_all_options; static int save_and_exit; static int silent; -static int jump_key_char; static void conf(struct menu *menu, struct menu *active_menu); @@ -378,58 +378,6 @@ static void show_help(struct menu *menu) str_free(&help); } -struct search_data { - struct list_head *head; - struct menu *target; -}; - -static int next_jump_key(int key) -{ - if (key < '1' || key > '9') - return '1'; - - key++; - - if (key > '9') - key = '1'; - - return key; -} - -static int handle_search_keys(int key, size_t start, size_t end, void *_data) -{ - struct search_data *data = _data; - struct jump_key *pos; - int index = 0; - - if (key < '1' || key > '9') - return 0; - - list_for_each_entry(pos, data->head, entries) { - index = next_jump_key(index); - - if (pos->offset < start) - continue; - - if (pos->offset >= end) - break; - - if (key == index) { - data->target = pos->target; - return 1; - } - } - - return 0; -} - -int get_jump_key_char(void) -{ - jump_key_char = next_jump_key(jump_key_char); - - return jump_key_char; -} - static void search_conf(void) { struct symbol **sym_arr; diff --git a/scripts/kconfig/mnconf-common.c b/scripts/kconfig/mnconf-common.c new file mode 100644 index 000000000000..18cb9a6c5aaa --- /dev/null +++ b/scripts/kconfig/mnconf-common.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "expr.h" +#include "list.h" +#include "mnconf-common.h" + +int jump_key_char; + +int next_jump_key(int key) +{ + if (key < '1' || key > '9') + return '1'; + + key++; + + if (key > '9') + key = '1'; + + return key; +} + +int handle_search_keys(int key, size_t start, size_t end, void *_data) +{ + struct search_data *data = _data; + struct jump_key *pos; + int index = 0; + + if (key < '1' || key > '9') + return 0; + + list_for_each_entry(pos, data->head, entries) { + index = next_jump_key(index); + + if (pos->offset < start) + continue; + + if (pos->offset >= end) + break; + + if (key == index) { + data->target = pos->target; + return 1; + } + } + + return 0; +} + +int get_jump_key_char(void) +{ + jump_key_char = next_jump_key(jump_key_char); + + return jump_key_char; +} diff --git a/scripts/kconfig/mnconf-common.h b/scripts/kconfig/mnconf-common.h new file mode 100644 index 000000000000..ab6292cc4bf2 --- /dev/null +++ b/scripts/kconfig/mnconf-common.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef MNCONF_COMMON_H +#define MNCONF_COMMON_H + +#include + +struct search_data { + struct list_head *head; + struct menu *target; +}; + +extern int jump_key_char; + +int next_jump_key(int key); +int handle_search_keys(int key, size_t start, size_t end, void *_data); +int get_jump_key_char(void); + +#endif /* MNCONF_COMMON_H */ diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 8cd72fe25974..1148163cfa7e 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -12,6 +12,7 @@ #include #include "lkc.h" +#include "mnconf-common.h" #include "nconf.h" #include @@ -279,7 +280,6 @@ static const char *current_instructions = menu_instructions; static char *dialog_input_result; static int dialog_input_result_len; -static int jump_key_char; static void selected_conf(struct menu *menu, struct menu *active_menu); static void conf(struct menu *menu); @@ -691,57 +691,6 @@ static int do_exit(void) return 0; } -struct search_data { - struct list_head *head; - struct menu *target; -}; - -static int next_jump_key(int key) -{ - if (key < '1' || key > '9') - return '1'; - - key++; - - if (key > '9') - key = '1'; - - return key; -} - -static int handle_search_keys(int key, size_t start, size_t end, void *_data) -{ - struct search_data *data = _data; - struct jump_key *pos; - int index = 0; - - if (key < '1' || key > '9') - return 0; - - list_for_each_entry(pos, data->head, entries) { - index = next_jump_key(index); - - if (pos->offset < start) - continue; - - if (pos->offset >= end) - break; - - if (key == index) { - data->target = pos->target; - return 1; - } - } - - return 0; -} - -int get_jump_key_char(void) -{ - jump_key_char = next_jump_key(jump_key_char); - - return jump_key_char; -} static void search_conf(void) { From patchwork Sun Dec 3 10:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13477230 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 EEAAA8F69 for ; Sun, 3 Dec 2023 10:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e0F0Nnyp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF795C433CA; Sun, 3 Dec 2023 10:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701599135; bh=5SBYjvSXCCi361BUF6jW6e0HVe2sXM0i9kXYxAiDfG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0F0Nnyp3WZmkSirOGw6DV/AN4cIC1JcR0C8H9SZRzwHSlALHuz+2Bnoepfd8ypx+ VW/Q0aG5avI60eQyeSm469rI3VsIP7VpiQwldFz3FKqr7zRQZCtutd6za0np9Babm4 SRV2eCNl2eh9VVmniqMoUJfFeFLMl3dPnoFpVmJu3Af3uC9TiUme7eVkZKcFJtmcsC dnnXI6gceb5k620eQCgygAiExRPYv3zLiAtKtEPot1LVpdF1fYL7xZIL/YxoENVrY/ kljsBARO72ssfdQ4CReLXWLOp2KRUghuhO+OL6bBVp/WxPyOXo9uPaH49L0iFW0Pl+ y0O1ffyelLi2Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] kconfig: make menu_warn() static function Date: Sun, 3 Dec 2023 19:25:24 +0900 Message-Id: <20231203102528.1913822-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231203102528.1913822-1-masahiroy@kernel.org> References: <20231203102528.1913822-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function is only used locally within menu.c. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lkc.h | 1 - scripts/kconfig/menu.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 471a59acecec..3908741edf8f 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -80,7 +80,6 @@ char *str_get(struct gstr *gs); /* menu.c */ void _menu_init(void); -void menu_warn(struct menu *menu, const char *fmt, ...); struct menu *menu_add_menu(void); void menu_end_menu(void); void menu_add_entry(struct symbol *sym); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 61c442d84aef..f07c0d8691af 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -19,7 +19,7 @@ static struct menu **last_entry_ptr; struct file *file_list; struct file *current_file; -void menu_warn(struct menu *menu, const char *fmt, ...) +static void menu_warn(struct menu *menu, const char *fmt, ...) { va_list ap; va_start(ap, fmt); From patchwork Sun Dec 3 10:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13477231 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 2A7D779DC for ; Sun, 3 Dec 2023 10:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IKMP5z88" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3ADEC433D9; Sun, 3 Dec 2023 10:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701599136; bh=xr4qK+/McATkt6q41PjvXqtg2z7HnzV21XZ0nlNgetk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKMP5z88fzjGpGdCnlKyWmfF+b6BNwd1jdWHy3CARQgDPGEfpSPxyUnfveZzZ5VwM UdNtQweYYnU6E3R/t065Yy5ssR4Tq0SxW6QpO2BrYfCw5wLLESe+zeFWdchcUeuamd B2OL01AOAjKwc0YuwrDp6JoyzwM+V/CxQaWHd/GWLsNILwoWY0B9LWe7Z2GS3DR88V /zg7o0LV9bRcP7TGcbx1Nlgk4jHttWPlPbenCYOgQvxPCvz9/orfaZUdrkfK6jsGjH mgNJolZleOnXZv+ScCdbIdkw5UTpq3eN/ZZ/dgZu7mZXRVYew2EtZ3PjIOvNQhrzFC y81wxIlKhNtsg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] kconfig: squash menu_has_help() and menu_get_help() Date: Sun, 3 Dec 2023 19:25:25 +0900 Message-Id: <20231203102528.1913822-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231203102528.1913822-1-masahiroy@kernel.org> References: <20231203102528.1913822-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 menu_has_help() and menu_get_help() functions are only used within menu_get_ext_help(). Squash them into menu_get_ext_help(). It revealed the if-conditional in menu_get_help() was unneeded, as menu_has_help() has already checked that menu->help is not NULL. Signed-off-by: Masahiro Yamada --- scripts/kconfig/lkc.h | 2 -- scripts/kconfig/menu.c | 17 ++--------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 3908741edf8f..8ca5bbc74df1 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -98,8 +98,6 @@ bool menu_is_visible(struct menu *menu); bool menu_has_prompt(struct menu *menu); const char *menu_get_prompt(struct menu *menu); struct menu *menu_get_parent_menu(struct menu *menu); -bool menu_has_help(struct menu *menu); -const char *menu_get_help(struct menu *menu); int get_jump_key_char(void); struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); void menu_get_ext_help(struct menu *menu, struct gstr *help); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index f07c0d8691af..dc60a9ddc5dd 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -673,19 +673,6 @@ struct menu *menu_get_parent_menu(struct menu *menu) return menu; } -bool menu_has_help(struct menu *menu) -{ - return menu->help != NULL; -} - -const char *menu_get_help(struct menu *menu) -{ - if (menu->help) - return menu->help; - else - return ""; -} - static void get_def_str(struct gstr *r, struct menu *menu) { str_printf(r, "Defined at %s:%d\n", @@ -856,10 +843,10 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) struct symbol *sym = menu->sym; const char *help_text = nohelp_text; - if (menu_has_help(menu)) { + if (menu->help) { if (sym->name) str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); - help_text = menu_get_help(menu); + help_text = menu->help; } str_printf(help, "%s\n", help_text); if (sym) From patchwork Sun Dec 3 10:25:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13477232 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 3F0AC79DC for ; Sun, 3 Dec 2023 10:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vj+fwQJa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E37B6C433C9; Sun, 3 Dec 2023 10:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701599137; bh=LEoTggARida+p4FLdOShzFKl4z7iyh9a/kviqyZ5sDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vj+fwQJayDbwrfs2+Hs+St+PCRLNFFY8IDpG2/4YAkzdbMeKDiNE472eFVcZw9Ezc 8dFreVRKLo4w6cAS8YUWeD8Q92tyUA7fF+4vmeD+tp9Pzd/2JYLtyAcWG4Vi7dd7q5 Qw2tFWn2qqxLJB010d/eYVy7dmWHsiiDWPVo/wVZkEXeCrao3W+CWHYlvy+KP4uYBo rBmOYjV9W3U81PjmHHKkfWalzGcrmgKwg+163ciOjhohFHK2CKezf6disP4A5fO0Zr Dcvuxr5j0gFQrcaoH/RrWS+V+5IgjaI5RFJCcZ0pXh7a0UTdqBjaZZZEKW+ERKZcjp 1dW9m6ivPmmPw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] kconfig: add include guard to lkc_proto.h Date: Sun, 3 Dec 2023 19:25:26 +0900 Message-Id: <20231203102528.1913822-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231203102528.1913822-1-masahiroy@kernel.org> References: <20231203102528.1913822-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Masahiro Yamada --- scripts/kconfig/lkc_proto.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index edd1e617b25c..687d8698d801 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -1,4 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifndef LKC_PROTO_H +#define LKC_PROTO_H + #include /* confdata.c */ @@ -50,3 +53,5 @@ 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); + +#endif /* LKC_PROTO_H */ From patchwork Sun Dec 3 10:25:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13477233 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 D38B89463; Sun, 3 Dec 2023 10:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ru11GhM8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08552C433CA; Sun, 3 Dec 2023 10:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701599139; bh=/G/U1jJhbg6VKWyteRfH6C1mvYApP8yrSi62PoEqI9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ru11GhM84CbNOelG13KOP1EoEqrb8+Wvlvslrb7HO888VE7rXPv8gGZNWGla1cS2c /vzIfuDA7nv5eCPMlO/dUbAT1l2/8dSPRLuyq1q7qHSx6xZU4pyZRzeXpOABc7hasb GrVzvInmpj19XxroKZTs8Ulwp20rJyHa6ejUCPLhjztl7s4S7SIoesFrougAlvMqis O+DVF79EGrgNWxMnJF37ZTdwifA++f2ylh+huqAlQCjyc+QT5Bvv9yKHhzV2r/Qq1o P9pt2ypmlUV9rXAv/HTjBE1K+VhMnBe13AzN8iEBtsT7aMWQxBNKYvn3qlollSvI3v IAswBND4PDQnw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 5/6] kconfig: remove unreachable printf() Date: Sun, 3 Dec 2023 19:25:27 +0900 Message-Id: <20231203102528.1913822-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231203102528.1913822-1-masahiroy@kernel.org> References: <20231203102528.1913822-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the unreachable code detected by clang. $ make HOSTCC=clang HOSTCFLAGS=-Wunreachable-code defconfig [ snip ] scripts/kconfig/expr.c:1134:2: warning: code will never be executed [-Wunreachable-code] printf("[%dgt%d?]", t1, t2); ^~~~~~ 1 warning generated. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 81ebf8108ca7..a290de36307b 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1131,7 +1131,6 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) default: return -1; } - printf("[%dgt%d?]", t1, t2); return 0; } From patchwork Sun Dec 3 10:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13477234 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 0419AB654 for ; Sun, 3 Dec 2023 10:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cO6Viyxe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A04F0C433C8; Sun, 3 Dec 2023 10:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701599140; bh=Lnc3/O+6CGAEAS2bB5Go5eHeE+xwqLvuu2/DPt0BL5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cO6ViyxeBuYd4k0wYeSUZ2wRRCgCArk8SlgrIlhwtkOCQuajWRfPbcE/PA68owivB qzSGcHRasVodTIV5akKFFbHJJerXJTboGgemSWzDxbcQWyj2BEUVp6Iytzg+doS3ci ChiV5qQaogDbCC4R/vZTLgoXSxUVHmqzpD1NO94CUSyUrtvWsVnCTVXSr1m0dyFhZc XBQwGJl7icuvWAQ3CSoyGadulYrl3B8bt+pFfA4qfQmW6GmZqNF2bT9ZtuSQM3p5gB AR4QDeP2XKfr5Fe3QfTWUWV8UGFNa1FeIapCUTirBFC+D+sr6GWALN7w/7cghSoXf2 r48aKdBWseT4g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] kconfig: remove redundant NULL pointer check before free() Date: Sun, 3 Dec 2023 19:25:28 +0900 Message-Id: <20231203102528.1913822-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231203102528.1913822-1-masahiroy@kernel.org> References: <20231203102528.1913822-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Passing NULL to free() is allowed and is a no-op. Remove redundant NULL pointer checks. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 3 +-- scripts/kconfig/util.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index bd14aae1db58..f1197e672431 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -432,8 +432,7 @@ int conf_read_simple(const char *name, int def) case S_INT: case S_HEX: case S_STRING: - if (sym->def[def].val) - free(sym->def[def].val); + free(sym->def[def].val); /* fall through */ default: sym->def[def].val = NULL; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index b78f114ad48c..92e5b2b9761d 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -42,8 +42,7 @@ struct gstr str_new(void) /* Free storage for growable string */ void str_free(struct gstr *gs) { - if (gs->s) - free(gs->s); + free(gs->s); gs->s = NULL; gs->len = 0; }