diff mbox series

[bpf-next] libbpf: Use PRIu64 when printing ulimit value

Message ID 20191218112840.871338-1-toke@redhat.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] libbpf: Use PRIu64 when printing ulimit value | expand

Commit Message

Toke Høiland-Jørgensen Dec. 18, 2019, 11:28 a.m. UTC
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 the PRIu64 definition in printf.

Fixes: dc3a2d254782 ("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>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexei Starovoitov Dec. 18, 2019, 3:37 p.m. UTC | #1
On Wed, Dec 18, 2019 at 3:28 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> 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 the PRIu64 definition in printf.
>
> Fixes: dc3a2d254782 ("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>
> ---
>  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 3fe42d6b0c2f..ba31083998ce 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -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), "%"PRIu64" bytes", limit.rlim_cur);

please use %zu and (size_t) cast like the rest of libbpf.
Thanks!
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 3fe42d6b0c2f..ba31083998ce 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -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), "%"PRIu64" bytes", limit.rlim_cur);
 	else if (limit.rlim_cur < 1024*1024)
 		snprintf(buf, sizeof(buf), "%.1f KiB", (double)limit.rlim_cur / 1024);
 	else