Re: [PATCH bpf-next] libbpf: fix printf compilation warnings on ppc64le arch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 11, 2019 at 11:26:34AM -0800, Andrii Nakryiko wrote:
> On ppc64le __u64 and __s64 are defined as long int and unsigned long int,
> respectively. This causes compiler to emit warning when %lld/%llu are used to
> printf 64-bit numbers. Fix this by casting directly to unsigned long long
> (through shorter typedef). In few cases casting error code to int explicitly
> is cleaner, so that's what's done instead.
> 
> Fixes: 1f8e2bcb2cd5 ("libbpf: Refactor relocation handling")
> Fixes: abd29c931459 ("libbpf: allow specifying map definitions using BTF")
> Signed-off-by: Andrii Nakryiko <andriin@xxxxxx>
> ---
>  tools/lib/bpf/libbpf.c | 34 ++++++++++++++++++----------------
>  1 file changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 3f09772192f1..5ee54f9355a4 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -128,6 +128,8 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...)
>  # define LIBBPF_ELF_C_READ_MMAP ELF_C_READ
>  #endif
>  
> +typedef unsigned long long __pu64;
> +
>  static inline __u64 ptr_to_u64(const void *ptr)
>  {
>  	return (__u64) (unsigned long) ptr;
> @@ -1242,15 +1244,15 @@ static int bpf_object__init_user_btf_map(struct bpf_object *obj,
>  			}
>  			sz = btf__resolve_size(obj->btf, t->type);
>  			if (sz < 0) {
> -				pr_warn("map '%s': can't determine key size for type [%u]: %lld.\n",
> -					map_name, t->type, sz);
> +				pr_warn("map '%s': can't determine key size for type [%u]: %d.\n",
> +					map_name, t->type, (int)sz);
>  				return sz;
>  			}
> -			pr_debug("map '%s': found key [%u], sz = %lld.\n",
> -				 map_name, t->type, sz);
> +			pr_debug("map '%s': found key [%u], sz = %d.\n",
> +				 map_name, t->type, (int)sz);
>  			if (map->def.key_size && map->def.key_size != sz) {
> -				pr_warn("map '%s': conflicting key size %u != %lld.\n",
> -					map_name, map->def.key_size, sz);
> +				pr_warn("map '%s': conflicting key size %u != %d.\n",
> +					map_name, map->def.key_size, (int)sz);
>  				return -EINVAL;
>  			}
>  			map->def.key_size = sz;
> @@ -1285,15 +1287,15 @@ static int bpf_object__init_user_btf_map(struct bpf_object *obj,
>  			}
>  			sz = btf__resolve_size(obj->btf, t->type);
>  			if (sz < 0) {
> -				pr_warn("map '%s': can't determine value size for type [%u]: %lld.\n",
> -					map_name, t->type, sz);
> +				pr_warn("map '%s': can't determine value size for type [%u]: %d.\n",
> +					map_name, t->type, (int)sz);
>  				return sz;
>  			}
> -			pr_debug("map '%s': found value [%u], sz = %lld.\n",
> -				 map_name, t->type, sz);
> +			pr_debug("map '%s': found value [%u], sz = %d.\n",
> +				 map_name, t->type, (int)sz);
>  			if (map->def.value_size && map->def.value_size != sz) {
> -				pr_warn("map '%s': conflicting value size %u != %lld.\n",
> -					map_name, map->def.value_size, sz);
> +				pr_warn("map '%s': conflicting value size %u != %d.\n",
> +					map_name, map->def.value_size, (int)sz);
It is not an error case (i.e. not sz < 0) here.
Same for the above pr_debug().




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux