All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf beauty: Fix fsconfig generator
@ 2021-04-14 16:29 Vitaly Chikunov
  2021-04-14 18:04 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Vitaly Chikunov @ 2021-04-14 16:29 UTC (permalink / raw)
  To: linux-kernel, Arnaldo Carvalho de Melo; +Cc: Dmitry V. Levin, Vitaly Chikunov

After gnulib update sed stopped matching `[[:space:]]*+' as before,
causing the following compilation error:

  In file included from builtin-trace.c:719:
  trace/beauty/generated/fsconfig_arrays.c:2:3: error: expected expression before ']' token
      2 |  [] = "",
	|   ^
  trace/beauty/generated/fsconfig_arrays.c:2:3: error: array index in initializer not of integer type
  trace/beauty/generated/fsconfig_arrays.c:2:3: note: (near initialization for 'fsconfig_cmds')

Fix this by correcting the regular expression used in the generator.
Also, clean up the script by removing redundant egrep, xargs, and printf
invocations.

Fixes: d35293004a5e4 ("perf beauty: Add generator for fsconfig's 'cmd' arg values")
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---
 tools/perf/trace/beauty/fsconfig.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/perf/trace/beauty/fsconfig.sh b/tools/perf/trace/beauty/fsconfig.sh
index 83fb24df05c9f..cc76b2aa7a5af 100755
--- a/tools/perf/trace/beauty/fsconfig.sh
+++ b/tools/perf/trace/beauty/fsconfig.sh
@@ -10,8 +10,6 @@ fi
 linux_mount=${linux_header_dir}/mount.h
 
 printf "static const char *fsconfig_cmds[] = {\n"
-regex='^[[:space:]]*+FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,[[:space:]]*.*'
-egrep $regex ${linux_mount} | \
-	sed -r "s/$regex/\2 \1/g"	| \
-	xargs printf "\t[%s] = \"%s\",\n"
+regex='^[[:space:]]*FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,.*'
+sed -nr "s/$regex/\t[\2] = \"\1\",/p" ${linux_mount}
 printf "};\n"
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf beauty: Fix fsconfig generator
  2021-04-14 16:29 [PATCH] perf beauty: Fix fsconfig generator Vitaly Chikunov
@ 2021-04-14 18:04 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-04-14 18:04 UTC (permalink / raw)
  To: Vitaly Chikunov; +Cc: linux-kernel, Dmitry V. Levin

Em Wed, Apr 14, 2021 at 07:29:42PM +0300, Vitaly Chikunov escreveu:
> After gnulib update sed stopped matching `[[:space:]]*+' as before,
> causing the following compilation error:
> 
>   In file included from builtin-trace.c:719:
>   trace/beauty/generated/fsconfig_arrays.c:2:3: error: expected expression before ']' token
>       2 |  [] = "",
> 	|   ^
>   trace/beauty/generated/fsconfig_arrays.c:2:3: error: array index in initializer not of integer type
>   trace/beauty/generated/fsconfig_arrays.c:2:3: note: (near initialization for 'fsconfig_cmds')
> 
> Fix this by correcting the regular expression used in the generator.
> Also, clean up the script by removing redundant egrep, xargs, and printf
> invocations.
> 
> Fixes: d35293004a5e4 ("perf beauty: Add generator for fsconfig's 'cmd' arg values")
> Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> ---
>  tools/perf/trace/beauty/fsconfig.sh | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/trace/beauty/fsconfig.sh b/tools/perf/trace/beauty/fsconfig.sh
> index 83fb24df05c9f..cc76b2aa7a5af 100755
> --- a/tools/perf/trace/beauty/fsconfig.sh
> +++ b/tools/perf/trace/beauty/fsconfig.sh
> @@ -10,8 +10,6 @@ fi
>  linux_mount=${linux_header_dir}/mount.h
>  
>  printf "static const char *fsconfig_cmds[] = {\n"
> -regex='^[[:space:]]*+FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,[[:space:]]*.*'
> -egrep $regex ${linux_mount} | \
> -	sed -r "s/$regex/\2 \1/g"	| \
> -	xargs printf "\t[%s] = \"%s\",\n"
> +regex='^[[:space:]]*FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,.*'
> +sed -nr "s/$regex/\t[\2] = \"\1\",/p" ${linux_mount}
>  printf "};\n"

Testing this, all working, I'll step back and ask you to remove that now
useless regex variable and do it directly in the now only line using it,
the sed one.

- Arnaldo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-14 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 16:29 [PATCH] perf beauty: Fix fsconfig generator Vitaly Chikunov
2021-04-14 18:04 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.