Skip to content

Commit

Permalink
libbpf: Fix printing of ulimit value
Browse files Browse the repository at this point in the history
Naresh pointed out that libbpf builds fail on 32-bit architectures because
rlimit.rlim_cur is defined as 'unsigned long long' on those architectures.
Fix this by using %zu in printf and casting to size_t.

Fixes: dc3a2d2 ("libbpf: Print hint about ulimit when getting permission denied error")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191219090236.905059-1-toke@redhat.com
  • Loading branch information
Toke Høiland-Jørgensen authored and Daniel Borkmann committed Dec 19, 2019
1 parent 580205d commit b5c7d0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void pr_perm_msg(int err)
return;

if (limit.rlim_cur < 1024)
snprintf(buf, sizeof(buf), "%lu bytes", limit.rlim_cur);
snprintf(buf, sizeof(buf), "%zu bytes", (size_t)limit.rlim_cur);
else if (limit.rlim_cur < 1024*1024)
snprintf(buf, sizeof(buf), "%.1f KiB", (double)limit.rlim_cur / 1024);
else
Expand Down

0 comments on commit b5c7d0d

Please sign in to comment.