[PATCH 1/3] Cochran: Add a size parameter to cochran_commander_read_config().

John Van Ostrand john at vanostrand.com
Fri Aug 11 07:33:22 PDT 2017


Responded to a code review.
---
 src/cochran_commander.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/cochran_commander.c b/src/cochran_commander.c
index f7d2e91..068fd04 100644
--- a/src/cochran_commander.c
+++ b/src/cochran_commander.c
@@ -429,12 +429,24 @@ cochran_commander_read_id (cochran_commander_device_t *device, unsigned char id[
 
 
 static dc_status_t
-cochran_commander_read_config (cochran_commander_device_t *device, dc_event_progress_t *progress, unsigned char data[])
+cochran_commander_read_config (cochran_commander_device_t *device, dc_event_progress_t *progress, unsigned char data[], int data_size)
 {
 	dc_device_t *abstract = (dc_device_t *) device;
 	dc_status_t rc = DC_STATUS_SUCCESS;
 
-	unsigned int pages = 2;
+	unsigned int pages = 0;
+
+	switch (data_size) {
+	case 512:
+		pages = 1;
+		break;
+	case 1024:
+		pages = 2;
+		break;
+	default:
+		return DC_STATUS_INVALIDARGS;
+		break;
+	}
 
 	if (device->layout->model == COCHRAN_MODEL_COMMANDER_TM)
 		pages = 1;
@@ -816,7 +828,7 @@ cochran_commander_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
 	vendor.size = sizeof (device->id);
 	device_event_emit (abstract, DC_EVENT_VENDOR, &vendor);
 
-	rc = cochran_commander_read_config (device, &progress, config);
+	rc = cochran_commander_read_config (device, &progress, config, config_size);
 	if (rc != DC_STATUS_SUCCESS)
 		return rc;
 
@@ -867,7 +879,7 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
 
 	// Read config
 	dc_status_t rc = DC_STATUS_SUCCESS;
-	rc = cochran_commander_read_config(device, &progress, data.config);
+	rc = cochran_commander_read_config(device, &progress, data.config, max_config);
 	if (rc != DC_STATUS_SUCCESS)
 		return rc;
 
-- 
2.4.11



More information about the devel mailing list