lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1448659575-13485-6-git-send-email-fabf@skynet.be>
Date:	Fri, 27 Nov 2015 22:26:10 +0100
From:	Fabian Frederick <fabf@...net.be>
To:	linux-kernel@...r.kernel.org
Cc:	Philipp Reisner <philipp.reisner@...bit.com>,
	Fabian Frederick <fabf@...net.be>,
	Lars Ellenberg <lars.ellenberg@...bit.com>,
	drbd-dev@...ts.linbit.com
Subject: [PATCH 05/21] drbd: rework is_valid_state()

Remove empty condition to avoid semantic warnings

Signed-off-by: Fabian Frederick <fabf@...net.be>
---
 drivers/block/drbd/drbd_state.c | 86 ++++++++++++++++++-----------------------
 1 file changed, 38 insertions(+), 48 deletions(-)

diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 5a7ef78..a7631a3 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -813,54 +813,44 @@ is_valid_state(struct drbd_device *device, union drbd_state ns)
 		}
 	}
 
-	if (rv <= 0)
-		/* already found a reason to abort */;
-	else if (ns.role == R_SECONDARY && device->open_cnt)
-		rv = SS_DEVICE_IN_USE;
-
-	else if (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.disk < D_UP_TO_DATE)
-		rv = SS_NO_UP_TO_DATE_DISK;
-
-	else if (fp >= FP_RESOURCE &&
-		 ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk >= D_UNKNOWN)
-		rv = SS_PRIMARY_NOP;
-
-	else if (ns.role == R_PRIMARY && ns.disk <= D_INCONSISTENT && ns.pdsk <= D_INCONSISTENT)
-		rv = SS_NO_UP_TO_DATE_DISK;
-
-	else if (ns.conn > C_CONNECTED && ns.disk < D_INCONSISTENT)
-		rv = SS_NO_LOCAL_DISK;
-
-	else if (ns.conn > C_CONNECTED && ns.pdsk < D_INCONSISTENT)
-		rv = SS_NO_REMOTE_DISK;
-
-	else if (ns.conn > C_CONNECTED && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)
-		rv = SS_NO_UP_TO_DATE_DISK;
-
-	else if ((ns.conn == C_CONNECTED ||
-		  ns.conn == C_WF_BITMAP_S ||
-		  ns.conn == C_SYNC_SOURCE ||
-		  ns.conn == C_PAUSED_SYNC_S) &&
-		  ns.disk == D_OUTDATED)
-		rv = SS_CONNECTED_OUTDATES;
-
-	else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
-		 (nc->verify_alg[0] == 0))
-		rv = SS_NO_VERIFY_ALG;
-
-	else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
-		  first_peer_device(device)->connection->agreed_pro_version < 88)
-		rv = SS_NOT_SUPPORTED;
-
-	else if (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)
-		rv = SS_NO_UP_TO_DATE_DISK;
-
-	else if ((ns.conn == C_STARTING_SYNC_S || ns.conn == C_STARTING_SYNC_T) &&
-                 ns.pdsk == D_UNKNOWN)
-		rv = SS_NEED_CONNECTION;
-
-	else if (ns.conn >= C_CONNECTED && ns.pdsk == D_UNKNOWN)
-		rv = SS_CONNECTED_OUTDATES;
+	if (rv > 0) {
+		if (ns.role == R_SECONDARY && device->open_cnt)
+			rv = SS_DEVICE_IN_USE;
+		else if (ns.role == R_PRIMARY && ns.conn < C_CONNECTED &&
+			 ns.disk < D_UP_TO_DATE)
+			rv = SS_NO_UP_TO_DATE_DISK;
+		else if (fp >= FP_RESOURCE && ns.role == R_PRIMARY &&
+			 ns.conn < C_CONNECTED && ns.pdsk >= D_UNKNOWN)
+			rv = SS_PRIMARY_NOP;
+		else if (ns.role == R_PRIMARY && ns.disk <= D_INCONSISTENT &&
+			 ns.pdsk <= D_INCONSISTENT)
+			rv = SS_NO_UP_TO_DATE_DISK;
+		else if (ns.conn > C_CONNECTED && ns.disk < D_INCONSISTENT)
+			rv = SS_NO_LOCAL_DISK;
+		else if (ns.conn > C_CONNECTED && ns.pdsk < D_INCONSISTENT)
+			rv = SS_NO_REMOTE_DISK;
+		else if (ns.conn > C_CONNECTED && ns.disk < D_UP_TO_DATE &&
+			 ns.pdsk < D_UP_TO_DATE)
+			rv = SS_NO_UP_TO_DATE_DISK;
+		else if ((ns.conn == C_CONNECTED || ns.conn == C_WF_BITMAP_S ||
+			  ns.conn == C_SYNC_SOURCE ||
+			  ns.conn == C_PAUSED_SYNC_S) && ns.disk == D_OUTDATED)
+			rv = SS_CONNECTED_OUTDATES;
+		else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
+			 (nc->verify_alg[0] == 0))
+			rv = SS_NO_VERIFY_ALG;
+		else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
+			  first_peer_device(device)->connection->agreed_pro_version < 88)
+			rv = SS_NOT_SUPPORTED;
+		else if (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE &&
+			 ns.pdsk < D_UP_TO_DATE)
+			rv = SS_NO_UP_TO_DATE_DISK;
+		else if ((ns.conn == C_STARTING_SYNC_S ||
+			  ns.conn == C_STARTING_SYNC_T) && ns.pdsk == D_UNKNOWN)
+			rv = SS_NEED_CONNECTION;
+		else if (ns.conn >= C_CONNECTED && ns.pdsk == D_UNKNOWN)
+			rv = SS_CONNECTED_OUTDATES;
+	}
 
 	rcu_read_unlock();
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ