Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932066AbbK0V1l (ORCPT ); Fri, 27 Nov 2015 16:27:41 -0500 Received: from mailrelay119.isp.belgacom.be ([195.238.20.146]:4148 "EHLO mailrelay119.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755348AbbK0V1e (ORCPT ); Fri, 27 Nov 2015 16:27:34 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B/AgCCyVhW/6YUtFtegmlSgUK8BYIaAQ2BZIYPAoE+ORQBAQEBAQEBgQqENQEBBCcvIxBROR4ZiDIBsnKKDgEBCCOGVI43BYdKjw2NOI8xjTAfAQFChAU9NIVSAQEB From: Fabian Frederick To: linux-kernel@vger.kernel.org Cc: Philipp Reisner , Fabian Frederick , Lars Ellenberg , drbd-dev@lists.linbit.com Subject: [PATCH 05/21] drbd: rework is_valid_state() Date: Fri, 27 Nov 2015 22:26:10 +0100 Message-Id: <1448659575-13485-6-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448659575-13485-1-git-send-email-fabf@skynet.be> References: <1448659575-13485-1-git-send-email-fabf@skynet.be> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4064 Lines: 112 Remove empty condition to avoid semantic warnings Signed-off-by: Fabian Frederick --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/