bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: "Andrii Nakryiko" <andrii.nakryiko@gmail.com>,
	"Jakub Kicinski" <jakub.kicinski@netronome.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Andrii Nakryiko" <andriin@fb.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jiri Olsa" <jolsa@kernel.org>, "Martin KaFai Lau" <kafai@fb.com>,
	"Namhyung Kim" <namhyung@kernel.org>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	linux-perf-users@vger.kernel.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Quentin Monnet" <quentin.monnet@netronome.com>
Subject: Re: [PATCH] libbpf: Use PRIu64 for sym->st_value to fix build on 32-bit arches
Date: Wed, 27 Nov 2019 11:33:00 -0800	[thread overview]
Message-ID: <CAADnVQ+Hgqg0Pi0GRrRw-fwySbMiYVNwdgvTqOtRTRJPAnEhcQ@mail.gmail.com> (raw)
In-Reply-To: <20191127134553.GC22719@kernel.org>

On Wed, Nov 27, 2019 at 5:45 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Another fix I'm carrying in my perf/core branch,
>
> Regards,
>
> - Arnaldo
>
> commit 98bb09f90a0ae33125fabc8f41529345382f1498
> Author: Arnaldo Carvalho de Melo <acme@redhat.com>
> Date:   Wed Nov 27 09:26:54 2019 -0300
>
>     libbpf: Use PRIu64 for sym->st_value to fix build on 32-bit arches
>
>     The st_value field is a 64-bit value, so use PRIu64 to fix this error on
>     32-bit arches:
>
>       In file included from libbpf.c:52:
>       libbpf.c: In function 'bpf_program__record_reloc':
>       libbpf_internal.h:59:22: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'Elf64_Addr' {aka 'const long long unsigned int'} [-Werror=format=]
>         libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
>                             ^~~~~~~~~~
>       libbpf_internal.h:62:27: note: in expansion of macro '__pr'
>        #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
>                                  ^~~~
>       libbpf.c:1822:4: note: in expansion of macro 'pr_warn'
>           pr_warn("bad call relo offset: %lu\n", sym->st_value);
>           ^~~~~~~
>       libbpf.c:1822:37: note: format string is defined here
>           pr_warn("bad call relo offset: %lu\n", sym->st_value);
>                                          ~~^
>                                          %llu
>
>     Fixes: 1f8e2bcb2cd5 ("libbpf: Refactor relocation handling")
>     Cc: Alexei Starovoitov <ast@kernel.org>
>     Cc: Andrii Nakryiko <andriin@fb.com>
>     Link: https://lkml.kernel.org/n/tip-iabs1wq19c357bkk84p7blif@git.kernel.org
>     Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index b20f82e58989..6b0eae5c8a94 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -1819,7 +1819,7 @@ static int bpf_program__record_reloc(struct bpf_program *prog,
>                         return -LIBBPF_ERRNO__RELOC;
>                 }
>                 if (sym->st_value % 8) {
> -                       pr_warn("bad call relo offset: %lu\n", sym->st_value);
> +                       pr_warn("bad call relo offset: %" PRIu64 "\n", sym->st_value);

Looking at this more... I never liked this PRI stuff. It makes for
such unreadable code.
How about just typecasting st_value to (long) ?

  parent reply	other threads:[~2019-11-27 19:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 15:10 [PATCH] libbpf: Fix up generation of bpf_helper_defs.h Arnaldo Carvalho de Melo
2019-11-26 15:48 ` Arnaldo Carvalho de Melo
2019-11-26 16:38   ` Toke Høiland-Jørgensen
2019-11-26 18:34     ` Arnaldo Carvalho de Melo
2019-11-26 18:50       ` Toke Høiland-Jørgensen
2019-11-26 19:04         ` Arnaldo Carvalho de Melo
2019-11-26 22:05           ` Andrii Nakryiko
2019-11-26 22:10             ` Arnaldo Carvalho de Melo
2019-11-26 22:17               ` Arnaldo Carvalho de Melo
2019-11-26 22:38                 ` Andrii Nakryiko
2019-11-26 23:10                   ` Stanislav Fomichev
2019-11-26 23:52                     ` Jakub Kicinski
2019-11-27  1:39                       ` Arnaldo Carvalho de Melo
2019-11-27 13:45                         ` [PATCH] libbpf: Use PRIu64 for sym->st_value to fix build on 32-bit arches Arnaldo Carvalho de Melo
2019-11-27 16:39                           ` Alexei Starovoitov
2019-11-27 18:45                             ` Arnaldo Carvalho de Melo
2019-11-27 18:55                               ` Alexei Starovoitov
2019-11-27 19:39                                 ` Arnaldo Carvalho de Melo
2019-11-27 19:33                           ` Alexei Starovoitov [this message]
2019-12-03 13:50                           ` Naresh Kamboju
2019-12-03 14:41                             ` Arnaldo Carvalho de Melo
2019-11-28  0:31                         ` [PATCH] libbpf: Fix up generation of bpf_helper_defs.h Alexei Starovoitov
2019-11-28  0:51                           ` Arnaldo Carvalho de Melo
2019-11-28  0:59                             ` Alexei Starovoitov
2019-11-28  1:17                               ` Arnaldo Carvalho de Melo
2019-11-28  1:20                                 ` Alexei Starovoitov
2019-11-28  1:27                                   ` Arnaldo Carvalho de Melo
2019-11-28  1:52                                     ` Alexei Starovoitov
2019-11-26 16:53 ` Alexei Starovoitov
2019-11-26 18:30   ` Arnaldo Carvalho de Melo

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=CAADnVQ+Hgqg0Pi0GRrRw-fwySbMiYVNwdgvTqOtRTRJPAnEhcQ@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin.monnet@netronome.com \
    --cc=sdf@fomichev.me \
    --cc=toke@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).