From: Sun Haiyong Date: Mon, 4 Dec 2023 08:20:55 +0000 (+0800) Subject: perf top: Remove needless malloc(0) call that triggers -Walloc-size X-Git-Tag: accepted/tizen/unified/x/20240725.154558~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35e648c36223d93a1cf8823ba6a9c10bdcb76067;p=platform%2Fkernel%2Flinux-riscv.git 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. Signed-off-by: Sun Haiyong Signed-off-by: Yanteng Si Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20231204082055.91877-1-siyanteng@loongson.cn Signed-off-by: Arnaldo Carvalho de Melo [cherry picked from commit 79baac8acfc60a7a5114f6d60731e28c242ef8ce] Signed-off-by: Jaehoon Chung Change-Id: Ia34af97505a9d0d0fce380a1393488a8d8a2499a --- diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 4b3ff7687236..d2a32c4f04aa 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -355,7 +355,7 @@ static void perf_top__print_sym_table(struct perf_top *top) static void prompt_integer(int *target, const char *msg) { - char *buf = malloc(0), *p; + char *buf = NULL, *p; size_t dummy = 0; int tmp;