All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Netdev <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Yonghong Song <yhs@fb.com>,
	lkft-triage@lists.linaro.org, Leo Yan <leo.yan@linaro.org>,
	Daniel Diaz <daniel.diaz@linaro.org>
Subject: Re: [PATCH bpf-next v2] libbpf: Print hint about ulimit when getting permission denied error
Date: Wed, 18 Dec 2019 12:08:34 +0100	[thread overview]
Message-ID: <878sn97ux9.fsf@toke.dk> (raw)
In-Reply-To: <CA+G9fYssgDcBkiNGSV7BmjE4Tj1j1_fa4VTJFv3N=2FHzewQLg@mail.gmail.com>

Naresh Kamboju <naresh.kamboju@linaro.org> writes:

> On Tue, 17 Dec 2019 at 00:00, Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>> index a2cc7313763a..3fe42d6b0c2f 100644
>> --- a/tools/lib/bpf/libbpf.c
>> +++ b/tools/lib/bpf/libbpf.c
>> @@ -41,6 +41,7 @@
>>  #include <sys/types.h>
>>  #include <sys/vfs.h>
>>  #include <sys/utsname.h>
>> +#include <sys/resource.h>
>>  #include <tools/libc_compat.h>
>>  #include <libelf.h>
>>  #include <gelf.h>
>> @@ -100,6 +101,32 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...)
>>         va_end(args);
>>  }
>>
>> +static void pr_perm_msg(int err)
>> +{
>> +       struct rlimit limit;
>> +       char buf[100];
>> +
>> +       if (err != -EPERM || geteuid() != 0)
>> +               return;
>> +
>> +       err = getrlimit(RLIMIT_MEMLOCK, &limit);
>> +       if (err)
>> +               return;
>> +
>> +       if (limit.rlim_cur == RLIM_INFINITY)
>> +               return;
>> +
>> +       if (limit.rlim_cur < 1024)
>> +               snprintf(buf, sizeof(buf), "%lu bytes", limit.rlim_cur);
>
>  libbpf.c: In function 'pr_perm_msg':
>  libbpf.c:120:33: error: format '%lu' expects argument of type 'long
> unsigned int', but argument 4 has type 'rlim_t {aka long long unsigned
> int}' [-Werror=format=]
>     snprintf(buf, sizeof(buf), "%lu bytes", limit.rlim_cur);
>                                 ~~^         ~~~~~~~~~~~~~~
>                                 %llu
>

Ah, guess this needs PRIu64. Will send a follow-up, thanks for the
report :)

-Toke


      reply	other threads:[~2019-12-18 11:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 18:12 [PATCH bpf-next v2] libbpf: Print hint about ulimit when getting permission denied error Toke Høiland-Jørgensen
2019-12-16 22:54 ` Alexei Starovoitov
2019-12-18 10:47 ` Naresh Kamboju
2019-12-18 11:08   ` Toke Høiland-Jørgensen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sn97ux9.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel.diaz@linaro.org \
    --cc=daniel@iogearbox.net \
    --cc=leo.yan@linaro.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.