diff options
author | 2020-12-23 17:32:57 -0800 | |
---|---|---|
committer | 2022-04-22 16:30:45 +0200 | |
commit | c461e6d76b27b11284dda66316263696d5266764 (patch) | |
tree | 3d612fc904046a381438cf008448aaf4a1424f10 | |
parent | 95316d81633120244d53b85303447beb1a917f74 (diff) | |
download | libimobiledevice-c461e6d76b27b11284dda66316263696d5266764.tar.gz libimobiledevice-c461e6d76b27b11284dda66316263696d5266764.tar.bz2 |
[clang-tidy] Fix bugprone string compare
Found with bugprone-suspicious-string-compare
Signed-off-by: Rosen Penev <rosenp@gmail.com>
-rw-r--r-- | src/afc.c | 2 | ||||
-rw-r--r-- | src/device_link_service.c | 8 | ||||
-rw-r--r-- | src/file_relay.c | 2 | ||||
-rw-r--r-- | src/lockdown.c | 2 | ||||
-rw-r--r-- | src/mobilesync.c | 2 | ||||
-rw-r--r-- | src/screenshotr.c | 2 | ||||
-rw-r--r-- | tools/idevicebackup.c | 4 | ||||
-rw-r--r-- | tools/idevicedebug.c | 16 | ||||
-rw-r--r-- | tools/idevicepair.c | 2 |
9 files changed, 20 insertions, 20 deletions
@@ -235,7 +235,7 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t | |||
235 | } | 235 | } |
236 | 236 | ||
237 | /* check if it's a valid AFC header */ | 237 | /* check if it's a valid AFC header */ |
238 | if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN)) { | 238 | if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN) != 0) { |
239 | debug_info("Invalid AFC packet received (magic != " AFC_MAGIC ")!"); | 239 | debug_info("Invalid AFC packet received (magic != " AFC_MAGIC ")!"); |
240 | } | 240 | } |
241 | 241 | ||
diff --git a/src/device_link_service.c b/src/device_link_service.c index 6daf84d..66c2461 100644 --- a/src/device_link_service.c +++ b/src/device_link_service.c | |||
@@ -83,7 +83,7 @@ static int device_link_service_get_message(plist_t dl_msg, char **message) | |||
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | if ((strlen(cmd_str) < 9) || (strncmp(cmd_str, "DL", 2))) { | 86 | if ((strlen(cmd_str) < 9) || (strncmp(cmd_str, "DL", 2) != 0)) { |
87 | free(cmd_str); | 87 | free(cmd_str); |
88 | return 0; | 88 | return 0; |
89 | } | 89 | } |
@@ -184,7 +184,7 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser | |||
184 | goto leave; | 184 | goto leave; |
185 | } | 185 | } |
186 | device_link_service_get_message(array, &msg); | 186 | device_link_service_get_message(array, &msg); |
187 | if (!msg || strcmp(msg, "DLMessageVersionExchange")) { | 187 | if (!msg || strcmp(msg, "DLMessageVersionExchange") != 0) { |
188 | debug_info("Did not receive DLMessageVersionExchange from device!"); | 188 | debug_info("Did not receive DLMessageVersionExchange from device!"); |
189 | err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; | 189 | err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; |
190 | goto leave; | 190 | goto leave; |
@@ -239,7 +239,7 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser | |||
239 | goto leave; | 239 | goto leave; |
240 | } | 240 | } |
241 | device_link_service_get_message(array, &msg); | 241 | device_link_service_get_message(array, &msg); |
242 | if (!msg || strcmp(msg, "DLMessageDeviceReady")) { | 242 | if (!msg || strcmp(msg, "DLMessageDeviceReady") != 0) { |
243 | debug_info("Did not get DLMessageDeviceReady!"); | 243 | debug_info("Did not get DLMessageDeviceReady!"); |
244 | err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; | 244 | err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; |
245 | goto leave; | 245 | goto leave; |
@@ -403,7 +403,7 @@ device_link_service_error_t device_link_service_receive_process_message(device_l | |||
403 | 403 | ||
404 | char *msg = NULL; | 404 | char *msg = NULL; |
405 | device_link_service_get_message(pmsg, &msg); | 405 | device_link_service_get_message(pmsg, &msg); |
406 | if (!msg || strcmp(msg, "DLMessageProcessMessage")) { | 406 | if (!msg || strcmp(msg, "DLMessageProcessMessage") != 0) { |
407 | debug_info("Did not receive DLMessageProcessMessage as expected!"); | 407 | debug_info("Did not receive DLMessageProcessMessage as expected!"); |
408 | err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; | 408 | err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; |
409 | goto leave; | 409 | goto leave; |
diff --git a/src/file_relay.c b/src/file_relay.c index e304d31..aa77ae6 100644 --- a/src/file_relay.c +++ b/src/file_relay.c | |||
@@ -143,7 +143,7 @@ LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources_timeout(file_ | |||
143 | goto leave; | 143 | goto leave; |
144 | } | 144 | } |
145 | 145 | ||
146 | if (strcmp(ack, "Acknowledged")) { | 146 | if (strcmp(ack, "Acknowledged") != 0) { |
147 | debug_info("ERROR: Did not receive 'Acknowledged' but '%s'", ack); | 147 | debug_info("ERROR: Did not receive 'Acknowledged' but '%s'", ack); |
148 | goto leave; | 148 | goto leave; |
149 | } | 149 | } |
diff --git a/src/lockdown.c b/src/lockdown.c index 1786536..25e8c87 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
@@ -680,7 +680,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi | |||
680 | ret = lockdownd_query_type(client_loc, &type); | 680 | ret = lockdownd_query_type(client_loc, &type); |
681 | if (LOCKDOWN_E_SUCCESS != ret) { | 681 | if (LOCKDOWN_E_SUCCESS != ret) { |
682 | debug_info("QueryType failed in the lockdownd client."); | 682 | debug_info("QueryType failed in the lockdownd client."); |
683 | } else if (strcmp("com.apple.mobile.lockdown", type)) { | 683 | } else if (strcmp("com.apple.mobile.lockdown", type) != 0) { |
684 | debug_info("Warning QueryType request returned \"%s\".", type); | 684 | debug_info("Warning QueryType request returned \"%s\".", type); |
685 | } | 685 | } |
686 | free(type); | 686 | free(type); |
diff --git a/src/mobilesync.c b/src/mobilesync.c index 8881e75..e50226c 100644 --- a/src/mobilesync.c +++ b/src/mobilesync.c | |||
@@ -473,7 +473,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_clear_all_records_on_device(m | |||
473 | goto out; | 473 | goto out; |
474 | } | 474 | } |
475 | 475 | ||
476 | if (strcmp(response_type, "SDMessageDeviceWillClearAllRecords")) { | 476 | if (strcmp(response_type, "SDMessageDeviceWillClearAllRecords") != 0) { |
477 | err = MOBILESYNC_E_PLIST_ERROR; | 477 | err = MOBILESYNC_E_PLIST_ERROR; |
478 | } | 478 | } |
479 | 479 | ||
diff --git a/src/screenshotr.c b/src/screenshotr.c index 11d6506..77835da 100644 --- a/src/screenshotr.c +++ b/src/screenshotr.c | |||
@@ -142,7 +142,7 @@ LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_take_screenshot(screenshotr | |||
142 | plist_t node = plist_dict_get_item(dict, "MessageType"); | 142 | plist_t node = plist_dict_get_item(dict, "MessageType"); |
143 | char *strval = NULL; | 143 | char *strval = NULL; |
144 | plist_get_string_val(node, &strval); | 144 | plist_get_string_val(node, &strval); |
145 | if (!strval || strcmp(strval, "ScreenShotReply")) { | 145 | if (!strval || strcmp(strval, "ScreenShotReply") != 0) { |
146 | debug_info("invalid screenshot data received!"); | 146 | debug_info("invalid screenshot data received!"); |
147 | res = SCREENSHOTR_E_PLIST_ERROR; | 147 | res = SCREENSHOTR_E_PLIST_ERROR; |
148 | goto leave; | 148 | goto leave; |
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 483f3d6..1e512d8 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c | |||
@@ -533,7 +533,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const | |||
533 | for ( i = 0; i < 20; i++, p += 2 ) { | 533 | for ( i = 0; i < 20; i++, p += 2 ) { |
534 | snprintf (p, 3, "%02x", (unsigned char)fnhash[i] ); | 534 | snprintf (p, 3, "%02x", (unsigned char)fnhash[i] ); |
535 | } | 535 | } |
536 | if (strcmp(fnamehash, hash)) { | 536 | if (strcmp(fnamehash, hash) != 0) { |
537 | printf("\r\n"); | 537 | printf("\r\n"); |
538 | printf("WARNING: filename hash does not match for entry '%s'\n", hash); | 538 | printf("WARNING: filename hash does not match for entry '%s'\n", hash); |
539 | } | 539 | } |
@@ -544,7 +544,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const | |||
544 | plist_get_string_val(node, &auth_version); | 544 | plist_get_string_val(node, &auth_version); |
545 | } | 545 | } |
546 | 546 | ||
547 | if (strcmp(auth_version, "1.0")) { | 547 | if (strcmp(auth_version, "1.0") != 0) { |
548 | printf("\r\n"); | 548 | printf("\r\n"); |
549 | printf("WARNING: Unknown AuthVersion '%s', DataHash cannot be verified!\n", auth_version); | 549 | printf("WARNING: Unknown AuthVersion '%s', DataHash cannot be verified!\n", auth_version); |
550 | } | 550 | } |
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c index c30b90e..7c9205f 100644 --- a/tools/idevicedebug.c +++ b/tools/idevicedebug.c | |||
@@ -406,7 +406,7 @@ int main(int argc, char *argv[]) | |||
406 | debugserver_command_free(command); | 406 | debugserver_command_free(command); |
407 | command = NULL; | 407 | command = NULL; |
408 | if (response) { | 408 | if (response) { |
409 | if (strncmp(response, "OK", 2)) { | 409 | if (strncmp(response, "OK", 2) != NULL) { |
410 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 410 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
411 | goto cleanup; | 411 | goto cleanup; |
412 | } | 412 | } |
@@ -423,7 +423,7 @@ int main(int argc, char *argv[]) | |||
423 | debugserver_command_free(command); | 423 | debugserver_command_free(command); |
424 | command = NULL; | 424 | command = NULL; |
425 | if (response) { | 425 | if (response) { |
426 | if (strncmp(response, "OK", 2)) { | 426 | if (strncmp(response, "OK", 2) != NULL) { |
427 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 427 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
428 | goto cleanup; | 428 | goto cleanup; |
429 | } | 429 | } |
@@ -439,7 +439,7 @@ int main(int argc, char *argv[]) | |||
439 | debugserver_command_free(command); | 439 | debugserver_command_free(command); |
440 | command = NULL; | 440 | command = NULL; |
441 | if (response) { | 441 | if (response) { |
442 | if (strncmp(response, "OK", 2)) { | 442 | if (strncmp(response, "OK", 2) != NULL) { |
443 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 443 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
444 | goto cleanup; | 444 | goto cleanup; |
445 | } | 445 | } |
@@ -480,7 +480,7 @@ int main(int argc, char *argv[]) | |||
480 | debugserver_command_free(command); | 480 | debugserver_command_free(command); |
481 | command = NULL; | 481 | command = NULL; |
482 | if (response) { | 482 | if (response) { |
483 | if (strncmp(response, "OK", 2)) { | 483 | if (strncmp(response, "OK", 2) != NULL) { |
484 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 484 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
485 | goto cleanup; | 485 | goto cleanup; |
486 | } | 486 | } |
@@ -514,7 +514,7 @@ int main(int argc, char *argv[]) | |||
514 | debugserver_command_free(command); | 514 | debugserver_command_free(command); |
515 | command = NULL; | 515 | command = NULL; |
516 | if (response) { | 516 | if (response) { |
517 | if (strncmp(response, "OK", 2)) { | 517 | if (strncmp(response, "OK", 2) != NULL) { |
518 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 518 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
519 | goto cleanup; | 519 | goto cleanup; |
520 | } | 520 | } |
@@ -540,7 +540,7 @@ int main(int argc, char *argv[]) | |||
540 | 540 | ||
541 | if (response) { | 541 | if (response) { |
542 | log_debug("response: %s", response); | 542 | log_debug("response: %s", response); |
543 | if (strncmp(response, "OK", 2)) { | 543 | if (strncmp(response, "OK", 2) != NULL) { |
544 | dres = debugserver_client_handle_response(debugserver_client, &response, &res); | 544 | dres = debugserver_client_handle_response(debugserver_client, &response, &res); |
545 | if (dres != DEBUGSERVER_E_SUCCESS) { | 545 | if (dres != DEBUGSERVER_E_SUCCESS) { |
546 | log_debug("failed to process response; error %d; %s", dres, response); | 546 | log_debug("failed to process response; error %d; %s", dres, response); |
@@ -567,7 +567,7 @@ int main(int argc, char *argv[]) | |||
567 | debugserver_command_free(command); | 567 | debugserver_command_free(command); |
568 | command = NULL; | 568 | command = NULL; |
569 | if (response) { | 569 | if (response) { |
570 | if (strncmp(response, "OK", 2)) { | 570 | if (strncmp(response, "OK", 2) != NULL) { |
571 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 571 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
572 | } | 572 | } |
573 | free(response); | 573 | free(response); |
@@ -581,7 +581,7 @@ int main(int argc, char *argv[]) | |||
581 | debugserver_command_free(command); | 581 | debugserver_command_free(command); |
582 | command = NULL; | 582 | command = NULL; |
583 | if (response) { | 583 | if (response) { |
584 | if (strncmp(response, "OK", 2)) { | 584 | if (strncmp(response, "OK", 2) != NULL) { |
585 | debugserver_client_handle_response(debugserver_client, &response, NULL); | 585 | debugserver_client_handle_response(debugserver_client, &response, NULL); |
586 | } | 586 | } |
587 | free(response); | 587 | free(response); |
diff --git a/tools/idevicepair.c b/tools/idevicepair.c index a2dc944..f42f498 100644 --- a/tools/idevicepair.c +++ b/tools/idevicepair.c | |||
@@ -411,7 +411,7 @@ int main(int argc, char **argv) | |||
411 | result = EXIT_FAILURE; | 411 | result = EXIT_FAILURE; |
412 | goto leave; | 412 | goto leave; |
413 | } else { | 413 | } else { |
414 | if (strcmp("com.apple.mobile.lockdown", type)) { | 414 | if (strcmp("com.apple.mobile.lockdown", type) != 0) { |
415 | printf("WARNING: QueryType request returned '%s'\n", type); | 415 | printf("WARNING: QueryType request returned '%s'\n", type); |
416 | } | 416 | } |
417 | free(type); | 417 | free(type); |