[PATCH 8/8] Cleaned up cochran assignments in if statments

John Van Ostrand john at vanostrand.com
Sun Nov 2 18:52:34 PST 2014


---
 src/cochran_commander.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/cochran_commander.c b/src/cochran_commander.c
index fc25932..d6e4152 100644
--- a/src/cochran_commander.c
+++ b/src/cochran_commander.c
@@ -151,9 +151,9 @@ cochran_commander_serial_setup (cochran_device_t *device, dc_context_t *context)
 	}
 
 	// Wait for heartbeat byte before send
-	int n;
 	char answer[1];
-	if ((n = serial_read(device->port, answer, 1)) != 1) {
+	int n = serial_read(device->port, answer, 1);
+	if (n != 1) {
 		ERROR (context, "Failed to receive device heartbeat.");
 		return EXITCODE (n);
 	}
@@ -205,8 +205,8 @@ cochran_commander_device_open (dc_device_t **out, dc_context_t *context,
 	device->data.sample = NULL;
 	cochran_commander_device_set_fingerprint((dc_device_t *) device, "", 0);
 
-	if ((rc = cochran_commander_serial_open(device, context))
-			!= DC_STATUS_SUCCESS)
+	rc = cochran_commander_serial_open(device, context);
+	if (rc != DC_STATUS_SUCCESS)
 		return rc;
 
 	// Read ID from the device
@@ -472,9 +472,9 @@ cochran_read_misc (dc_device_t *abstract)
 	// Send first byte then wait for heartbeat before sending the rest
 	serial_write(device->port, command, 1);
 
-	int n;
 	char answer[1];
-	if ((n = serial_read(device->port, answer, 1)) != 1) {
+	int n = serial_read(device->port, answer, 1);
+	if (n != 1) {
 		ERROR (abstract->context, "Failed to receive device heartbeat.");
 		return EXITCODE (n);
 	}
-- 
1.8.3.1



More information about the devel mailing list