summaryrefslogtreecommitdiffstats
path: root/src/idevicerestore.c
diff options
context:
space:
mode:
authorGravatar BALATON Zoltan2017-02-09 00:37:06 +0100
committerGravatar BALATON Zoltan2017-11-13 22:12:44 +0100
commita87ce4efcbdb9ad3aff3eb52ee9fd9da8e4ab922 (patch)
tree78dba41813b8037db98212a8647ec4bf940b2fc7 /src/idevicerestore.c
parent08d610d5811ed0aa3fecf48ff9e9cee2190b1981 (diff)
downloadidevicerestore-a87ce4efcbdb9ad3aff3eb52ee9fd9da8e4ab922.tar.gz
idevicerestore-a87ce4efcbdb9ad3aff3eb52ee9fd9da8e4ab922.tar.bz2
Change check_hardware_model() to get_irecv_device()
The check_hardware_model() function has a misleading name. It returns a string with the hardware model but this is not used. Instead, this function is only called for its side effect to initialise an irecv device in the passed client struct which it creates from the hardware model name returned by mode specific implementations. But these mode specific implementations already create an irecv device to get the hardware model name so instead of going through this unnecessary complication just return the irecv device directly and rename the function accordingly to make this clear. (This may also prevent leaking an irecv device in the mode specific functions.)
Diffstat (limited to 'src/idevicerestore.c')
-rw-r--r--src/idevicerestore.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 423d79c..a051b95 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -284,8 +284,9 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}
// discover the device type
- if (check_hardware_model(client) == NULL || client->device == NULL) {
- error("ERROR: Unable to discover device model\n");
+ client->device = get_irecv_device(client);
+ if (client->device == NULL) {
+ error("ERROR: Unable to discover device type\n");
return -1;
}
idevicerestore_progress(client, RESTORE_STEP_DETECT, 0.2);
@@ -1193,8 +1194,7 @@ int check_mode(struct idevicerestore_client_t* client) {
return mode;
}
-const char* check_hardware_model(struct idevicerestore_client_t* client) {
- const char* hw_model = NULL;
+irecv_device_t get_irecv_device(struct idevicerestore_client_t *client) {
int mode = MODE_UNKNOWN;
if (client->mode) {
@@ -1203,26 +1203,18 @@ const char* check_hardware_model(struct idevicerestore_client_t* client) {
switch (mode) {
case MODE_RESTORE:
- hw_model = restore_check_hardware_model(client);
- break;
+ return restore_get_irecv_device(client);
case MODE_NORMAL:
- hw_model = normal_check_hardware_model(client);
- break;
+ return normal_get_irecv_device(client);
case MODE_DFU:
case MODE_RECOVERY:
- hw_model = dfu_check_hardware_model(client);
- break;
- default:
- break;
- }
+ return dfu_get_irecv_device(client);
- if (hw_model != NULL) {
- irecv_devices_get_device_by_hardware_model(hw_model, &client->device);
+ default:
+ return NULL;
}
-
- return hw_model;
}
int is_image4_supported(struct idevicerestore_client_t* client)