diff mbox series

[net-next] tools: lib: bpf: libbpf: fix max() type mistmatch for 32bit

Message ID 20190625141142.2378-1-ivan.khoronzhuk@linaro.org
State Superseded
Headers show
Series [net-next] tools: lib: bpf: libbpf: fix max() type mistmatch for 32bit | expand

Commit Message

Ivan Khoronzhuk June 25, 2019, 2:11 p.m. UTC
It fixes build error for 32bit coused by type mistmatch
size_t/unsigned long.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

---

Based on net-next/master

 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.17.1

Comments

Andrii Nakryiko June 25, 2019, 5:45 p.m. UTC | #1
On Tue, Jun 25, 2019 at 7:12 AM Ivan Khoronzhuk
<ivan.khoronzhuk@linaro.org> wrote:
>

> It fixes build error for 32bit coused by type mistmatch


typo: coused -> caused, mistmatch -> mismatch

> size_t/unsigned long.

>

> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

> ---

>

> Based on net-next/master


libbpf changes should be based against bpf-next. Indicate that also
with [PATCH bpf-next] subject prefix.

Also, there is no need to have this long "tools: lib: bpf: libbpf:"
prefix, it's not supposed to be a repeat of file path. Use just
"libbpf: " to indicate it's libbpf-related changes.


>

>  tools/lib/bpf/libbpf.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c

> index 4259c9f0cfe7..d03016a559e2 100644

> --- a/tools/lib/bpf/libbpf.c

> +++ b/tools/lib/bpf/libbpf.c

> @@ -778,7 +778,7 @@ static struct bpf_map *bpf_object__add_map(struct bpf_object *obj)

>         if (obj->nr_maps < obj->maps_cap)

>                 return &obj->maps[obj->nr_maps++];

>

> -       new_cap = max(4ul, obj->maps_cap * 3 / 2);

> +       new_cap = max((size_t)4, obj->maps_cap * 3 / 2);


The fix itself works, thanks!

>         new_maps = realloc(obj->maps, new_cap * sizeof(*obj->maps));

>         if (!new_maps) {

>                 pr_warning("alloc maps for object failed\n");

> --

> 2.17.1

>
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 4259c9f0cfe7..d03016a559e2 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -778,7 +778,7 @@  static struct bpf_map *bpf_object__add_map(struct bpf_object *obj)
 	if (obj->nr_maps < obj->maps_cap)
 		return &obj->maps[obj->nr_maps++];
 
-	new_cap = max(4ul, obj->maps_cap * 3 / 2);
+	new_cap = max((size_t)4, obj->maps_cap * 3 / 2);
 	new_maps = realloc(obj->maps, new_cap * sizeof(*obj->maps));
 	if (!new_maps) {
 		pr_warning("alloc maps for object failed\n");