From a87ce4efcbdb9ad3aff3eb52ee9fd9da8e4ab922 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan Date: Thu, 9 Feb 2017 00:37:06 +0100 Subject: 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.) --- src/restore.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 83eef83..05ec228 100644 --- a/src/restore.c +++ b/src/restore.c @@ -222,7 +222,7 @@ int restore_check_mode(struct idevicerestore_client_t* client) { return 0; } -const char* restore_check_hardware_model(struct idevicerestore_client_t* client) { +irecv_device_t restore_get_irecv_device(struct idevicerestore_client_t* client) { char* model = NULL; plist_t node = NULL; idevice_t device = NULL; @@ -274,11 +274,8 @@ const char* restore_check_hardware_model(struct idevicerestore_client_t* client) plist_get_string_val(node, &model); irecv_devices_get_device_by_hardware_model(model, &irecv_device); free(model); - if (irecv_device && irecv_device->product_type) { - return irecv_device->hardware_model; - } - return NULL; + return irecv_device; } void restore_device_callback(const idevice_event_t* event, void* userdata) { -- cgit v1.1-32-gdbae