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/toolchain/20240610.172841~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=275733ff01f0b9a19103e5316009277d32e7eb8b;p=platform%2Fkernel%2Flinux-starfive.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. cherry-picked from commit 79baac8acfc60a7a5114f6d60731e28c242ef8ce Change-Id: I3065836e0e7c352eb7dd7a82b73d4392b8142221 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 --- diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index ea8c7eca5eee..3960c4d15eff 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -357,7 +357,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;