summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Rosen Penev2020-12-23 17:39:01 -0800
committerGravatar Nikias Bassen2022-04-30 13:34:21 +0200
commitcf2c7d48380969200034afeab93169e68c34c397 (patch)
treea96f518be279922d00898a3ce81dc0ff483a40b2
parent6cb13f9e6d3939930aecf91d8e23d1896a3b92e5 (diff)
downloadlibimobiledevice-cf2c7d48380969200034afeab93169e68c34c397.tar.gz
libimobiledevice-cf2c7d48380969200034afeab93169e68c34c397.tar.bz2
[clang-tidy] Do not use else after return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
-rw-r--r--src/afc.c34
-rw-r--r--src/idevice.c76
-rw-r--r--src/lockdown.c20
-rw-r--r--src/misagent.c3
-rw-r--r--src/mobileactivation.c15
-rw-r--r--src/mobilebackup2.c9
-rw-r--r--src/preboard.c3
-rw-r--r--src/restore.c18
-rw-r--r--src/syslog_relay.c9
-rw-r--r--tools/idevicebackup.c13
-rw-r--r--tools/idevicebackup2.c28
-rw-r--r--tools/idevicecrashreport.c6
-rw-r--r--tools/ideviceprovision.c4
-rw-r--r--tools/idevicesyslog.c22
14 files changed, 133 insertions, 127 deletions
diff --git a/src/afc.c b/src/afc.c
index 17273e2..d8c3db0 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -229,7 +229,9 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t
229 if (recv_len == 0) { 229 if (recv_len == 0) {
230 debug_info("Just didn't get enough."); 230 debug_info("Just didn't get enough.");
231 return AFC_E_MUX_ERROR; 231 return AFC_E_MUX_ERROR;
232 } else if (recv_len < sizeof(AFCPacket)) { 232 }
233
234 if (recv_len < sizeof(AFCPacket)) {
233 debug_info("Did not even get the AFCPacket header"); 235 debug_info("Did not even get the AFCPacket header");
234 return AFC_E_MUX_ERROR; 236 return AFC_E_MUX_ERROR;
235 } 237 }
@@ -250,14 +252,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t
250 if (header.this_length < sizeof(AFCPacket)) { 252 if (header.this_length < sizeof(AFCPacket)) {
251 debug_info("Invalid AFCPacket header received!"); 253 debug_info("Invalid AFCPacket header received!");
252 return AFC_E_OP_HEADER_INVALID; 254 return AFC_E_OP_HEADER_INVALID;
253 } else if ((header.this_length == header.entire_length) 255 }
254 && header.entire_length == sizeof(AFCPacket)) { 256 if ((header.this_length == header.entire_length)
257 && header.entire_length == sizeof(AFCPacket)) {
255 debug_info("Empty AFCPacket received!"); 258 debug_info("Empty AFCPacket received!");
256 if (header.operation == AFC_OP_DATA) { 259 if (header.operation == AFC_OP_DATA) {
257 return AFC_E_SUCCESS; 260 return AFC_E_SUCCESS;
258 } else {
259 return AFC_E_IO_ERROR;
260 } 261 }
262 return AFC_E_IO_ERROR;
261 } 263 }
262 264
263 debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation); 265 debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation);
@@ -273,7 +275,8 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t
273 free(buf); 275 free(buf);
274 debug_info("Did not get packet contents!"); 276 debug_info("Did not get packet contents!");
275 return AFC_E_NOT_ENOUGH_DATA; 277 return AFC_E_NOT_ENOUGH_DATA;
276 } else if (recv_len < this_len) { 278 }
279 if (recv_len < this_len) {
277 free(buf); 280 free(buf);
278 debug_info("Could not receive this_len=%d bytes", this_len); 281 debug_info("Could not receive this_len=%d bytes", this_len);
279 return AFC_E_NOT_ENOUGH_DATA; 282 return AFC_E_NOT_ENOUGH_DATA;
@@ -749,22 +752,23 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t han
749 if (ret != AFC_E_SUCCESS) { 752 if (ret != AFC_E_SUCCESS) {
750 afc_unlock(client); 753 afc_unlock(client);
751 return ret; 754 return ret;
752 } else if (bytes_loc == 0) { 755 }
756 if (bytes_loc == 0) {
753 if (input) 757 if (input)
754 free(input); 758 free(input);
755 afc_unlock(client); 759 afc_unlock(client);
756 *bytes_read = current_count; 760 *bytes_read = current_count;
757 /* FIXME: check that's actually a success */ 761 /* FIXME: check that's actually a success */
758 return ret; 762 return ret;
759 } else {
760 if (input) {
761 debug_info("%d", bytes_loc);
762 memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc);
763 free(input);
764 input = NULL;
765 current_count += (bytes_loc > length) ? length : bytes_loc;
766 }
767 } 763 }
764 if (input) {
765 debug_info("%d", bytes_loc);
766 memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc);
767 free(input);
768 input = NULL;
769 current_count += (bytes_loc > length) ? length : bytes_loc;
770 }
771
768 afc_unlock(client); 772 afc_unlock(client);
769 *bytes_read = current_count; 773 *bytes_read = current_count;
770 return ret; 774 return ret;
diff --git a/src/idevice.c b/src/idevice.c
index f64570b..adf47f4 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -473,7 +473,8 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t
473 new_connection->status = IDEVICE_E_SUCCESS; 473 new_connection->status = IDEVICE_E_SUCCESS;
474 *connection = new_connection; 474 *connection = new_connection;
475 return IDEVICE_E_SUCCESS; 475 return IDEVICE_E_SUCCESS;
476 } else if (device->conn_type == CONNECTION_NETWORK) { 476 }
477 if (device->conn_type == CONNECTION_NETWORK) {
477 struct sockaddr_storage saddr_storage; 478 struct sockaddr_storage saddr_storage;
478 struct sockaddr* saddr = (struct sockaddr*)&saddr_storage; 479 struct sockaddr* saddr = (struct sockaddr*)&saddr_storage;
479 480
@@ -529,10 +530,9 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t
529 *connection = new_connection; 530 *connection = new_connection;
530 531
531 return IDEVICE_E_SUCCESS; 532 return IDEVICE_E_SUCCESS;
532 } else {
533 debug_info("Unknown connection type %d", device->conn_type);
534 } 533 }
535 534
535 debug_info("Unknown connection type %d", device->conn_type);
536 return IDEVICE_E_UNKNOWN_ERROR; 536 return IDEVICE_E_UNKNOWN_ERROR;
537} 537}
538 538
@@ -583,7 +583,8 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection,
583 return IDEVICE_E_UNKNOWN_ERROR; 583 return IDEVICE_E_UNKNOWN_ERROR;
584 } 584 }
585 return IDEVICE_E_SUCCESS; 585 return IDEVICE_E_SUCCESS;
586 } else if (connection->type == CONNECTION_NETWORK) { 586 }
587 if (connection->type == CONNECTION_NETWORK) {
587 int s = socket_send((int)(long)connection->data, (void*)data, len); 588 int s = socket_send((int)(long)connection->data, (void*)data, len);
588 if (s < 0) { 589 if (s < 0) {
589 *sent_bytes = 0; 590 *sent_bytes = 0;
@@ -591,9 +592,9 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection,
591 } 592 }
592 *sent_bytes = s; 593 *sent_bytes = s;
593 return IDEVICE_E_SUCCESS; 594 return IDEVICE_E_SUCCESS;
594 } else {
595 debug_info("Unknown connection type %d", connection->type);
596 } 595 }
596
597 debug_info("Unknown connection type %d", connection->type);
597 return IDEVICE_E_UNKNOWN_ERROR; 598 return IDEVICE_E_UNKNOWN_ERROR;
598 599
599} 600}
@@ -638,27 +639,26 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_
638 } 639 }
639 *sent_bytes = sent; 640 *sent_bytes = sent;
640 return IDEVICE_E_SUCCESS; 641 return IDEVICE_E_SUCCESS;
641 } else { 642 }
642 uint32_t sent = 0; 643 uint32_t sent = 0;
643 while (sent < len) { 644 while (sent < len) {
644 uint32_t bytes = 0; 645 uint32_t bytes = 0;
645 int s = internal_connection_send(connection, data+sent, len-sent, &bytes); 646 int s = internal_connection_send(connection, data+sent, len-sent, &bytes);
646 if (s < 0) { 647 if (s < 0) {
647 break; 648 break;
648 }
649 sent += bytes;
650 }
651 debug_info("len %d, sent %d", len, sent);
652 if (sent < len) {
653 *sent_bytes = sent;
654 if (sent == 0) {
655 return IDEVICE_E_UNKNOWN_ERROR;
656 }
657 return IDEVICE_E_NOT_ENOUGH_DATA;
658 } 649 }
650 sent += bytes;
651 }
652 debug_info("internal_connection_send %d, sent %d", len, sent);
653 if (sent < len) {
659 *sent_bytes = sent; 654 *sent_bytes = sent;
660 return IDEVICE_E_SUCCESS; 655 if (sent == 0) {
656 return IDEVICE_E_UNKNOWN_ERROR;
657 }
658 return IDEVICE_E_NOT_ENOUGH_DATA;
661 } 659 }
660 *sent_bytes = sent;
661 return IDEVICE_E_SUCCESS;
662} 662}
663 663
664static inline idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received) 664static inline idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received)
@@ -698,7 +698,8 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t
698 debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", conn_error, strerror(-conn_error)); 698 debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", conn_error, strerror(-conn_error));
699 } 699 }
700 return error; 700 return error;
701 } else if (connection->type == CONNECTION_NETWORK) { 701 }
702 if (connection->type == CONNECTION_NETWORK) {
702 int res = socket_receive_timeout((int)(long)connection->data, data, len, 0, timeout); 703 int res = socket_receive_timeout((int)(long)connection->data, data, len, 0, timeout);
703 idevice_error_t error = socket_recv_to_idevice_error(res, 0, 0); 704 idevice_error_t error = socket_recv_to_idevice_error(res, 0, 0);
704 if (error == IDEVICE_E_SUCCESS) { 705 if (error == IDEVICE_E_SUCCESS) {
@@ -707,9 +708,9 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t
707 debug_info("ERROR: socket_receive_timeout returned %d (%s)", res, strerror(-res)); 708 debug_info("ERROR: socket_receive_timeout returned %d (%s)", res, strerror(-res));
708 } 709 }
709 return error; 710 return error;
710 } else {
711 debug_info("Unknown connection type %d", connection->type);
712 } 711 }
712
713 debug_info("Unknown connection type %d", connection->type);
713 return IDEVICE_E_UNKNOWN_ERROR; 714 return IDEVICE_E_UNKNOWN_ERROR;
714} 715}
715 716
@@ -793,7 +794,8 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti
793 return IDEVICE_E_UNKNOWN_ERROR; 794 return IDEVICE_E_UNKNOWN_ERROR;
794 } 795 }
795 return IDEVICE_E_SUCCESS; 796 return IDEVICE_E_SUCCESS;
796 } else if (connection->type == CONNECTION_NETWORK) { 797 }
798 if (connection->type == CONNECTION_NETWORK) {
797 int res = socket_receive((int)(long)connection->data, data, len); 799 int res = socket_receive((int)(long)connection->data, data, len);
798 if (res < 0) { 800 if (res < 0) {
799 debug_info("ERROR: socket_receive returned %d (%s)", res, strerror(-res)); 801 debug_info("ERROR: socket_receive returned %d (%s)", res, strerror(-res));
@@ -801,9 +803,9 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti
801 } 803 }
802 *recv_bytes = (uint32_t)res; 804 *recv_bytes = (uint32_t)res;
803 return IDEVICE_E_SUCCESS; 805 return IDEVICE_E_SUCCESS;
804 } else {
805 debug_info("Unknown connection type %d", connection->type);
806 } 806 }
807
808 debug_info("Unknown connection type %d", connection->type);
807 return IDEVICE_E_UNKNOWN_ERROR; 809 return IDEVICE_E_UNKNOWN_ERROR;
808} 810}
809 811
@@ -846,17 +848,17 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connectio
846 return IDEVICE_E_INVALID_ARG; 848 return IDEVICE_E_INVALID_ARG;
847 } 849 }
848 850
849 idevice_error_t result = IDEVICE_E_UNKNOWN_ERROR;
850 if (connection->type == CONNECTION_USBMUXD) { 851 if (connection->type == CONNECTION_USBMUXD) {
851 *fd = (int)(long)connection->data; 852 *fd = (int)(long)connection->data;
852 result = IDEVICE_E_SUCCESS; 853 return IDEVICE_E_SUCCESS;
853 } else if (connection->type == CONNECTION_NETWORK) { 854 }
855 if (connection->type == CONNECTION_NETWORK) {
854 *fd = (int)(long)connection->data; 856 *fd = (int)(long)connection->data;
855 result = IDEVICE_E_SUCCESS; 857 return IDEVICE_E_SUCCESS;
856 } else {
857 debug_info("Unknown connection type %d", connection->type);
858 } 858 }
859 return result; 859
860 debug_info("Unknown connection type %d", connection->type);
861 return IDEVICE_E_UNKNOWN_ERROR;
860} 862}
861 863
862LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) 864LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
diff --git a/src/lockdown.c b/src/lockdown.c
index 25e8c87..d0922dd 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -163,22 +163,22 @@ lockdownd_error_t lockdown_check_result(plist_t dict, const char *query_match)
163 163
164 if (plist_get_node_type(query_node) != PLIST_STRING) { 164 if (plist_get_node_type(query_node) != PLIST_STRING) {
165 return ret; 165 return ret;
166 } else { 166 }
167 char *query_value = NULL;
168 167
169 plist_get_string_val(query_node, &query_value); 168 char *query_value = NULL;
170 if (!query_value) {
171 return ret;
172 }
173 169
174 if (query_match && (strcmp(query_value, query_match) != 0)) { 170 plist_get_string_val(query_node, &query_value);
175 free(query_value); 171 if (!query_value) {
176 return ret; 172 return ret;
177 } 173 }
178 174
175 if (query_match && (strcmp(query_value, query_match) != 0)) {
179 free(query_value); 176 free(query_value);
177 return ret;
180 } 178 }
181 179
180 free(query_value);
181
182 plist_t result_node = plist_dict_get_item(dict, "Result"); 182 plist_t result_node = plist_dict_get_item(dict, "Result");
183 if (!result_node) { 183 if (!result_node) {
184 /* iOS 5: the 'Result' key is not present anymore. 184 /* iOS 5: the 'Result' key is not present anymore.
diff --git a/src/misagent.c b/src/misagent.c
index d790a05..af925f9 100644
--- a/src/misagent.c
+++ b/src/misagent.c
@@ -85,9 +85,8 @@ static misagent_error_t misagent_check_result(plist_t response, int* status_code
85 *status_code = (int)(val & 0xFFFFFFFF); 85 *status_code = (int)(val & 0xFFFFFFFF);
86 if (*status_code == 0) { 86 if (*status_code == 0) {
87 return MISAGENT_E_SUCCESS; 87 return MISAGENT_E_SUCCESS;
88 } else {
89 return MISAGENT_E_REQUEST_FAILED;
90 } 88 }
89 return MISAGENT_E_REQUEST_FAILED;
91} 90}
92 91
93LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client) 92LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
diff --git a/src/mobileactivation.c b/src/mobileactivation.c
index 2de4333..79c7003 100644
--- a/src/mobileactivation.c
+++ b/src/mobileactivation.c
@@ -109,8 +109,6 @@ static plist_t plist_data_from_plist(plist_t plist)
109 109
110static mobileactivation_error_t mobileactivation_check_result(plist_t dict, const char *command) 110static mobileactivation_error_t mobileactivation_check_result(plist_t dict, const char *command)
111{ 111{
112 mobileactivation_error_t ret = MOBILEACTIVATION_E_UNKNOWN_ERROR;
113
114 if (!dict || plist_get_node_type(dict) != PLIST_DICT) { 112 if (!dict || plist_get_node_type(dict) != PLIST_DICT) {
115 return MOBILEACTIVATION_E_PLIST_ERROR; 113 return MOBILEACTIVATION_E_PLIST_ERROR;
116 } 114 }
@@ -118,14 +116,13 @@ static mobileactivation_error_t mobileactivation_check_result(plist_t dict, cons
118 plist_t err_node = plist_dict_get_item(dict, "Error"); 116 plist_t err_node = plist_dict_get_item(dict, "Error");
119 if (!err_node) { 117 if (!err_node) {
120 return MOBILEACTIVATION_E_SUCCESS; 118 return MOBILEACTIVATION_E_SUCCESS;
121 } else {
122 char *errmsg = NULL;
123 plist_get_string_val(err_node, &errmsg);
124 debug_info("ERROR: %s: %s", command, errmsg);
125 ret = MOBILEACTIVATION_E_REQUEST_FAILED;
126 free(errmsg);
127 } 119 }
128 return ret; 120
121 char *errmsg = NULL;
122 plist_get_string_val(err_node, &errmsg);
123 debug_info("ERROR: %s: %s", command, errmsg);
124 free(errmsg);
125 return MOBILEACTIVATION_E_REQUEST_FAILED;
129} 126}
130 127
131static mobileactivation_error_t mobileactivation_send_command_plist(mobileactivation_client_t client, plist_t command, plist_t *result) 128static mobileactivation_error_t mobileactivation_send_command_plist(mobileactivation_client_t client, plist_t command, plist_t *result)
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c
index f4fde95..3726065 100644
--- a/src/mobilebackup2.c
+++ b/src/mobilebackup2.c
@@ -240,9 +240,8 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_
240 if (sent > 0) { 240 if (sent > 0) {
241 *bytes = sent; 241 *bytes = sent;
242 return MOBILEBACKUP2_E_SUCCESS; 242 return MOBILEBACKUP2_E_SUCCESS;
243 } else {
244 return MOBILEBACKUP2_E_MUX_ERROR;
245 } 243 }
244 return MOBILEBACKUP2_E_MUX_ERROR;
246} 245}
247 246
248LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) 247LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes)
@@ -265,11 +264,11 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebacku
265 if (received > 0) { 264 if (received > 0) {
266 *bytes = received; 265 *bytes = received;
267 return MOBILEBACKUP2_E_SUCCESS; 266 return MOBILEBACKUP2_E_SUCCESS;
268 } else if (received == 0) { 267 }
268 if (received == 0) {
269 return MOBILEBACKUP2_E_SUCCESS; 269 return MOBILEBACKUP2_E_SUCCESS;
270 } else {
271 return MOBILEBACKUP2_E_MUX_ERROR;
272 } 270 }
271 return MOBILEBACKUP2_E_MUX_ERROR;
273} 272}
274 273
275LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version) 274LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version)
diff --git a/src/preboard.c b/src/preboard.c
index b975f0e..4b3b444 100644
--- a/src/preboard.c
+++ b/src/preboard.c
@@ -162,7 +162,8 @@ static void* preboard_receive_status_loop_thread(void* arg)
162 preboard_error_t perr = preboard_receive_with_timeout(data->client, &pl, 1000); 162 preboard_error_t perr = preboard_receive_with_timeout(data->client, &pl, 1000);
163 if (perr == PREBOARD_E_TIMEOUT) { 163 if (perr == PREBOARD_E_TIMEOUT) {
164 continue; 164 continue;
165 } else if (perr == PREBOARD_E_SUCCESS) { 165 }
166 if (perr == PREBOARD_E_SUCCESS) {
166 data->cbfunc(pl, data->user_data); 167 data->cbfunc(pl, data->user_data);
167 } 168 }
168 plist_free(pl); 169 plist_free(pl);
diff --git a/src/restore.c b/src/restore.c
index 4e9d65a..591fd16 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -268,29 +268,27 @@ LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t cli
268 268
269LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) 269LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
270{ 270{
271 plist_t item;
272
271 if (!client || !value || (value && *value)) 273 if (!client || !value || (value && *value))
272 return RESTORE_E_INVALID_ARG; 274 return RESTORE_E_INVALID_ARG;
273 275
274 if (!client->info) 276 if (!client->info)
275 return RESTORE_E_NOT_ENOUGH_DATA; 277 return RESTORE_E_NOT_ENOUGH_DATA;
276 278
277 restored_error_t ret = RESTORE_E_SUCCESS;
278 plist_t item = NULL;
279
280 if (!key) { 279 if (!key) {
281 *value = plist_copy(client->info); 280 *value = plist_copy(client->info);
282 return RESTORE_E_SUCCESS; 281 return RESTORE_E_SUCCESS;
283 } else {
284 item = plist_dict_get_item(client->info, key);
285 } 282 }
286 283
287 if (item) { 284 item = plist_dict_get_item(client->info, key);
288 *value = plist_copy(item); 285 if (!item) {
289 } else { 286 return RESTORE_E_PLIST_ERROR;
290 ret = RESTORE_E_PLIST_ERROR;
291 } 287 }
292 288
293 return ret; 289 *value = plist_copy(item);
290 free(item);
291 return RESTORE_E_SUCCESS;
294} 292}
295 293
296LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label) 294LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label)
diff --git a/src/syslog_relay.c b/src/syslog_relay.c
index c137297..ec9eca5 100644
--- a/src/syslog_relay.c
+++ b/src/syslog_relay.c
@@ -154,16 +154,15 @@ void *syslog_relay_worker(void *arg)
154 ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100); 154 ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100);
155 if (ret == SYSLOG_RELAY_E_TIMEOUT || ret == SYSLOG_RELAY_E_NOT_ENOUGH_DATA || ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS))) { 155 if (ret == SYSLOG_RELAY_E_TIMEOUT || ret == SYSLOG_RELAY_E_NOT_ENOUGH_DATA || ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS))) {
156 continue; 156 continue;
157 } else if (ret < 0) { 157 }
158 if (ret < 0) {
158 debug_info("Connection to syslog relay interrupted"); 159 debug_info("Connection to syslog relay interrupted");
159 break; 160 break;
160 } 161 }
161 if (srwt->is_raw) { 162 if (srwt->is_raw) {
162 srwt->cbfunc(c, srwt->user_data); 163 srwt->cbfunc(c, srwt->user_data);
163 } else { 164 } else if (c != 0) {
164 if (c != 0) { 165 srwt->cbfunc(c, srwt->user_data);
165 srwt->cbfunc(c, srwt->user_data);
166 }
167 } 166 }
168 } 167 }
169 168
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index 0affd7a..2856fda 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -926,15 +926,16 @@ int main(int argc, char *argv[])
926 if (aerr == AFC_E_SUCCESS) { 926 if (aerr == AFC_E_SUCCESS) {
927 do_post_notification(NP_SYNC_DID_START); 927 do_post_notification(NP_SYNC_DID_START);
928 break; 928 break;
929 } else if (aerr == AFC_E_OP_WOULD_BLOCK) { 929 }
930 if (aerr == AFC_E_OP_WOULD_BLOCK) {
930 usleep(LOCK_WAIT); 931 usleep(LOCK_WAIT);
931 continue; 932 continue;
932 } else {
933 fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr);
934 afc_file_close(afc, lockfile);
935 lockfile = 0;
936 cmd = CMD_LEAVE;
937 } 933 }
934
935 fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr);
936 afc_file_close(afc, lockfile);
937 lockfile = 0;
938 cmd = CMD_LEAVE;
938 } 939 }
939 if (i == LOCK_ATTEMPTS) { 940 if (i == LOCK_ATTEMPTS) {
940 fprintf(stderr, "ERROR: timeout while locking for sync\n"); 941 fprintf(stderr, "ERROR: timeout while locking for sync\n");
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index d1ef0d6..ec7eacd 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -184,9 +184,8 @@ static int mkdir_with_parents(const char *dir, int mode)
184 if (!dir) return -1; 184 if (!dir) return -1;
185 if (__mkdir(dir, mode) == 0) { 185 if (__mkdir(dir, mode) == 0) {
186 return 0; 186 return 0;
187 } else {
188 if (errno == EEXIST) return 0;
189 } 187 }
188 if (errno == EEXIST) return 0;
190 int res; 189 int res;
191 char *parent = strdup(dir); 190 char *parent = strdup(dir);
192 char *parentdir = dirname(parent); 191 char *parentdir = dirname(parent);
@@ -973,10 +972,12 @@ static int mb2_receive_filename(mobilebackup2_client_t mobilebackup2, char** fil
973 if ((nlen == 0) && (rlen == 4)) { 972 if ((nlen == 0) && (rlen == 4)) {
974 // a zero length means no more files to receive 973 // a zero length means no more files to receive
975 return 0; 974 return 0;
976 } else if(rlen == 0) { 975 }
976 if (rlen == 0) {
977 // device needs more time, waiting... 977 // device needs more time, waiting...
978 continue; 978 continue;
979 } else if (nlen > 4096) { 979 }
980 if (nlen > 4096) {
980 // filename length is too large 981 // filename length is too large
981 printf("ERROR: %s: too large filename length (%d)!\n", __func__, nlen); 982 printf("ERROR: %s: too large filename length (%d)!\n", __func__, nlen);
982 return 0; 983 return 0;
@@ -1368,7 +1369,8 @@ static void get_hidden_input(char *buf, int maxlen)
1368 while ((c = my_getch())) { 1369 while ((c = my_getch())) {
1369 if ((c == '\r') || (c == '\n')) { 1370 if ((c == '\r') || (c == '\n')) {
1370 break; 1371 break;
1371 } else if (isprint(c)) { 1372 }
1373 if (isprint(c)) {
1372 if (pwlen < maxlen-1) 1374 if (pwlen < maxlen-1)
1373 buf[pwlen++] = c; 1375 buf[pwlen++] = c;
1374 fputc('*', stderr); 1376 fputc('*', stderr);
@@ -1961,15 +1963,16 @@ int main(int argc, char *argv[])
1961 if (aerr == AFC_E_SUCCESS) { 1963 if (aerr == AFC_E_SUCCESS) {
1962 do_post_notification(device, NP_SYNC_DID_START); 1964 do_post_notification(device, NP_SYNC_DID_START);
1963 break; 1965 break;
1964 } else if (aerr == AFC_E_OP_WOULD_BLOCK) { 1966 }
1967 if (aerr == AFC_E_OP_WOULD_BLOCK) {
1965 usleep(LOCK_WAIT); 1968 usleep(LOCK_WAIT);
1966 continue; 1969 continue;
1967 } else {
1968 fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr);
1969 afc_file_close(afc, lockfile);
1970 lockfile = 0;
1971 cmd = CMD_LEAVE;
1972 } 1970 }
1971
1972 fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr);
1973 afc_file_close(afc, lockfile);
1974 lockfile = 0;
1975 cmd = CMD_LEAVE;
1973 } 1976 }
1974 if (i == LOCK_ATTEMPTS) { 1977 if (i == LOCK_ATTEMPTS) {
1975 fprintf(stderr, "ERROR: timeout while locking for sync\n"); 1978 fprintf(stderr, "ERROR: timeout while locking for sync\n");
@@ -2103,9 +2106,8 @@ checkpoint:
2103 if (write_restore_applications(info_plist, afc) < 0) { 2106 if (write_restore_applications(info_plist, afc) < 0) {
2104 cmd = CMD_LEAVE; 2107 cmd = CMD_LEAVE;
2105 break; 2108 break;
2106 } else {
2107 PRINT_VERBOSE(1, "Wrote RestoreApplications.plist\n");
2108 } 2109 }
2110 PRINT_VERBOSE(1, "Wrote RestoreApplications.plist\n");
2109 } 2111 }
2110 2112
2111 /* Start restore */ 2113 /* Start restore */
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index 48bda3a..d0d2147 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -475,10 +475,10 @@ int main(int argc, char* argv[])
475 if (service_error == SERVICE_E_SUCCESS || service_error == SERVICE_E_TIMEOUT) { 475 if (service_error == SERVICE_E_SUCCESS || service_error == SERVICE_E_TIMEOUT) {
476 attempts++; 476 attempts++;
477 continue; 477 continue;
478 } else {
479 fprintf(stderr, "ERROR: Crash logs could not be moved. Connection interrupted (%d).\n", service_error);
480 break;
481 } 478 }
479
480 fprintf(stderr, "ERROR: Crash logs could not be moved. Connection interrupted (%d).\n", service_error);
481 break;
482 } 482 }
483 service_client_free(svcmove); 483 service_client_free(svcmove);
484 free(ping); 484 free(ping);
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 981a7ee..7cd4f3f 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -448,7 +448,9 @@ int main(int argc, char *argv[])
448 plist_free(pl); 448 plist_free(pl);
449 449
450 return res; 450 return res;
451 } else if (op == OP_COPY) { 451 }
452
453 if (op == OP_COPY) {
452 struct stat st; 454 struct stat st;
453 const char *checkdir = (param2) ? param2 : param; 455 const char *checkdir = (param2) ? param2 : param;
454 if ((stat(checkdir, &st) < 0) || !S_ISDIR(st.st_mode)) { 456 if ((stat(checkdir, &st) < 0) || !S_ISDIR(st.st_mode)) {
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 2a72d72..f85c7cc 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -151,7 +151,9 @@ static void syslog_callback(char c, void *user_data)
151 shall_print = 1; 151 shall_print = 1;
152 cprintf(COLOR_WHITE); 152 cprintf(COLOR_WHITE);
153 break; 153 break;
154 } else if (line[3] == ' ' && line[6] == ' ' && line[15] == ' ') { 154 }
155
156 if (line[3] == ' ' && line[6] == ' ' && line[15] == ' ') {
155 char* end = &line[lp]; 157 char* end = &line[lp];
156 char* p = &line[16]; 158 char* p = &line[16];
157 159
@@ -190,10 +192,9 @@ static void syslog_callback(char c, void *user_data)
190 if (!found) { 192 if (!found) {
191 shall_print = 0; 193 shall_print = 0;
192 break; 194 break;
193 } else {
194 triggered = 1;
195 shall_print = 1;
196 } 195 }
196 triggered = 1;
197 shall_print = 1;
197 } else if (num_trigger_filters == 0 && num_untrigger_filters > 0 && !triggered) { 198 } else if (num_trigger_filters == 0 && num_untrigger_filters > 0 && !triggered) {
198 shall_print = 0; 199 shall_print = 0;
199 quit_flag++; 200 quit_flag++;
@@ -213,9 +214,8 @@ static void syslog_callback(char c, void *user_data)
213 if (!found) { 214 if (!found) {
214 shall_print = 0; 215 shall_print = 0;
215 break; 216 break;
216 } else {
217 shall_print = 1;
218 } 217 }
218 shall_print = 1;
219 } 219 }
220 220
221 /* process name */ 221 /* process name */
@@ -430,7 +430,8 @@ static void device_event_cb(const idevice_event_t* event, void* userdata)
430{ 430{
431 if (use_network && event->conn_type != CONNECTION_NETWORK) { 431 if (use_network && event->conn_type != CONNECTION_NETWORK) {
432 return; 432 return;
433 } else if (!use_network && event->conn_type != CONNECTION_USBMUXD) { 433 }
434 if (!use_network && event->conn_type != CONNECTION_USBMUXD) {
434 return; 435 return;
435 } 436 }
436 if (event->event == IDEVICE_DEVICE_ADD) { 437 if (event->event == IDEVICE_DEVICE_ADD) {
@@ -656,7 +657,8 @@ int main(int argc, char *argv[])
656 fprintf(stderr, "ERROR: -p and -e/-q cannot be used together.\n"); 657 fprintf(stderr, "ERROR: -p and -e/-q cannot be used together.\n");
657 print_usage(argc, argv, 1); 658 print_usage(argc, argv, 1);
658 return 2; 659 return 2;
659 } else if (include_filter > 0 && exclude_kernel > 0) { 660 }
661 if (include_filter > 0 && exclude_kernel > 0) {
660 fprintf(stderr, "ERROR: -p and -K cannot be used together.\n"); 662 fprintf(stderr, "ERROR: -p and -K cannot be used together.\n");
661 print_usage(argc, argv, 1); 663 print_usage(argc, argv, 1);
662 return 2; 664 return 2;
@@ -699,9 +701,9 @@ int main(int argc, char *argv[])
699 if (!udid) { 701 if (!udid) {
700 fprintf(stderr, "No device found. Plug in a device or pass UDID with -u to wait for device to be available.\n"); 702 fprintf(stderr, "No device found. Plug in a device or pass UDID with -u to wait for device to be available.\n");
701 return -1; 703 return -1;
702 } else {
703 fprintf(stderr, "Waiting for device with UDID %s to become available...\n", udid);
704 } 704 }
705
706 fprintf(stderr, "Waiting for device with UDID %s to become available...\n", udid);
705 } 707 }
706 708
707 line_buffer_size = 1024; 709 line_buffer_size = 1024;