[v2] lib/bpf: fix clang build warnings for aarch64

Message ID 20191115064754.57605-1-ruifeng.wang@arm.com (mailing list archive)
State Accepted, archived
Headers
Series [v2] lib/bpf: fix clang build warnings for aarch64 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed

Commit Message

Ruifeng Wang Nov. 15, 2019, 6:47 a.m. UTC
  Clang has different prototype for __builtin___clear_cache(). It requires
'char *' parameters while gcc requires 'void *'.

Clang version 8.0 was used.
Warning messages during build:
../lib/librte_bpf/bpf_jit_arm64.c:1438:26: warning: incompatible pointer
types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type
'char *' [-Wincompatible-pointer-types]
        __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
                                ^~~~~~~
../lib/librte_bpf/bpf_jit_arm64.c:1438:35: warning: incompatible pointer
types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type
'char *' [-Wincompatible-pointer-types]
        __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
                                         ^~~~~~~~~~~~~~~~~

Fixes: f3e516772464 ("bpf/arm: add prologue and epilogue")
Cc: jerinj@marvell.com

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
---
v2:
Update commit message for failure reason. (Jerin)

 lib/librte_bpf/bpf_jit_arm64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jerin Jacob Nov. 15, 2019, 7:14 a.m. UTC | #1
On Fri, Nov 15, 2019 at 12:18 PM Ruifeng Wang <ruifeng.wang@arm.com> wrote:
>
> Clang has different prototype for __builtin___clear_cache(). It requires
> 'char *' parameters while gcc requires 'void *'.
>
> Clang version 8.0 was used.
> Warning messages during build:
> ../lib/librte_bpf/bpf_jit_arm64.c:1438:26: warning: incompatible pointer
> types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type
> 'char *' [-Wincompatible-pointer-types]
>         __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
>                                 ^~~~~~~
> ../lib/librte_bpf/bpf_jit_arm64.c:1438:35: warning: incompatible pointer
> types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type
> 'char *' [-Wincompatible-pointer-types]
>         __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
>                                          ^~~~~~~~~~~~~~~~~
>
> Fixes: f3e516772464 ("bpf/arm: add prologue and epilogue")
> Cc: jerinj@marvell.com
>
> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Phil Yang <phil.yang@arm.com>
> Reviewed-by: Gavin Hu <gavin.hu@arm.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>



> ---
> v2:
> Update commit message for failure reason. (Jerin)
>
>  lib/librte_bpf/bpf_jit_arm64.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_bpf/bpf_jit_arm64.c b/lib/librte_bpf/bpf_jit_arm64.c
> index 8882fee67..a5a5d46f0 100644
> --- a/lib/librte_bpf/bpf_jit_arm64.c
> +++ b/lib/librte_bpf/bpf_jit_arm64.c
> @@ -1435,7 +1435,7 @@ bpf_jit_arm64(struct rte_bpf *bpf)
>         }
>
>         /* Flush the icache */
> -       __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
> +       __builtin___clear_cache((char *)ctx.ins, (char *)(ctx.ins + ctx.idx));
>
>         bpf->jit.func = (void *)ctx.ins;
>         bpf->jit.sz = size;
> --
> 2.17.1
>
  
Thomas Monjalon Nov. 20, 2019, 11:32 p.m. UTC | #2
15/11/2019 08:14, Jerin Jacob:
> On Fri, Nov 15, 2019 at 12:18 PM Ruifeng Wang <ruifeng.wang@arm.com> wrote:
> >
> > Clang has different prototype for __builtin___clear_cache(). It requires
> > 'char *' parameters while gcc requires 'void *'.
> >
> > Clang version 8.0 was used.
> > Warning messages during build:
> > ../lib/librte_bpf/bpf_jit_arm64.c:1438:26: warning: incompatible pointer
> > types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type
> > 'char *' [-Wincompatible-pointer-types]
> >         __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
> >                                 ^~~~~~~
> > ../lib/librte_bpf/bpf_jit_arm64.c:1438:35: warning: incompatible pointer
> > types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type
> > 'char *' [-Wincompatible-pointer-types]
> >         __builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
> >                                          ^~~~~~~~~~~~~~~~~
> >
> > Fixes: f3e516772464 ("bpf/arm: add prologue and epilogue")
> > Cc: jerinj@marvell.com
> >
> > Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > Reviewed-by: Phil Yang <phil.yang@arm.com>
> > Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> 
> Acked-by: Jerin Jacob <jerinj@marvell.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_bpf/bpf_jit_arm64.c b/lib/librte_bpf/bpf_jit_arm64.c
index 8882fee67..a5a5d46f0 100644
--- a/lib/librte_bpf/bpf_jit_arm64.c
+++ b/lib/librte_bpf/bpf_jit_arm64.c
@@ -1435,7 +1435,7 @@  bpf_jit_arm64(struct rte_bpf *bpf)
 	}
 
 	/* Flush the icache */
-	__builtin___clear_cache(ctx.ins, ctx.ins + ctx.idx);
+	__builtin___clear_cache((char *)ctx.ins, (char *)(ctx.ins + ctx.idx));
 
 	bpf->jit.func = (void *)ctx.ins;
 	bpf->jit.sz = size;