diff options
author | Rosen Penev | 2020-12-23 17:39:01 -0800 |
---|---|---|
committer | Nikias Bassen | 2022-04-30 13:34:21 +0200 |
commit | cf2c7d48380969200034afeab93169e68c34c397 (patch) | |
tree | a96f518be279922d00898a3ce81dc0ff483a40b2 /tools | |
parent | 6cb13f9e6d3939930aecf91d8e23d1896a3b92e5 (diff) | |
download | libimobiledevice-cf2c7d48380969200034afeab93169e68c34c397.tar.gz libimobiledevice-cf2c7d48380969200034afeab93169e68c34c397.tar.bz2 |
[clang-tidy] Do not use else after return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/idevicebackup.c | 13 | ||||
-rw-r--r-- | tools/idevicebackup2.c | 28 | ||||
-rw-r--r-- | tools/idevicecrashreport.c | 6 | ||||
-rw-r--r-- | tools/ideviceprovision.c | 4 | ||||
-rw-r--r-- | tools/idevicesyslog.c | 22 |
5 files changed, 40 insertions, 33 deletions
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[]) if (aerr == AFC_E_SUCCESS) { do_post_notification(NP_SYNC_DID_START); break; - } else if (aerr == AFC_E_OP_WOULD_BLOCK) { + } + if (aerr == AFC_E_OP_WOULD_BLOCK) { usleep(LOCK_WAIT); continue; - } else { - fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr); - afc_file_close(afc, lockfile); - lockfile = 0; - cmd = CMD_LEAVE; } + + fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr); + afc_file_close(afc, lockfile); + lockfile = 0; + cmd = CMD_LEAVE; } if (i == LOCK_ATTEMPTS) { 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) if (!dir) return -1; if (__mkdir(dir, mode) == 0) { return 0; - } else { - if (errno == EEXIST) return 0; } + if (errno == EEXIST) return 0; int res; char *parent = strdup(dir); char *parentdir = dirname(parent); @@ -973,10 +972,12 @@ static int mb2_receive_filename(mobilebackup2_client_t mobilebackup2, char** fil if ((nlen == 0) && (rlen == 4)) { // a zero length means no more files to receive return 0; - } else if(rlen == 0) { + } + if (rlen == 0) { // device needs more time, waiting... continue; - } else if (nlen > 4096) { + } + if (nlen > 4096) { // filename length is too large printf("ERROR: %s: too large filename length (%d)!\n", __func__, nlen); return 0; @@ -1368,7 +1369,8 @@ static void get_hidden_input(char *buf, int maxlen) while ((c = my_getch())) { if ((c == '\r') || (c == '\n')) { break; - } else if (isprint(c)) { + } + if (isprint(c)) { if (pwlen < maxlen-1) buf[pwlen++] = c; fputc('*', stderr); @@ -1961,15 +1963,16 @@ int main(int argc, char *argv[]) if (aerr == AFC_E_SUCCESS) { do_post_notification(device, NP_SYNC_DID_START); break; - } else if (aerr == AFC_E_OP_WOULD_BLOCK) { + } + if (aerr == AFC_E_OP_WOULD_BLOCK) { usleep(LOCK_WAIT); continue; - } else { - fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr); - afc_file_close(afc, lockfile); - lockfile = 0; - cmd = CMD_LEAVE; } + + fprintf(stderr, "ERROR: could not lock file! error code: %d\n", aerr); + afc_file_close(afc, lockfile); + lockfile = 0; + cmd = CMD_LEAVE; } if (i == LOCK_ATTEMPTS) { fprintf(stderr, "ERROR: timeout while locking for sync\n"); @@ -2103,9 +2106,8 @@ checkpoint: if (write_restore_applications(info_plist, afc) < 0) { cmd = CMD_LEAVE; break; - } else { - PRINT_VERBOSE(1, "Wrote RestoreApplications.plist\n"); } + PRINT_VERBOSE(1, "Wrote RestoreApplications.plist\n"); } /* 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[]) if (service_error == SERVICE_E_SUCCESS || service_error == SERVICE_E_TIMEOUT) { attempts++; continue; - } else { - fprintf(stderr, "ERROR: Crash logs could not be moved. Connection interrupted (%d).\n", service_error); - break; } + + fprintf(stderr, "ERROR: Crash logs could not be moved. Connection interrupted (%d).\n", service_error); + break; } service_client_free(svcmove); 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[]) plist_free(pl); return res; - } else if (op == OP_COPY) { + } + + if (op == OP_COPY) { struct stat st; const char *checkdir = (param2) ? param2 : param; 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) shall_print = 1; cprintf(COLOR_WHITE); break; - } else if (line[3] == ' ' && line[6] == ' ' && line[15] == ' ') { + } + + if (line[3] == ' ' && line[6] == ' ' && line[15] == ' ') { char* end = &line[lp]; char* p = &line[16]; @@ -190,10 +192,9 @@ static void syslog_callback(char c, void *user_data) if (!found) { shall_print = 0; break; - } else { - triggered = 1; - shall_print = 1; } + triggered = 1; + shall_print = 1; } else if (num_trigger_filters == 0 && num_untrigger_filters > 0 && !triggered) { shall_print = 0; quit_flag++; @@ -213,9 +214,8 @@ static void syslog_callback(char c, void *user_data) if (!found) { shall_print = 0; break; - } else { - shall_print = 1; } + shall_print = 1; } /* process name */ @@ -430,7 +430,8 @@ static void device_event_cb(const idevice_event_t* event, void* userdata) { if (use_network && event->conn_type != CONNECTION_NETWORK) { return; - } else if (!use_network && event->conn_type != CONNECTION_USBMUXD) { + } + if (!use_network && event->conn_type != CONNECTION_USBMUXD) { return; } if (event->event == IDEVICE_DEVICE_ADD) { @@ -656,7 +657,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "ERROR: -p and -e/-q cannot be used together.\n"); print_usage(argc, argv, 1); return 2; - } else if (include_filter > 0 && exclude_kernel > 0) { + } + if (include_filter > 0 && exclude_kernel > 0) { fprintf(stderr, "ERROR: -p and -K cannot be used together.\n"); print_usage(argc, argv, 1); return 2; @@ -699,9 +701,9 @@ int main(int argc, char *argv[]) if (!udid) { fprintf(stderr, "No device found. Plug in a device or pass UDID with -u to wait for device to be available.\n"); return -1; - } else { - fprintf(stderr, "Waiting for device with UDID %s to become available...\n", udid); } + + fprintf(stderr, "Waiting for device with UDID %s to become available...\n", udid); } line_buffer_size = 1024; |