libbpf: fix max() type mismatch for 32bit
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Wed, 26 Jun 2019 10:38:37 +0000 (13:38 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 26 Jun 2019 12:41:20 +0000 (14:41 +0200)
It fixes build error for 32bit caused by type mismatch
size_t/unsigned long.

Fixes: bf82927125dd ("libbpf: refactor map initialization")
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/libbpf.c

index 68f45a96769fe5759f618c4c6ee430f3b9530572..5186b7710430bacfdbd261e86a7352a7cf75f18f 100644 (file)
@@ -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");