Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libperf tests: Avoid uninitialized variable warning

The variable 'bf' is read (for a write call) without being initialized
triggering a memory sanitizer warning. Use 'bf' in the read and switch
the write to reading from a string.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20210114212304.4018119-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
be82fddc a042a82d

+2 -2
+2 -2
tools/lib/perf/tests/test-evlist.c
··· 208 208 char path[PATH_MAX]; 209 209 int id, err, pid, go_pipe[2]; 210 210 union perf_event *event; 211 - char bf; 212 211 int count = 0; 213 212 214 213 snprintf(path, PATH_MAX, "%s/kernel/debug/tracing/events/syscalls/sys_enter_prctl/id", ··· 228 229 pid = fork(); 229 230 if (!pid) { 230 231 int i; 232 + char bf; 231 233 232 234 read(go_pipe[0], &bf, 1); 233 235 ··· 266 266 perf_evlist__enable(evlist); 267 267 268 268 /* kick the child and wait for it to finish */ 269 - write(go_pipe[1], &bf, 1); 269 + write(go_pipe[1], "A", 1); 270 270 waitpid(pid, NULL, 0); 271 271 272 272 /*