Skip to contentSkip to conversation

bpf: btf: remove a couple conditions

PATCH In review Dan Carpenter 3 participants 8 messages Apr 27, 2018 – Apr 28, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 bpf: btf: remove a couple conditions

We know "err" is zero so we can remove these and pull the code in one indent level.

---
This applies to the BPF tree (linux-next)

kernel/bpf/btf.c +4 -6
index e631b6fd60d3..7cb0905f37c2 100644
@@ -1973,16 +1973,14 @@ static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size,
 	if (err)
 		goto errout;
 
-	if (!err && log->level && bpf_verifier_log_full(log)) {
+	if (log->level && bpf_verifier_log_full(log)) {
 		err = -ENOSPC;
 		goto errout;
 	}
 
-	if (!err) {
-		btf_verifier_env_free(env);
-		btf_get(btf);
-		return btf;
-	}
+	btf_verifier_env_free(env);
+	btf_get(btf);
+	return btf;
 
 errout:
 	btf_verifier_env_free(env);
Acked-by on v1 2/2
#1 lore raw
Quoted 4 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Thanks for the simplification!

Quoted 28 lines

---
This applies to the BPF tree (linux-next)

kernel/bpf/btf.c +4 -6
index e631b6fd60d3..7cb0905f37c2 100644
@@ -1973,16 +1973,14 @@ static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size,
 	if (err)
 		goto errout;
 
-	if (!err && log->level && bpf_verifier_log_full(log)) {
+	if (log->level && bpf_verifier_log_full(log)) {
 		err = -ENOSPC;
 		goto errout;
 	}
 
-	if (!err) {
-		btf_verifier_env_free(env);
-		btf_get(btf);
-		return btf;
-	}
+	btf_verifier_env_free(env);
+	btf_get(btf);
+	return btf;
 
 errout:
 	btf_verifier_env_free(env);
#2 lore raw
Quoted 8 lines · Martin KaFai Lau
Quoted 4 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Thanks for the simplification!

btw, it should be for bpf-next. Please tag the subject with bpf-next when you respin. Thanks!

Quoted 29 lines
Quoted 29 lines

---
This applies to the BPF tree (linux-next)

kernel/bpf/btf.c +4 -6
index e631b6fd60d3..7cb0905f37c2 100644
@@ -1973,16 +1973,14 @@ static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size,
 	if (err)
 		goto errout;
 
-	if (!err && log->level && bpf_verifier_log_full(log)) {
+	if (log->level && bpf_verifier_log_full(log)) {
 		err = -ENOSPC;
 		goto errout;
 	}
 
-	if (!err) {
-		btf_verifier_env_free(env);
-		btf_get(btf);
-		return btf;
-	}
+	btf_verifier_env_free(env);
+	btf_get(btf);
+	return btf;
 
 errout:
 	btf_verifier_env_free(env);
#3 lore raw
Quoted 5 lines · Martin KaFai Lau
Quoted 4 lines · Martin KaFai Lau
Quoted 3 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Thanks for the simplification!

btw, it should be for bpf-next. Please tag the subject with bpf-next when you respin. Thanks!

I'm working against linux-next. For networking, I have a separate tree which I use to figure out if it's in net or net-next. It's kind of a headache (but obviously networking is the largest subtree so it's required).

Is there an automated way to tie a Fixes tag from linux-next to a subtree?

regards,
dan carpenter

maintainer
#4 lore raw
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Martin KaFai Lau
Quoted 4 lines · Martin KaFai Lau
Quoted 3 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Thanks for the simplification!

btw, it should be for bpf-next. Please tag the subject with bpf-next when you respin. Thanks!

Dan, thanks a lot for your fixes! Please respin with addressing Martin's feedback when you get a chance.

Thanks,
Daniel

#5 lore raw
Quoted 8 lines · Daniel Borkmann
Quoted 7 lines · Dan Carpenter
Quoted 6 lines · Martin KaFai Lau
Quoted 5 lines · Martin KaFai Lau
Quoted 4 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

Thanks for the simplification!

btw, it should be for bpf-next. Please tag the subject with bpf-next when you respin. Thanks!

Dan, thanks a lot for your fixes! Please respin with addressing Martin's feedback when you get a chance.

My understanding is that he'd prefer we just ignore the static checker warning since it's a false positive. Should I instead initialize the size to zero or something just to silence it?

regards,
dan carpenter

#6 lore raw
Quoted 15 lines · Dan Carpenter
Quoted 14 lines · Daniel Borkmann
Quoted 12 lines · Dan Carpenter
Quoted 11 lines · Martin KaFai Lau
Quoted 8 lines · Martin KaFai Lau
Quoted 4 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Thanks for the simplification!

btw, it should be for bpf-next. Please tag the subject with bpf-next when you respin. Thanks!

Quoted 6 lines
Quoted 3 lines

Dan, thanks a lot for your fixes! Please respin with addressing Martin's feedback when you get a chance.

My understanding is that he'd prefer we just ignore the static checker warning since it's a false positive.

Right, I think patch 1 is not needed. I would prefer to use a comment in those cases.

Quoted 6 lines

Should I instead initialize the
size to zero or something just to silence it?

regards,
dan carpenter

#7 lore raw
Quoted 16 lines · Martin KaFai Lau
Quoted 15 lines · Dan Carpenter
Quoted 14 lines · Daniel Borkmann
Quoted 12 lines · Dan Carpenter
Quoted 11 lines · Martin KaFai Lau
Quoted 8 lines · Martin KaFai Lau
Quoted 4 lines · Dan Carpenter

We know "err" is zero so we can remove these and pull the code in one indent level.

Thanks for the simplification!

btw, it should be for bpf-next. Please tag the subject with bpf-next when you respin. Thanks!

Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

Dan, thanks a lot for your fixes! Please respin with addressing Martin's feedback when you get a chance.

My understanding is that he'd prefer we just ignore the static checker warning since it's a false positive.

Right, I think patch 1 is not needed. I would prefer to use a comment in those cases.

Quoted 2 lines

Should I instead initialize the
size to zero or something just to silence it?

After another thought, I think init size to zero is fine which is less intrusive.

Thanks!
Martin

Quoted 4 lines
Quoted 4 lines

regards,
dan carpenter