From: Quentin Monnet Date: Fri, 2 Mar 2018 04:20:08 +0000 (-0800) Subject: tools: bpftool: support comments in batch files X-Git-Tag: v4.19~1326^2~312^2^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06cc7fe7c2951e64cd5e73ea447791c7e6bc3852;p=platform%2Fkernel%2Flinux-rpi3.git tools: bpftool: support comments in batch files Replace '#' by '\0' in commands read from batch files in order to avoid processing the remaining part of the line, thus allowing users to use comments in the files. Signed-off-by: Quentin Monnet Acked-by: Jakub Kicinski Signed-off-by: Daniel Borkmann --- diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 185acfa..79587e6 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -176,6 +176,7 @@ static int do_batch(int argc, char **argv) char buf[65536]; int n_argc; FILE *fp; + char *cp; int err; int i; @@ -200,6 +201,10 @@ static int do_batch(int argc, char **argv) if (json_output) jsonw_start_array(json_wtr); while (fgets(buf, sizeof(buf), fp)) { + cp = strchr(buf, '#'); + if (cp) + *cp = '\0'; + if (strlen(buf) == sizeof(buf) - 1) { errno = E2BIG; break;