From 6e567e1e55a1968926eeb75be34cb1689dbeab7b Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Fri, 14 Dec 2012 19:42:55 +0000
Subject: [PATCH] Removed a redundant variable.

The offHook flag was equivalent to reliabilityLayer != null.
---
 .../net/sf/briar/plugins/modem/ModemImpl.java    | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java b/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
index 774ac84938..39ba6ea9e4 100644
--- a/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
+++ b/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
@@ -36,9 +36,8 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 
 	private int lineLen = 0;
 
-	// All of the following are locking: this
-	private ReliabilityLayer reliabilityLayer = null;
-	private boolean initialised = false, offHook = false, connected = false;
+	private ReliabilityLayer reliabilityLayer = null; // Locking: this
+	private boolean initialised = false, connected = false; // Locking: this
 
 	ModemImpl(Executor executor, Callback callback, String portName) {
 		this.executor = executor;
@@ -145,18 +144,17 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 	private void hangUpInner() throws IOException {
 		ReliabilityLayer reliabilityLayer;
 		synchronized(this) {
-			if(!offHook) {
+			if(this.reliabilityLayer == null) {
 				if(LOG.isLoggable(INFO))
 					LOG.info("Not hanging up - already on the hook");
 				return;
 			}
-			if(LOG.isLoggable(INFO)) LOG.info("Hanging up");
 			reliabilityLayer = this.reliabilityLayer;
 			this.reliabilityLayer = null;
-			offHook = false;
 			connected = false;
 		}
 		reliabilityLayer.stop();
+		if(LOG.isLoggable(INFO)) LOG.info("Hanging up");
 		try {
 			port.setDTR(false);
 		} catch(SerialPortException e) {
@@ -179,13 +177,12 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 						LOG.info("Not dialling - modem not initialised");
 					return false;
 				}
-				if(offHook) {
+				if(this.reliabilityLayer != null) {
 					if(LOG.isLoggable(INFO))
 						LOG.info("Not dialling - call in progress");
 					return false;
 				}
 				this.reliabilityLayer = reliabilityLayer;
-				offHook = true;
 			}
 			reliabilityLayer.start();
 			if(LOG.isLoggable(INFO)) LOG.info("Dialling");
@@ -358,13 +355,12 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 						LOG.info("Not answering - modem not initialised");
 					return;
 				}
-				if(offHook) {
+				if(this.reliabilityLayer != null) {
 					if(LOG.isLoggable(INFO))
 						LOG.info("Not answering - call in progress");
 					return;
 				}
 				this.reliabilityLayer = reliabilityLayer;
-				offHook = true;
 			}
 			reliabilityLayer.start();
 			if(LOG.isLoggable(INFO)) LOG.info("Answering");
-- 
GitLab