perf top: Remove needless malloc(0) call that triggers -Walloc-size 28/312128/1
authorSun Haiyong <sunhaiyong@loongson.cn>
Mon, 4 Dec 2023 08:20:55 +0000 (16:20 +0800)
committerDongkyun Son <dongkyun.s@samsung.com>
Tue, 4 Jun 2024 11:48:05 +0000 (20:48 +0900)
commit275733ff01f0b9a19103e5316009277d32e7eb8b
treeb3b27552f5b14591e679e2739a674ec3af2d13c2
parent033b457bed3db4788d0806d55b12280f19deee3f
perf top: Remove needless malloc(0) call that triggers -Walloc-size

GCC 14 introduces a new -Walloc-size included in -Wextra which errors out
like:

  builtin-top.c: In function ‘prompt_integer’:
  builtin-top.c:360:21: error: allocation of insufficient size ‘0’ for
  type ‘char’ with size ‘1’ [-Werror=alloc-size]
    360 |         char *buf = malloc(0), *p;
        |                     ^~~~~~

Just set it to NULL, getline() will do the allocation.

cherry-picked from commit 79baac8acfc60a7a5114f6d60731e28c242ef8ce

Change-Id: I3065836e0e7c352eb7dd7a82b73d4392b8142221
Signed-off-by: Sun Haiyong <sunhaiyong@loongson.cn>
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231204082055.91877-1-siyanteng@loongson.cn
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-top.c