Skip to content

Commit

Permalink
dfu: A little code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Apr 4, 2024
1 parent d8f8cb1 commit 6d40d0a
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ irecv_device_t dfu_get_irecv_device(struct idevicerestore_client_t* client)
return device;
}

int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size)
int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size, unsigned int irecv_options)
{
irecv_error_t err = 0;

info("Sending data (%d bytes)...\n", size);

err = irecv_send_buffer(client->dfu->client, buffer, size, 1);
err = irecv_send_buffer(client->dfu->client, buffer, size, irecv_options);
if (err != IRECV_E_SUCCESS) {
error("ERROR: Unable to send data: %s\n", irecv_strerror(err));
return -1;
Expand All @@ -118,19 +118,9 @@ int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffe
return 0;
}

int dfu_send_buffer_with_options(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size, unsigned int irecv_options)
int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size)
{
irecv_error_t err = 0;

info("Sending data (%d bytes)...\n", size);

err = irecv_send_buffer(client->dfu->client, buffer, size, irecv_options);
if (err != IRECV_E_SUCCESS) {
error("ERROR: Unable to send data: %s\n", irecv_strerror(err));
return -1;
}

return 0;
return dfu_send_buffer_with_options(client, buffer, size, IRECV_SEND_OPT_DFU_NOTIFY_FINISH);
}

int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component)
Expand Down Expand Up @@ -208,7 +198,7 @@ int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_ide

info("Sending %s (%d bytes)...\n", component, size);

irecv_error_t err = irecv_send_buffer(client->dfu->client, data, size, 1);
irecv_error_t err = irecv_send_buffer(client->dfu->client, data, size, IRECV_SEND_OPT_DFU_NOTIFY_FINISH);
if (err != IRECV_E_SUCCESS) {
error("ERROR: Unable to send %s component: %s\n", component, irecv_strerror(err));
free(data);
Expand Down

0 comments on commit 6d40d0a

Please sign in to comment.