All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tools/perf: Fix malloc call for new -Walloc-size
@ 2023-12-04  8:20 Yanteng Si
  2024-01-26 14:31 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Yanteng Si @ 2023-12-04  8:20 UTC (permalink / raw)
  To: peterz, mingo, acme
  Cc: alexander.shishkin, jolsa, mark.rutland, namhyung, adrian.hunter,
	linux-perf-users, Sun Haiyong, Yanteng Si

From: Sun Haiyong <sunhaiyong@loongson.cn>

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;
      |                     ^~~~~~

```

So, just set it to NULL, silence this error.

Signed-off-by: Sun Haiyong <sunhaiyong@loongson.cn>
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
v2:

* Refer to Namhyung's comment and set it to NULL.

 tools/perf/builtin-top.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
 
-- 
2.31.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-26 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04  8:20 [PATCH v2] tools/perf: Fix malloc call for new -Walloc-size Yanteng Si
2024-01-26 14:31 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.