perf jevents: Fix getting maximum number of fds
authorFelix Fietkau <nbd@nbd.name>
Tue, 25 May 2021 16:07:58 +0000 (18:07 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 26 May 2021 13:49:28 +0000 (10:49 -0300)
commit75ea44e356b5de8c817f821c9dd68ae329e82add
tree76651eb16926c90a6a61f9444f4130860ae540b8
parenta050a6d2b7e80ca52b2f4141eaf3420d201b72b3
perf jevents: Fix getting maximum number of fds

On some hosts, rlim.rlim_max can be returned as RLIM_INFINITY.
By casting it to int, it is interpreted as -1, which will cause get_maxfds
to return 0, causing "Invalid argument" errors in nftw() calls.
Fix this by casting the second argument of min() to rlim_t instead.

Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lore.kernel.org/lkml/20210525160758.97829-1-nbd@nbd.name
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/pmu-events/jevents.c