From 58c2fb40e767496736810dd0bc34e178bee3e8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?skipzhang=28=E5=BC=A0=E9=87=91=E6=A0=8B=29?= Date: Tue, 21 May 2024 21:11:45 +0800 Subject: [PATCH] fix compile error --- CMakeLists.txt | 1 + src/agentcall.c | 2 +- src/fileexchange.c | 4 ++-- src/pipe.c | 17 +++++++++-------- src/portforward.c | 8 ++++---- src/pty.c | 4 ++-- src/repl.c | 8 ++++---- src/vnet.c | 10 +++++----- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21bba81..6661c9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 2.8) project(termtunnel C) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_C_STANDARD 11) if (CMAKE_HOST_WIN32) set(WINDOWS 1) diff --git a/src/agentcall.c b/src/agentcall.c index 79acb3d..e56f1f3 100644 --- a/src/agentcall.c +++ b/src/agentcall.c @@ -131,7 +131,7 @@ int server_call_agent(int32_t method, char *strbuf) { thread_arg_pass_t *tmp = malloc(sizeof(thread_arg_pass_t)); tmp->method = method; tmp->strbuf = strdup(strbuf); - sys_thread_new("call_send", call_send_request, tmp, DEFAULT_THREAD_STACKSIZE, + sys_thread_new("call_send", (lwip_thread_fn)call_send_request, tmp, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); return 0; } diff --git a/src/fileexchange.c b/src/fileexchange.c index 75212f9..a8eecc4 100644 --- a/src/fileexchange.c +++ b/src/fileexchange.c @@ -172,7 +172,7 @@ int file_send_start(char *src_path, char *dst_path) { // uv_async_send(pe->exchange_notify); } log_info("file_send_start2"); - sys_thread_new("file_send", file_send_request, (void *)pe, + sys_thread_new("file_send", (lwip_thread_fn)file_send_request, (void *)pe, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); return 0; } @@ -217,7 +217,7 @@ int file_recv_start(char *src_path, char *dst_path) { strcpy(pe->src_path, src_path); strcpy(pe->dst_path, dst_path); log_debug("file_recv_start"); - sys_thread_new("file_recv", file_recv_request, (void *)pe, + sys_thread_new("file_recv", (lwip_thread_fn)file_recv_request, (void *)pe, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); return 0; } diff --git a/src/pipe.c b/src/pipe.c index d1cb2cd..39f108d 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -103,7 +103,7 @@ queue_t *q; void uvloop_process_income(uv_async_t *handle) { // log_info("process income queue\n"); frame_data *f; - int dry = handle->data; + size_t dry = (size_t)handle->data; if (!dry) { return; } @@ -139,7 +139,7 @@ int vnet_notify_to_libuv(char *buf, size_t size) { f->len = size; queue_put(q, f); // log_info("add queue"); - data_income_notify.data = 1; // set dry + data_income_notify.data = (void*)1; // set dry int r = uv_async_send(&data_income_notify); return 0; } @@ -151,7 +151,7 @@ int libuv_add_vnet_notify() { return 0; } added = true; - data_income_notify.data = 1; + data_income_notify.data = (void*)1; int r = uv_async_init(uv_default_loop(), &data_income_notify, uvloop_process_income); log_info("libuv_add_vnet_notify %d", r); @@ -377,7 +377,7 @@ void find_a_packet(char *buf, ssize_t len) { } int push_data() { - data_income_notify.data = 1; + data_income_notify.data = (void*)1; return uv_async_send(&data_income_notify); } @@ -451,11 +451,12 @@ void send_exit_message(uv_async_t *handle) { //free(handle); // TODO } -void pty_process_on_exit(int exitcode) { +int pty_process_on_exit(int exitcode) { // TODO 模拟信号错误 // tell client our exitcode. - async_process_exit->data = (int)exitcode; + async_process_exit->data = (void*)exitcode; uv_async_send(async_process_exit); + return 0; } void server(int argc, const char *argv[]) { @@ -532,7 +533,7 @@ int call_bootstrap_get_args(get_args_callback bootstrap_args_ready) { uv_async_t *s = malloc(sizeof(uv_async_t)); uv_async_init(uv_default_loop(), s, (uv_async_cb)bootstrap_args_ready); pthread_t p; - pthread_create(&p, NULL, bootstrap_get_args, s); + pthread_create(&p, NULL, (void*)bootstrap_get_args, s); pthread_detach(p); return 0; } @@ -556,7 +557,7 @@ void server_handle_client_packet(int64_t type, char *buf, ssize_t len) { } case COMMAND_GET_ARGS: { - call_bootstrap_get_args(get_args_done_callback); + call_bootstrap_get_args((void*)get_args_done_callback); //comm_write_packet_to_cli(COMMAND_TTY_PLAIN_DATA, "11", 2); break; } diff --git a/src/portforward.c b/src/portforward.c index a6bfc00..c4ef1a8 100644 --- a/src/portforward.c +++ b/src/portforward.c @@ -244,7 +244,7 @@ int pipe_lwip_socket_and_socket_pair(int lwip_fd, int fd) { *(array) = lwip_fd; *(array + 1) = fd; pthread_t worker2; - pthread_create(&worker2, NULL, &loop_socket_to_lwipsocket, (void *)array); + pthread_create(&worker2, NULL, (void*)&loop_socket_to_lwipsocket, (void *)array); loop_lwipsocket_to_socket((void *)array); pthread_join(worker2, NULL); log_info("lwip ip pair %d %d", lwip_fd, fd); @@ -289,9 +289,9 @@ static void portforward_service_handler(port_listen_t *pe) { child_pe->port = pe->port; child_pe->local_fd = new_sd; if (pe->port == 0) { // socks/http proxy - pthread_create(worker, NULL, &portforward_transparent_server_pipe, (void *)child_pe); + pthread_create(worker, NULL, (void*)&portforward_transparent_server_pipe, (void *)child_pe); } else { - pthread_create(worker, NULL, &portforward_static_server_pipe, (void *)child_pe); + pthread_create(worker, NULL, (void*)&portforward_static_server_pipe, (void *)child_pe); } } else { @@ -354,7 +354,7 @@ int portforward_static_start(char *src_host, uint16_t src_port, char *dst_host, // TODO(jdz) agent监听模式,cli暂时无法获取结果 } - sys_thread_new("portforward_static", portforward_service_handler, (void *)pe, + sys_thread_new("portforward_static", (lwip_thread_fn)portforward_service_handler, (void *)pe, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); return 0; diff --git a/src/pty.c b/src/pty.c index 03a7a42..47c19e6 100644 --- a/src/pty.c +++ b/src/pty.c @@ -99,7 +99,7 @@ int do_waitpid(pid_t childpid) { pid_t wait_id = 0; do { errno = 0; - wait_id = waitpid(childpid, &status, NULL); + wait_id = waitpid(childpid, &status, 0); if (wait_id < 0 && errno == EINTR) { wait_id = 0; @@ -179,7 +179,7 @@ int pty_run(int argc, char *argv[], tell_exitcode_callback *cb) { (thread_pass_arg_t *)malloc(sizeof(thread_pass_arg_t)); temp->cb_func = cb; temp->process_pid = pid; - pthread_create(&thr, NULL, do_waitpid_wrap, temp); + pthread_create(&thr, NULL, (void*)do_waitpid_wrap, temp); pthread_detach(thr); } free(name); diff --git a/src/repl.c b/src/repl.c index ed97cd1..aee3e61 100644 --- a/src/repl.c +++ b/src/repl.c @@ -360,17 +360,17 @@ actionfinder_t action_table[] = { {"local_listen", portforward_func, "port forward bind on local host", "local_listen [local_host] [local_port] [remote_host] [remote_port]\n" "when remote_port==0, the service listen on remote_port will be a " - "socks5+http proxy server.", NULL}, + "socks5+http proxy server.", 0}, {"remote_listen", portforward_func, "port forward bind on remote host", "remote_listen [remote_host] [remote_port] [local_host] [local_port]\n" "when local_port==0, the service listen on remote_port will be a " - "socks5+http proxy server.", NULL}, + "socks5+http proxy server.", 0}, {"upload", upload_func, "upload a file", "usage", FLAG_ONESHOT}, {"rz", upload_func, "alias upload", "usage", FLAG_ONESHOT}, {"download", download_func, "download a file", "usage", FLAG_ONESHOT}, {"sz", download_func, "alias download", "usage", FLAG_ONESHOT}, {"help", help_func, "view help manpage", "usage", FLAG_ONESHOT}, - {"exit", exit_func, "exit application", "usage", NULL}, + {"exit", exit_func, "exit application", "usage", 0}, }; int help_func(int argc, char **argv) { @@ -596,7 +596,7 @@ void interact_run(int _in, int _out) { int cc = read(STDIN_FILENO, ibuf, BUFSIZ); CHECK(cc > 0, "cc>0"); if (cc < 0) { - log_trace("error %s", strerror("read")); + log_trace("read error %s", strerror(errno)); exit(EXIT_FAILURE); } send_binary(_out, COMMAND_TTY_PLAIN_DATA, ibuf, cc); diff --git a/src/vnet.c b/src/vnet.c index 606b50f..422cfe7 100644 --- a/src/vnet.c +++ b/src/vnet.c @@ -326,17 +326,17 @@ void *vnet_init(callback_t cb) { if (get_state_mode() == MODE_AGENT_PROCESS) { // pass - sys_thread_new("file_receiver", file_receiver_start, NULL, + sys_thread_new("file_receiver", (lwip_thread_fn)file_receiver_start, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); - sys_thread_new("file_sender", file_sender_start, NULL, + sys_thread_new("file_sender", (lwip_thread_fn)file_sender_start, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); - sys_thread_new("agentcall_server", agentcall_server_start, NULL, + sys_thread_new("agentcall_server", (lwip_thread_fn)agentcall_server_start, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); } sys_thread_new("portforward_static_server", - portforward_static_remote_server_start, NULL, + (lwip_thread_fn)portforward_static_remote_server_start, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); - sys_thread_new("socksproxy_server", socksproxy_remote_start, NULL, + sys_thread_new("socksproxy_server", (lwip_thread_fn)socksproxy_remote_start, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); return &g_netif;