07dbbc65b9f20ce0e58f96900033b34aa3790cd1
[openwrt/openwrt.git] / package / network / utils / iproute2 / patches / 185-libbpf-add-limits-h.patch
1 From c77310119f9a5f99221dd967c5eb0c7a26094b41 Mon Sep 17 00:00:00 2001
2 From: Tony Ambardar <Tony.Ambardar@gmail.com>
3 Date: Wed, 3 Mar 2021 10:29:24 -0800
4 Subject: [PATCH] lib/bpf: add missing limits.h includes
5
6 Several functions in bpf_glue.c and bpf_libbpf.c rely on PATH_MAX, which is
7 normally included from <limits.h> in other iproute2 source files.
8
9 It fixes errors seen using gcc 10.2.0, binutils 2.35.1 and musl 1.1.24:
10
11 bpf_glue.c: In function 'get_libbpf_version':
12 bpf_glue.c:46:11: error: 'PATH_MAX' undeclared (first use in this function);
13 did you mean 'AF_MAX'?
14 46 | char buf[PATH_MAX], *s;
15 | ^~~~~~~~
16 | AF_MAX
17
18 Reported-by: Rui Salvaterra <rsalvaterra@gmail.com>
19 Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
20 ---
21 lib/bpf_glue.c | 2 ++
22 lib/bpf_libbpf.c | 1 +
23 2 files changed, 3 insertions(+)
24
25 --- a/lib/bpf_glue.c
26 +++ b/lib/bpf_glue.c
27 @@ -4,6 +4,8 @@
28 * Authors: Hangbin Liu <haliu@redhat.com>
29 *
30 */
31 +#include <limits.h>
32 +
33 #include "bpf_util.h"
34 #ifdef HAVE_LIBBPF
35 #include <bpf/bpf.h>
36 --- a/lib/bpf_libbpf.c
37 +++ b/lib/bpf_libbpf.c
38 @@ -13,6 +13,7 @@
39 #include <stdint.h>
40 #include <errno.h>
41 #include <fcntl.h>
42 +#include <limits.h>
43
44 #include <libelf.h>
45 #include <gelf.h>