Message ID | 20230629160351.2996541-2-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9759501vqr; Thu, 29 Jun 2023 09:27:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HeCrDABahPcKzgTutDK683th35nwp+oyOhfMslfOnQfnuQu/+yrAZo/rkfbjRdZrnnRXO X-Received: by 2002:a17:903:2051:b0:1b8:2ba0:c9a8 with SMTP id q17-20020a170903205100b001b82ba0c9a8mr6829767pla.2.1688056056592; Thu, 29 Jun 2023 09:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688056056; cv=none; d=google.com; s=arc-20160816; b=WnY8h5JT064TWAiUYGKjtuIdiQglQWQD+v2LACsZE/sjTkl/x1JA9xOiGkZLxkhx1+ FEJKm46VP/Ax7UW5ctTEEbP8jr54id2O5uT/2oKHA/2qvNz8kL7NJAgTLMJ1NpOOOD0Z DOj7Q+ud7rBZN7Cp7Nz9diP3zv0bll1dk2Lwn/ec5jMTLL0rzTTx7D4Y9WBwwd6ABbGx RarGQDJuNYnRgG0V+SD88hMV9K82NL65HbKJlg+sU75JguAPUg6Kgt5Y2Cn/wjW4MuIj gAOVUB9iWUvOzvGbH4EvdVcX3KCztfpkigeYyPr4s06OkwC5SQ64Jp34Y32mMZ1RH9TF C8jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FzrQWiG8yEJ6gS5brF1RKO/zeLNmlCEDpPacxHOk4yI=; fh=LAvKCTCkOR6JLV+1HSkDX+xK3iySpNFcJw3S+JzCk2k=; b=mKSrjjmwxWj4IPvuLdyN6EKvAj/XyuHb8nC/3TmSFe2ziY5MFHYKNh4STMwMyzxQVE bqb8i5OZWZ4c0K6b8d1lXqa08aaREncHEnzvy/5agVfg+eOuazQ+DpXRNB9AFUXNHncG VSPFoaiKCm9T6ZLqgGFYlqP02dYa3bqq2f7pS1rADqYiVEB9dzNI9FCcs0vMooN7jd1h ovu5rN1WelAP8Atd5KMJ/1wTjo7HUdXBzYorDj8zZ8WRalnIpHSj3MpI/PfXHYufHZHC uclG4ZBi6AMJ8S/5vHjtU+w3jCLscJr3grJv0veodW4p1q4WzQaqPjyElEKp6/cTIFzH /Wvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LNvpacQZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a170903234400b001b3df47010dsi6212349plh.408.2023.06.29.09.27.21; Thu, 29 Jun 2023 09:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LNvpacQZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbjF2QEE (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Thu, 29 Jun 2023 12:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbjF2QEB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 12:04:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FE6C10D5; Thu, 29 Jun 2023 09:04:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9FE96156D; Thu, 29 Jun 2023 16:03:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D0BC433C9; Thu, 29 Jun 2023 16:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688054639; bh=kecJ7j1mmrkVEupftE0qUI4crvKvKvDb/jves3wo4F8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNvpacQZCKhYQq0u34fEhS/M05Vbgc2zSsPVWnBSBjsYihTTq4GETbJAt5V0CmitM yhHawHUZOqsGxIG3amSA/Ik0QwKPrBUnsJCSKOSZXF5n4Y5YXLU4A4rwkiyDRUNoR7 AAs27VNslKEYpDQk8yqWmodKY3+zfTInYoBXnKI1GleH7IZgtEEPL/KycXaHZeRSWp L1tNtqfK4d5ntfL4FzjEt4D0G5yBitStGgMT0bNYvyI9wNz/Io0we7sRLWLB4h3IrL g656gucy5TjjdzFJw9tVKIAhjVsYmrh0sMQLrspo9JZ1S1QPSmGxlloAURpNAa/Okp akf/g91y3VYdg== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jesse Taube <Mr.Bossman075@gmail.com>, Masahiro Yamada <masahiroy@kernel.org> Subject: [PATCH 2/2] kconfig: menuconfig: remove jump_key::index Date: Fri, 30 Jun 2023 01:03:51 +0900 Message-Id: <20230629160351.2996541-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230629160351.2996541-1-masahiroy@kernel.org> References: <20230629160351.2996541-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770055067452315864?= X-GMAIL-MSGID: =?utf-8?q?1770055067452315864?= |
Series |
[1/2] kconfig: menuconfig: simplify global jump key assignment
|
|
Commit Message
Masahiro Yamada
June 29, 2023, 4:03 p.m. UTC
You do not need to remember the index of each jump key because you can
count it up after a key is pressed.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/kconfig/expr.h | 1 -
scripts/kconfig/mconf.c | 7 ++++---
scripts/kconfig/menu.c | 8 --------
3 files changed, 4 insertions(+), 12 deletions(-)
Comments
On Thu, Jun 29, 2023 at 12:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > You do not need to remember the index of each jump key because you can > count it up after a key is pressed. > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > --- > > scripts/kconfig/expr.h | 1 - > scripts/kconfig/mconf.c | 7 ++++--- > scripts/kconfig/menu.c | 8 -------- > 3 files changed, 4 insertions(+), 12 deletions(-) > > diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h > index 9c9caca5bd5f..4a9a23b1b7e1 100644 > --- a/scripts/kconfig/expr.h > +++ b/scripts/kconfig/expr.h > @@ -275,7 +275,6 @@ struct jump_key { > struct list_head entries; > size_t offset; > struct menu *target; > - int index; > }; > > extern struct file *file_list; > diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c > index 7adfd6537279..fcb91d69c774 100644 > --- a/scripts/kconfig/mconf.c > +++ b/scripts/kconfig/mconf.c > @@ -22,8 +22,6 @@ > #include "lkc.h" > #include "lxdialog/dialog.h" > > -#define JUMP_NB 9 > - > static const char mconf_readme[] = > "Overview\n" > "--------\n" > @@ -399,6 +397,7 @@ static int handle_search_keys(int key, int start, int end, void *_data) > { > struct search_data *data = _data; > struct jump_key *pos; > + int index = '1'; > > if (key < '1' || key > '9') > return 0; > @@ -408,11 +407,13 @@ static int handle_search_keys(int key, int start, int end, void *_data) > if (pos->offset >= end) > break; > > - if (key == '1' + (pos->index % JUMP_NB)) { > + if (key == index) { > data->target = pos->target; > return 1; > } > } > + > + index = next_key(index); > } > > return 0; > diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c > index 5578b8bc8a23..198eb1367e7a 100644 > --- a/scripts/kconfig/menu.c > +++ b/scripts/kconfig/menu.c > @@ -735,15 +735,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, > } > if (head && location) { > jump = xmalloc(sizeof(struct jump_key)); > - > jump->target = location; > - > - if (list_empty(head)) > - jump->index = 0; > - else > - jump->index = list_entry(head->prev, struct jump_key, > - entries)->index + 1; > - > list_add_tail(&jump->entries, head); > } > > -- > 2.39.2 > Looks good! Reviewed-by: Jesse Taube <Mr.Bossman075@gmail.com> One slight off-topic question. The names of the menu-based config programs have names similar to their corresponding file gconfig ('gconf'), xconfig ('qconf'), menuconfig ('mconf'), and nconfig ('nconf'). The only exceptions to this one-letter naming are mconfig is not memuconfig and qconfig isn't xconfig. Would it be possible to add an alias to fix this? Side-side note config isn't in the docs. Thanks, Jesse Taube
Hi Jesse, On 6/30/23 21:08, Jesse T wrote: > On Thu, Jun 29, 2023 at 12:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote: >> >> You do not need to remember the index of each jump key because you can >> count it up after a key is pressed. >> >> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> >> --- > > One slight off-topic question. > The names of the menu-based config programs have names similar to their > corresponding file gconfig ('gconf'), xconfig ('qconf'), menuconfig ('mconf'), > and nconfig ('nconf'). The only exceptions to this one-letter naming are mconfig > is not memuconfig and qconfig isn't xconfig. Would it be possible to > add an alias > to fix this? > > Side-side note config isn't in the docs. I'm not following what you mean here. Are you referring to 'make config'? So: what documentation is missing and where would it be found? thanks.
On Sat, Jul 1, 2023 at 12:23 AM Randy Dunlap <rdunlap@infradead.org> wrote: > > Hi Jesse, > > On 6/30/23 21:08, Jesse T wrote: > > On Thu, Jun 29, 2023 at 12:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > >> > >> You do not need to remember the index of each jump key because you can > >> count it up after a key is pressed. > >> > >> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > >> --- > > > > > One slight off-topic question. > > The names of the menu-based config programs have names similar to their > > corresponding file gconfig ('gconf'), xconfig ('qconf'), menuconfig ('mconf'), > > and nconfig ('nconf'). The only exceptions to this one-letter naming are mconfig > > is not memuconfig and qconfig isn't xconfig. Would it be possible to > > add an alias > > to fix this? > > > > Side-side note config isn't in the docs. > > I'm not following what you mean here. > Are you referring to 'make config'? Typo sorry, `make gconfig` It's not listed at the top Documentation/kbuild/kconfig.rst and only briefly mentioned at the bottom. > > So: what documentation is missing and where would it be found? > > thanks. > -- > ~Randy
On 6/30/23 21:38, Jesse T wrote: > On Sat, Jul 1, 2023 at 12:23 AM Randy Dunlap <rdunlap@infradead.org> wrote: >> >> Hi Jesse, >> >> On 6/30/23 21:08, Jesse T wrote: >>> On Thu, Jun 29, 2023 at 12:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote: >>>> >>>> You do not need to remember the index of each jump key because you can >>>> count it up after a key is pressed. >>>> >>>> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> >>>> --- >> >>> >>> One slight off-topic question. >>> The names of the menu-based config programs have names similar to their >>> corresponding file gconfig ('gconf'), xconfig ('qconf'), menuconfig ('mconf'), >>> and nconfig ('nconf'). The only exceptions to this one-letter naming are mconfig >>> is not memuconfig and qconfig isn't xconfig. Would it be possible to >>> add an alias >>> to fix this? >>> >>> Side-side note config isn't in the docs. >> >> I'm not following what you mean here. >> Are you referring to 'make config'? > > Typo sorry, `make gconfig` > It's not listed at the top Documentation/kbuild/kconfig.rst and only briefly > mentioned at the bottom. > Ah, I see. I don't mind adding it to kconfig.rst, but it is arguably (IMHO) the least useful of the *config interfaces since it doesn't have a search capability. >> >> So: what documentation is missing and where would it be found?
On Sat, Jul 1, 2023 at 1:09 PM Jesse T <mr.bossman075@gmail.com> wrote: > > On Thu, Jun 29, 2023 at 12:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > You do not need to remember the index of each jump key because you can > > count it up after a key is pressed. > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > --- > > > > scripts/kconfig/expr.h | 1 - > > scripts/kconfig/mconf.c | 7 ++++--- > > scripts/kconfig/menu.c | 8 -------- > > 3 files changed, 4 insertions(+), 12 deletions(-) > > > > diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h > > index 9c9caca5bd5f..4a9a23b1b7e1 100644 > > --- a/scripts/kconfig/expr.h > > +++ b/scripts/kconfig/expr.h > > @@ -275,7 +275,6 @@ struct jump_key { > > struct list_head entries; > > size_t offset; > > struct menu *target; > > - int index; > > }; > > > > extern struct file *file_list; > > diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c > > index 7adfd6537279..fcb91d69c774 100644 > > --- a/scripts/kconfig/mconf.c > > +++ b/scripts/kconfig/mconf.c > > @@ -22,8 +22,6 @@ > > #include "lkc.h" > > #include "lxdialog/dialog.h" > > > > -#define JUMP_NB 9 > > - > > static const char mconf_readme[] = > > "Overview\n" > > "--------\n" > > @@ -399,6 +397,7 @@ static int handle_search_keys(int key, int start, int end, void *_data) > > { > > struct search_data *data = _data; > > struct jump_key *pos; > > + int index = '1'; > > > > if (key < '1' || key > '9') > > return 0; > > @@ -408,11 +407,13 @@ static int handle_search_keys(int key, int start, int end, void *_data) > > if (pos->offset >= end) > > break; > > > > - if (key == '1' + (pos->index % JUMP_NB)) { > > + if (key == index) { > > data->target = pos->target; > > return 1; > > } > > } > > + > > + index = next_key(index); > > } > > > > return 0; > > diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c > > index 5578b8bc8a23..198eb1367e7a 100644 > > --- a/scripts/kconfig/menu.c > > +++ b/scripts/kconfig/menu.c > > @@ -735,15 +735,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, > > } > > if (head && location) { > > jump = xmalloc(sizeof(struct jump_key)); > > - > > jump->target = location; > > - > > - if (list_empty(head)) > > - jump->index = 0; > > - else > > - jump->index = list_entry(head->prev, struct jump_key, > > - entries)->index + 1; > > - > > list_add_tail(&jump->entries, head); > > } > > > > -- > > 2.39.2 > > > > Looks good! > Reviewed-by: Jesse Taube <Mr.Bossman075@gmail.com> > > One slight off-topic question. > The names of the menu-based config programs have names similar to their > corresponding file gconfig ('gconf'), xconfig ('qconf'), menuconfig ('mconf'), > and nconfig ('nconf'). The only exceptions to this one-letter naming are mconfig > is not memuconfig and qconfig isn't xconfig. Would it be possible to > add an alias > to fix this? I also wondered the same question in the past. I think xconfig was implemented differently at first, then later it was rewritten based on Qt. The former developers kept the target name 'xconfig' to avoid unneeded impacts, but the internal implementation changed a lot. So, it is a historical reason, I guess. I do not think it would be rewritten based on yet another library, but I just convinced myself "it's just a name" after all. > > Side-side note config isn't in the docs. > > Thanks, > Jesse Taube
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 9c9caca5bd5f..4a9a23b1b7e1 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -275,7 +275,6 @@ struct jump_key { struct list_head entries; size_t offset; struct menu *target; - int index; }; extern struct file *file_list; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 7adfd6537279..fcb91d69c774 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -22,8 +22,6 @@ #include "lkc.h" #include "lxdialog/dialog.h" -#define JUMP_NB 9 - static const char mconf_readme[] = "Overview\n" "--------\n" @@ -399,6 +397,7 @@ static int handle_search_keys(int key, int start, int end, void *_data) { struct search_data *data = _data; struct jump_key *pos; + int index = '1'; if (key < '1' || key > '9') return 0; @@ -408,11 +407,13 @@ static int handle_search_keys(int key, int start, int end, void *_data) if (pos->offset >= end) break; - if (key == '1' + (pos->index % JUMP_NB)) { + if (key == index) { data->target = pos->target; return 1; } } + + index = next_key(index); } return 0; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5578b8bc8a23..198eb1367e7a 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -735,15 +735,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, } if (head && location) { jump = xmalloc(sizeof(struct jump_key)); - jump->target = location; - - if (list_empty(head)) - jump->index = 0; - else - jump->index = list_entry(head->prev, struct jump_key, - entries)->index + 1; - list_add_tail(&jump->entries, head); }