[V2,14/15] ARM: bpf: cleanup cppcheck shifting error
diff mbox series

Message ID 20190624135105.15579-15-tranmanphong@gmail.com
State New
Headers show
Series
  • cleanup cppcheck signed shifting errors
Related show

Commit Message

Phong Tran June 24, 2019, 1:51 p.m. UTC
[arch/arm/net/bpf_jit_32.c:618]: (error) Shifting signed 32-bit value by
31 bits is undefined behaviour

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
---
 arch/arm/net/bpf_jit_32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Russell King - ARM Linux admin June 24, 2019, 2 p.m. UTC | #1
On Mon, Jun 24, 2019 at 08:51:04PM +0700, Phong Tran wrote:
> [arch/arm/net/bpf_jit_32.c:618]: (error) Shifting signed 32-bit value by
> 31 bits is undefined behaviour
> 
> Signed-off-by: Phong Tran <tranmanphong@gmail.com>
> ---
>  arch/arm/net/bpf_jit_32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
> index adff54c312bf..4e8ad26305ca 100644
> --- a/arch/arm/net/bpf_jit_32.c
> +++ b/arch/arm/net/bpf_jit_32.c
> @@ -612,7 +612,7 @@ static inline void emit_a32_mov_se_i64(const bool is64, const s8 dst[],
>  				       const u32 val, struct jit_ctx *ctx) {
>  	u64 val64 = val;
>  
> -	if (is64 && (val & (1<<31)))
> +	if (is64 && (val & (BIT(31))))

Extra parens are not necessary, please remove.

>  		val64 |= 0xffffffff00000000ULL;
>  	emit_a32_mov_i64(dst, val64, ctx);
>  }
> -- 
> 2.11.0
> 
>

Patch
diff mbox series

diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index adff54c312bf..4e8ad26305ca 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/arch/arm/net/bpf_jit_32.c
@@ -612,7 +612,7 @@  static inline void emit_a32_mov_se_i64(const bool is64, const s8 dst[],
 				       const u32 val, struct jit_ctx *ctx) {
 	u64 val64 = val;
 
-	if (is64 && (val & (1<<31)))
+	if (is64 && (val & (BIT(31))))
 		val64 |= 0xffffffff00000000ULL;
 	emit_a32_mov_i64(dst, val64, ctx);
 }