On Thu, Jul 02 2026, "Simon Glass" <[email protected]> wrote:
> Hi Rasmus, > > On 2026-07-01T17:15:27, Rasmus Villemoes <[email protected]> wrote: >> cmd: config: allow simple filtering of output >> >> When doing development, it can be quite useful to enable >> CONFIG_CMD_CONFIG, so that one can always check whether a config knob >> one has just enabled has actually made it to target. >> >> Because sometimes, one doesn't flash the right binary, or maybe one >> has just done CONFIG_FOO=y in some config fragment, but that had no >> effect because one would also have to do CONFIG_BAR=y. >> >> However, 2400+ lines of text are rather hard to read through. One >> probably uses a terminal emulator with capturing enabled, but >> searching back through the capture file is a little tedious, and one >> easily ends up finding something that doesn't pertain to the most >> recent 'config' command invocation. >> >> So make it possible to limit the output to those lines containing a >> given string. Like the search functionality in menuconfig, make it >> case insensitive, because it is much more convenient to type "config >> pinctrl" than "config PINCTRL". >> [...] >> >> cmd/config.c | 25 ++++++++++++++++++++++--- >> 1 file changed, 22 insertions(+), 3 deletions(-) > >> diff --git a/cmd/config.c b/cmd/config.c >> @@ -29,7 +29,23 @@ static int do_config(struct cmd_tbl *cmdtp, int flag, int >> argc, >> + while (b < e) { >> + n = strchrnul(b, '\n'); >> + *n = '\0'; >> + >> + if (strcasestr(b, s)) { >> + puts(b); >> + puts('\n'); >> + } >> + b = n + 1; >> + } > > The two puts() could be a single printf("%s\n", b). Well, originally I just had the first puts(), then I found out that our puts() is not standards-compliant (which would automatically add that newline). I think I prefer keeping these as-is, to avoid a pathological case of some .config line exceeding CONFIG_SYS_PBSIZE and then be truncated (that could happen with some of the config options that are potentially long lists of strings, OF_LIST, DEVICE_TREE_INCLUDES, the like). > Also please add an explicit #include <linux/string.h> now that we rely > on strchrnul() and strcasestr() here. Ack. > Reviewed-by: Simon Glass <[email protected]> > > In addition to Tom's comment, how about a simple sandbox test? Ack. Rasmus

