linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Stefan Wahren <stefan.wahren@i2se.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>
Cc: linux-staging@lists.linux.dev, Stefan Wahren <stefan.wahren@i2se.com>
Subject: [PATCH 10/16] staging: vchiq_core: simplify WARN_ON conditions
Date: Thu,  3 Jun 2021 17:49:59 +0200	[thread overview]
Message-ID: <1622735405-9980-11-git-send-email-stefan.wahren@i2se.com> (raw)
In-Reply-To: <1622735405-9980-1-git-send-email-stefan.wahren@i2se.com>

During a recent review Dan Carpenter noticed a double negation in a WARN_ON.
But a quick search revealed more unnecessary complex WARN_ON conditions.
This change should simplify them.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 99624ca..2e1b218 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -924,7 +924,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
 
 	stride = calc_stride(size);
 
-	WARN_ON(!(stride <= VCHIQ_SLOT_SIZE));
+	WARN_ON(stride > VCHIQ_SLOT_SIZE);
 
 	if (!(flags & QMFLAGS_NO_MUTEX_LOCK) &&
 	    mutex_lock_killable(&state->slot_mutex))
@@ -1480,8 +1480,8 @@ abort_outstanding_bulks(struct vchiq_service *service,
 		service->state->id, service->localport, is_tx ? 't' : 'r',
 		queue->local_insert, queue->remote_insert, queue->process);
 
-	WARN_ON(!((int)(queue->local_insert - queue->process) >= 0));
-	WARN_ON(!((int)(queue->remote_insert - queue->process) >= 0));
+	WARN_ON((int)(queue->local_insert - queue->process) < 0);
+	WARN_ON((int)(queue->remote_insert - queue->process) < 0);
 
 	while ((queue->process != queue->local_insert) ||
 		(queue->process != queue->remote_insert)) {
@@ -1729,7 +1729,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
 
 	switch (type) {
 	case VCHIQ_MSG_OPEN:
-		WARN_ON(!(VCHIQ_MSG_DSTPORT(msgid) == 0));
+		WARN_ON(VCHIQ_MSG_DSTPORT(msgid));
 		if (!parse_open(state, header))
 			goto bail_not_ready;
 		break;
@@ -1756,7 +1756,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header)
 		}
 		break;
 	case VCHIQ_MSG_CLOSE:
-		WARN_ON(size != 0); /* There should be no data */
+		WARN_ON(size); /* There should be no data */
 
 		vchiq_log_info(vchiq_core_log_level,
 			"%d: prs CLOSE@%pK (%d->%d)",
@@ -1958,7 +1958,7 @@ parse_rx_slots(struct vchiq_state *state)
 		if (!state->rx_data) {
 			int rx_index;
 
-			WARN_ON(!((state->rx_pos & VCHIQ_SLOT_MASK) == 0));
+			WARN_ON(state->rx_pos & VCHIQ_SLOT_MASK);
 			rx_index = remote->slot_queue[
 				SLOT_QUEUE_INDEX_FROM_POS_MASKED(state->rx_pos)];
 			state->rx_data = (char *)SLOT_DATA_FROM_INDEX(state,
-- 
2.7.4


  parent reply	other threads:[~2021-06-03 15:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 15:49 [PATCH 00/16] staging: vchiq_arm: code clean-up part 3 Stefan Wahren
2021-06-03 15:49 ` [PATCH 01/16] staging: vchiq_core: fix logic in poll_services_of_group Stefan Wahren
2021-06-03 15:49 ` [PATCH 02/16] staging: vchiq_arm: introduce free_bulk_waiter Stefan Wahren
2021-06-03 15:49 ` [PATCH 03/16] staging: vchiq_core: move internals to C source Stefan Wahren
2021-06-03 15:49 ` [PATCH 04/16] staging: vchiq_core: get the rid of IS_POW2 Stefan Wahren
2021-06-03 15:49 ` [PATCH 05/16] staging: vchiq_core: get the rid of vchiq_static_assert Stefan Wahren
2021-06-03 15:49 ` [PATCH 06/16] staging: vchiq_core: put spaces around operators Stefan Wahren
2021-06-03 15:49 ` [PATCH 07/16] staging: vchiq_core: avoid precedence issues Stefan Wahren
2021-06-03 15:49 ` [PATCH 08/16] staging: vchiq_core: use define for message type shift Stefan Wahren
2021-06-03 15:49 ` [PATCH 09/16] staging: vchiq_core: introduce message specific make macros Stefan Wahren
2021-06-03 15:49 ` Stefan Wahren [this message]
2021-06-03 15:50 ` [PATCH 11/16] staging: vchiq_arm: tidy up service function naming Stefan Wahren
2021-06-03 15:50 ` [PATCH 12/16] staging: vchiq_core: introduce process_free_data_message Stefan Wahren
2021-06-03 15:50 ` [PATCH 13/16] staging: vchiq_core: reduce indentation in parse_open Stefan Wahren
2021-06-03 15:50 ` [PATCH 14/16] staging: vchiq_core: store message id in local variable Stefan Wahren
2021-06-03 15:50 ` [PATCH 15/16] staging: vchiq_connected: move EXPORT_SYMBOL below the right function Stefan Wahren
2021-06-03 15:50 ` [PATCH 16/16] staging: vchiq_core: introduce handle_poll Stefan Wahren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1622735405-9980-11-git-send-email-stefan.wahren@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=nsaenz@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).