[PATCH] selftests/bpf: Simplify the calculation of variables

Subsystems: bpf [general] (safe dynamic programs and tools), bpf [selftests] (test runners & infrastructure), kernel selftest framework, the rest, xdp (express data path)

STALE2025d

2 messages, 2 authors, 2021-02-09 · open the first message on its own page

[PATCH] selftests/bpf: Simplify the calculation of variables

From: Jiapeng Chong <hidden>
Date: 2021-02-05 06:29:00

Fix the following coccicheck warnings:

./tools/testing/selftests/bpf/xdpxceiver.c:954:28-30: WARNING !A || A &&
B is equivalent to !A || B.

./tools/testing/selftests/bpf/xdpxceiver.c:932:28-30: WARNING !A || A &&
B is equivalent to !A || B.

./tools/testing/selftests/bpf/xdpxceiver.c:909:28-30: WARNING !A || A &&
B is equivalent to !A || B.

Reported-by: Abaci Robot <redacted>
Signed-off-by: Jiapeng Chong <redacted>
---
 tools/testing/selftests/bpf/xdpxceiver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
index 1e722ee..98ad4a2 100644
--- a/tools/testing/selftests/bpf/xdpxceiver.c
+++ b/tools/testing/selftests/bpf/xdpxceiver.c
@@ -906,7 +906,7 @@ static void *worker_testapp_validate(void *arg)
 			ksft_print_msg("Destroying socket\n");
 	}
 
-	if (!opt_bidi || (opt_bidi && bidi_pass)) {
+	if (!opt_bidi || bidi_pass) {
 		xsk_socket__delete(((struct ifobject *)arg)->xsk->xsk);
 		(void)xsk_umem__delete(((struct ifobject *)arg)->umem->umem);
 	}
@@ -929,7 +929,7 @@ static void testapp_validate(void)
 	pthread_mutex_lock(&sync_mutex);
 
 	/*Spawn RX thread */
-	if (!opt_bidi || (opt_bidi && !bidi_pass)) {
+	if (!opt_bidi || !bidi_pass) {
 		if (pthread_create(&t0, &attr, worker_testapp_validate, (void *)ifdict[1]))
 			exit_with_error(errno);
 	} else if (opt_bidi && bidi_pass) {
@@ -951,7 +951,7 @@ static void testapp_validate(void)
 	pthread_mutex_unlock(&sync_mutex);
 
 	/*Spawn TX thread */
-	if (!opt_bidi || (opt_bidi && !bidi_pass)) {
+	if (!opt_bidi || !bidi_pass) {
 		if (pthread_create(&t1, &attr, worker_testapp_validate, (void *)ifdict[0]))
 			exit_with_error(errno);
 	} else if (opt_bidi && bidi_pass) {
-- 
1.8.3.1

Re: [PATCH] selftests/bpf: Simplify the calculation of variables

From: Andrii Nakryiko <hidden>
Date: 2021-02-09 05:21:59

On Thu, Feb 4, 2021 at 10:27 PM Jiapeng Chong
[off-list ref] wrote:
Fix the following coccicheck warnings:

./tools/testing/selftests/bpf/xdpxceiver.c:954:28-30: WARNING !A || A &&
B is equivalent to !A || B.

./tools/testing/selftests/bpf/xdpxceiver.c:932:28-30: WARNING !A || A &&
B is equivalent to !A || B.

./tools/testing/selftests/bpf/xdpxceiver.c:909:28-30: WARNING !A || A &&
B is equivalent to !A || B.

Reported-by: Abaci Robot <redacted>
Signed-off-by: Jiapeng Chong <redacted>
---
This doesn't apply cleanly onto bpf-next anymore. Please rebase and
re-submit. Make sure to include [PATCH bpf-next] prefix in your email
subject. Thanks!
quoted hunk
 tools/testing/selftests/bpf/xdpxceiver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
index 1e722ee..98ad4a2 100644
--- a/tools/testing/selftests/bpf/xdpxceiver.c
+++ b/tools/testing/selftests/bpf/xdpxceiver.c
@@ -906,7 +906,7 @@ static void *worker_testapp_validate(void *arg)
                        ksft_print_msg("Destroying socket\n");
        }

-       if (!opt_bidi || (opt_bidi && bidi_pass)) {
+       if (!opt_bidi || bidi_pass) {
                xsk_socket__delete(((struct ifobject *)arg)->xsk->xsk);
                (void)xsk_umem__delete(((struct ifobject *)arg)->umem->umem);
        }
@@ -929,7 +929,7 @@ static void testapp_validate(void)
        pthread_mutex_lock(&sync_mutex);

        /*Spawn RX thread */
-       if (!opt_bidi || (opt_bidi && !bidi_pass)) {
+       if (!opt_bidi || !bidi_pass) {
                if (pthread_create(&t0, &attr, worker_testapp_validate, (void *)ifdict[1]))
                        exit_with_error(errno);
        } else if (opt_bidi && bidi_pass) {
@@ -951,7 +951,7 @@ static void testapp_validate(void)
        pthread_mutex_unlock(&sync_mutex);

        /*Spawn TX thread */
-       if (!opt_bidi || (opt_bidi && !bidi_pass)) {
+       if (!opt_bidi || !bidi_pass) {
                if (pthread_create(&t1, &attr, worker_testapp_validate, (void *)ifdict[0]))
                        exit_with_error(errno);
        } else if (opt_bidi && bidi_pass) {
--
1.8.3.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help