Skip to content

Commit 5241874

Browse files
james-c-linaromehmetb0
authored andcommitted
perf: Always feature test reallocarray
BugLink: https://bugs.launchpad.net/bugs/2107212 [ Upstream commit 4c4c072 ] This is also used in util/comm.c now, so instead of selectively doing the feature test, always do it. If it's ever used anywhere else it's less likely to cause another build failure. This doesn't remove the need to manually include libc_compat.h, and missing that will still cause an error for glibc < 2.26. There isn't a way to fix that without poisoning reallocarray like libbpf did, but that has other downsides like making memory debugging tools less useful. So for Perf keep it like this and we'll have to fix up any missed includes. Fixes the following build error: util/comm.c:152:31: error: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration] 152 | tmp = reallocarray(comm_strs->strs, | ^~~~~~~~~~~~ Fixes: 13ca628 ("perf comm: Add reference count checking to 'struct comm_str'") Reported-by: Ali Utku Selen <[email protected]> Signed-off-by: James Clark <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Timo Aaltonen <[email protected]>
1 parent 2e01795 commit 5241874

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tools/perf/Makefile.config

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,14 @@ ifeq ($(feature-setns), 1)
497497
$(call detected,CONFIG_SETNS)
498498
endif
499499

500+
ifeq ($(feature-reallocarray), 0)
501+
CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
502+
endif
503+
500504
ifdef CORESIGHT
501505
$(call feature_check,libopencsd)
502506
ifeq ($(feature-libopencsd), 1)
503507
CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS)
504-
ifeq ($(feature-reallocarray), 0)
505-
CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
506-
endif
507508
LDFLAGS += $(LIBOPENCSD_LDFLAGS)
508509
EXTLIBS += $(OPENCSDLIBS)
509510
$(call detected,CONFIG_LIBOPENCSD)
@@ -1110,9 +1111,6 @@ ifndef NO_AUXTRACE
11101111
ifndef NO_AUXTRACE
11111112
$(call detected,CONFIG_AUXTRACE)
11121113
CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1113-
ifeq ($(feature-reallocarray), 0)
1114-
CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
1115-
endif
11161114
endif
11171115
endif
11181116

tools/perf/util/comm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <internal/rc_check.h>
66
#include <linux/refcount.h>
77
#include <linux/zalloc.h>
8+
#include <tools/libc_compat.h> // reallocarray
9+
810
#include "rwsem.h"
911

1012
DECLARE_RC_STRUCT(comm_str) {

0 commit comments

Comments
 (0)