From 96aaf1598a9907b4e67d9f45637985662099f899 Mon Sep 17 00:00:00 2001 From: Rong Tao <32674962+Rtoax@users.noreply.github.com> Date: Sun, 9 Jan 2022 03:36:00 +0800 Subject: [PATCH] reallocarray: eliminate compilation warnings (#3798) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit there are compile warnings below for klockstat. ```bash CC klockstat.o klockstat.c: In function ‘print_stats’: klockstat.c:396:12: warning: implicit declaration of function ‘reallocarray’; did you mean ‘realloc’? [-Wimplicit-function-declaration] stats = reallocarray(stats, stats_sz, sizeof(void *)); ^~~~~~~~~~~~ realloc klockstat.c:396:10: warning: assignment to ‘struct stack_stat **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] stats = reallocarray(stats, stats_sz, sizeof(void *)); ^ BINARY klockstat ``` Defining _GNU_SOURCE fixed the problem. --- libbpf-tools/klockstat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libbpf-tools/klockstat.c b/libbpf-tools/klockstat.c index f16b760e..55b4fcf5 100644 --- a/libbpf-tools/klockstat.c +++ b/libbpf-tools/klockstat.c @@ -14,6 +14,9 @@ #include #include #include +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include #include #include -- 2.34.1