Skip to contentSkip to conversation

bpf: delete meaningless code

PATCH In review Min Hu (Connor) 2 participants 5 messages Apr 21, 2021 – Apr 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: delete meaningless code

'rd->u.max = rd->u.max' is meaningless which should be deleted.

This patch fixed it.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")
---
 lib/librte_bpf/bpf_validate.c | 2 --
 1 file changed, 2 deletions(-)
lib/librte_bpf/bpf_validate.c +0 -2
index 9214f15..c5ad951 100644
@@ -517,8 +517,6 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs,
 	} else {
 		if (op == BPF_MOD)
 			rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1);
-		else
-			rd->u.max = rd->u.max;
 		rd->u.min = 0;
 	}
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines

'rd->u.max = rd->u.max' is meaningless which should be deleted.

This patch fixed it.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")

As I remember, I did it on purpose.
Some old (but still supported) version of clang complained about unitialized variable.

Quoted 20 lines
---
 lib/librte_bpf/bpf_validate.c | 2 --
 1 file changed, 2 deletions(-)
lib/librte_bpf/bpf_validate.c +0 -3
index 9214f15..c5ad951 100644
@@ -517,8 +517,6 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs,
 	} else {
 		if (op == BPF_MOD)
 			rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1);
-		else
-			rd->u.max = rd->u.max;
 		rd->u.min = 0;
 	}
 
--

2.7.4

#2 lore raw
Quoted 11 lines · Konstantin
Quoted 7 lines

'rd->u.max = rd->u.max' is meaningless which should be deleted.

This patch fixed it.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")

As I remember, I did it on purpose.
Some old (but still supported) version of clang complained about unitialized variable.

Well, how about like this ?

		uint64_t tmp = rd->u.max;
		if (op == BPF_MOD)
			tmp = RTE_MIN(tmp, tmp - 1);
		rd->u.max = tmp;
Quoted 24 lines
Quoted 20 lines
---
  lib/librte_bpf/bpf_validate.c | 2 --
  1 file changed, 2 deletions(-)
lib/librte_bpf/bpf_validate.c +0 -3
index 9214f15..c5ad951 100644
@@ -517,8 +517,6 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs,
  	} else {
  		if (op == BPF_MOD)
  			rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1);
-		else
-			rd->u.max = rd->u.max;
  		rd->u.min = 0;
  	}
 
--
Quoted 1 line

2.7.4

.

#3 lore raw
Quoted 16 lines · Konstantin
Quoted 11 lines
Quoted 7 lines

'rd->u.max = rd->u.max' is meaningless which should be deleted.

This patch fixed it.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")

As I remember, I did it on purpose.
Some old (but still supported) version of clang complained about unitialized variable.

Quoted 5 lines

Well, how about like this ?

		uint64_t tmp = rd->u.max;
		if (op == BPF_MOD)
			tmp = RTE_MIN(tmp, tmp - 1);
		rd->u.max = tmp;

Then, I think it should be:
tmp = RTE_MIN(tmp, rs->u.max - 1);

Or just leave things as they are right now.
Nothing is broken here.

Quoted 24 lines
Quoted 24 lines
Quoted 20 lines
---
  lib/librte_bpf/bpf_validate.c | 2 --
  1 file changed, 2 deletions(-)
lib/librte_bpf/bpf_validate.c +0 -3
index 9214f15..c5ad951 100644
@@ -517,8 +517,6 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs,
  	} else {
  		if (op == BPF_MOD)
  			rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1);
-		else
-			rd->u.max = rd->u.max;
  		rd->u.min = 0;
  	}
 
--
Quoted 1 line

2.7.4

.

#4 lore raw
Quoted 23 lines · Konstantin
Quoted 16 lines · Konstantin
Quoted 11 lines
Quoted 7 lines

'rd->u.max = rd->u.max' is meaningless which should be deleted.

This patch fixed it.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")

As I remember, I did it on purpose.
Some old (but still supported) version of clang complained about unitialized variable.

Quoted 5 lines

Well, how about like this ?

		uint64_t tmp = rd->u.max;
		if (op == BPF_MOD)
			tmp = RTE_MIN(tmp, tmp - 1);
		rd->u.max = tmp;
Quoted 6 lines

Then, I think it should be:
tmp = RTE_MIN(tmp, rs->u.max - 1);

Or just leave things as they are right now.
Nothing is broken here.

OK, this patch can be abandoned ,thanks.

Quoted 26 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
   lib/librte_bpf/bpf_validate.c | 2 --
   1 file changed, 2 deletions(-)
lib/librte_bpf/bpf_validate.c +0 -2
index 9214f15..c5ad951 100644
@@ -517,8 +517,6 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs,
   	} else {
   		if (op == BPF_MOD)
   			rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1);
-		else
-			rd->u.max = rd->u.max;
   		rd->u.min = 0;
   	}
 
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

--
2.7.4

.

.