diff options
author | Rosen Penev | 2020-06-03 15:46:25 -0700 |
---|---|---|
committer | Nikias Bassen | 2020-12-30 02:47:55 +0100 |
commit | e7168f30e6fdf0a1f9cffdc9252f52d45e5a59ef (patch) | |
tree | c406fb3830f2079a47918d4b85305a768955c591 /tools | |
parent | 98f6e62c6d397c54987bc627e3171363f3c74116 (diff) | |
download | libusbmuxd-e7168f30e6fdf0a1f9cffdc9252f52d45e5a59ef.tar.gz libusbmuxd-e7168f30e6fdf0a1f9cffdc9252f52d45e5a59ef.tar.bz2 |
Do not use else after return or break for better code readability
[clang-tidy] Found with readability-else-after-return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inetcat.c | 3 | ||||
-rw-r--r-- | tools/iproxy.c | 40 |
2 files changed, 22 insertions, 21 deletions
diff --git a/tools/inetcat.c b/tools/inetcat.c index 1674c81..59c18b2 100644 --- a/tools/inetcat.c +++ b/tools/inetcat.c @@ -197,7 +197,8 @@ int main(int argc, char **argv) if (dev_list[i].conn_type == CONNECTION_TYPE_USB && (lookup_opts & DEVICE_LOOKUP_USBMUX)) { dev = &(dev_list[i]); break; - } else if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK && (lookup_opts & DEVICE_LOOKUP_NETWORK)) { + } + if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK && (lookup_opts & DEVICE_LOOKUP_NETWORK)) { dev = &(dev_list[i]); break; } diff --git a/tools/iproxy.c b/tools/iproxy.c index 28fcb46..5dca580 100644 --- a/tools/iproxy.c +++ b/tools/iproxy.c @@ -112,7 +112,8 @@ static void *acceptor_thread(void *arg) if (dev_list[i].conn_type == CONNECTION_TYPE_USB && (cdata->lookup_opts & DEVICE_LOOKUP_USBMUX)) { dev = &(dev_list[i]); break; - } else if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK && (cdata->lookup_opts & DEVICE_LOOKUP_NETWORK)) { + } + if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK && (cdata->lookup_opts & DEVICE_LOOKUP_NETWORK)) { dev = &(dev_list[i]); break; } @@ -459,28 +460,27 @@ int main(int argc, char **argv) if (c_sock < 0) { fprintf(stderr, "accept: %s\n", strerror(errno)); break; - } else { - printf("New connection for %d->%d, fd = %d\n", listen_port[listen_sock[i].index], device_port[listen_sock[i].index], c_sock); - cdata = (struct client_data*)malloc(sizeof(struct client_data)); - if (!cdata) { - socket_close(c_sock); - fprintf(stderr, "ERROR: Out of memory\n"); - free(device_udid); - return -1; - } - cdata->fd = c_sock; - cdata->sfd = -1; - cdata->udid = (device_udid) ? strdup(device_udid) : NULL; - cdata->lookup_opts = lookup_opts; - cdata->device_port = device_port[listen_sock[i].index]; + } + printf("New connection for %d->%d, fd = %d\n", listen_port[listen_sock[i].index], device_port[listen_sock[i].index], c_sock); + cdata = (struct client_data*)malloc(sizeof(struct client_data)); + if (!cdata) { + socket_close(c_sock); + fprintf(stderr, "ERROR: Out of memory\n"); + free(device_udid); + return -1; + } + cdata->fd = c_sock; + cdata->sfd = -1; + cdata->udid = (device_udid) ? strdup(device_udid) : NULL; + cdata->lookup_opts = lookup_opts; + cdata->device_port = device_port[listen_sock[i].index]; #ifdef WIN32 - acceptor = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)acceptor_thread, cdata, 0, NULL); - CloseHandle(acceptor); + acceptor = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)acceptor_thread, cdata, 0, NULL); + CloseHandle(acceptor); #else - pthread_create(&acceptor, NULL, acceptor_thread, cdata); - pthread_detach(acceptor); + pthread_create(&acceptor, NULL, acceptor_thread, cdata); + pthread_detach(acceptor); #endif - } } } } |