1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 25 May 2021 18:00:34 +0200
3 Subject: [PATCH] perf jevents: fix getting maximum number of fds
5 On some hosts, rlim.rlim_max can be returned as RLIM_INFINITY.
6 By casting it to int, it is interpreted as -1, which will cause get_maxfds
7 to return 0, causing "Invalid argument" errors in nftw() calls.
8 Fix this by casting the second argument of min() to rlim_t instead.
10 Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file")
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 --- a/tools/perf/pmu-events/jevents.c
15 +++ b/tools/perf/pmu-events/jevents.c
16 @@ -894,7 +894,7 @@ static int get_maxfds(void)
19 if (getrlimit(RLIMIT_NOFILE, &rlim) == 0)
20 - return min((int)rlim.rlim_max / 2, 512);
21 + return min(rlim.rlim_max / 2, (rlim_t)512);