mirror of
https://github.com/libuv/libuv
synced 2025-03-28 21:13:16 +00:00
test, bench: make functions/variables static
Make functions and variables that are local to the compilation unit static. Remove what turns out to be unused.
This commit is contained in:
parent
7ff6f29b85
commit
847182cdf1
@ -26,7 +26,7 @@
|
||||
#define CONCURRENT_CALLS 10
|
||||
#define TOTAL_CALLS 10000
|
||||
|
||||
const char* name = "localhost";
|
||||
static const char* name = "localhost";
|
||||
|
||||
static uv_loop_t* loop;
|
||||
|
||||
|
@ -129,13 +129,7 @@ static void read_show_stats(void) {
|
||||
|
||||
|
||||
|
||||
void write_sockets_close_cb(uv_handle_t* handle) {
|
||||
/* If any client closes, the process is done. */
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void read_sockets_close_cb(uv_handle_t* handle) {
|
||||
static void read_sockets_close_cb(uv_handle_t* handle) {
|
||||
free(handle);
|
||||
read_sockets--;
|
||||
|
||||
@ -407,7 +401,7 @@ HELPER_IMPL(pipe_pump_server) {
|
||||
}
|
||||
|
||||
|
||||
void tcp_pump(int n) {
|
||||
static void tcp_pump(int n) {
|
||||
ASSERT(n <= MAX_WRITE_HANDLES);
|
||||
TARGET_CONNECTIONS = n;
|
||||
type = TCP;
|
||||
@ -425,7 +419,7 @@ void tcp_pump(int n) {
|
||||
}
|
||||
|
||||
|
||||
void pipe_pump(int n) {
|
||||
static void pipe_pump(int n) {
|
||||
ASSERT(n <= MAX_WRITE_HANDLES);
|
||||
TARGET_CONNECTIONS = n;
|
||||
type = PIPE;
|
||||
|
@ -44,10 +44,10 @@ static int process_open;
|
||||
static int pipe_open;
|
||||
|
||||
|
||||
static void spawn();
|
||||
static void spawn(void);
|
||||
|
||||
|
||||
void maybe_spawn() {
|
||||
static void maybe_spawn(void) {
|
||||
if (process_open == 0 && pipe_open == 0) {
|
||||
done++;
|
||||
if (done < N) {
|
||||
@ -71,7 +71,7 @@ static void exit_cb(uv_process_t* process, int exit_status, int term_signal) {
|
||||
}
|
||||
|
||||
|
||||
uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
|
||||
static uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
|
||||
uv_buf_t buf;
|
||||
buf.base = output + output_used;
|
||||
buf.len = OUTPUT_SIZE - output_used;
|
||||
@ -79,14 +79,14 @@ uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
|
||||
}
|
||||
|
||||
|
||||
void pipe_close_cb(uv_handle_t* pipe) {
|
||||
static void pipe_close_cb(uv_handle_t* pipe) {
|
||||
ASSERT(pipe_open == 1);
|
||||
pipe_open = 0;
|
||||
maybe_spawn();
|
||||
}
|
||||
|
||||
|
||||
void on_read(uv_stream_t* pipe, ssize_t nread, uv_buf_t buf) {
|
||||
static void on_read(uv_stream_t* pipe, ssize_t nread, uv_buf_t buf) {
|
||||
uv_err_t err = uv_last_error(loop);
|
||||
|
||||
if (nread > 0) {
|
||||
|
@ -63,9 +63,18 @@ static void on_connection(uv_stream_t*, int status);
|
||||
|
||||
#define LEN_OFFSET 0
|
||||
#define QUERYID_OFFSET 2
|
||||
unsigned char DNSRsp[] = {0, 43, 0, 0, 0x81, 0x80, 0, 1, 0, 1, 0, 0, 0, 0 };
|
||||
unsigned char qrecord[] = {5, 'e', 'c', 'h', 'o', 's', 3, 's', 'r', 'v', 0, 0, 1, 0, 1};
|
||||
unsigned char arecord[] = {0xc0, 0x0c, 0, 1, 0, 1, 0, 0, 5, 0xbd, 0, 4, 10, 0, 1, 1 };
|
||||
|
||||
static unsigned char DNSRsp[] = {
|
||||
0, 43, 0, 0, 0x81, 0x80, 0, 1, 0, 1, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static unsigned char qrecord[] = {
|
||||
5, 'e', 'c', 'h', 'o', 's', 3, 's', 'r', 'v', 0, 0, 1, 0, 1
|
||||
};
|
||||
|
||||
static unsigned char arecord[] = {
|
||||
0xc0, 0x0c, 0, 1, 0, 1, 0, 0, 5, 0xbd, 0, 4, 10, 0, 1, 1
|
||||
};
|
||||
|
||||
|
||||
static void after_write(uv_write_t* req, int status) {
|
||||
|
@ -35,7 +35,7 @@ static int prepare_cb_called;
|
||||
static int close_cb_called;
|
||||
|
||||
|
||||
void thread_cb(void *arg) {
|
||||
static void thread_cb(void *arg) {
|
||||
int n;
|
||||
int r;
|
||||
|
||||
|
@ -88,7 +88,7 @@ static void on_connect_without_close(uv_connect_t *req, int status) {
|
||||
}
|
||||
|
||||
|
||||
void connection_fail(uv_connect_cb connect_cb) {
|
||||
static void connection_fail(uv_connect_cb connect_cb) {
|
||||
struct sockaddr_in client_addr, server_addr;
|
||||
int r;
|
||||
|
||||
|
@ -104,7 +104,7 @@ static char buf[32];
|
||||
static char test_buf[] = "test-buffer\n";
|
||||
|
||||
|
||||
void check_permission(const char* filename, int mode) {
|
||||
static void check_permission(const char* filename, int mode) {
|
||||
int r;
|
||||
uv_fs_t req;
|
||||
struct stat* s;
|
||||
|
@ -406,7 +406,7 @@ TEST_IMPL(listen_no_simultaneous_accepts) {
|
||||
|
||||
/* Everything here runs in a child process. */
|
||||
|
||||
tcp_conn conn;
|
||||
static tcp_conn conn;
|
||||
|
||||
|
||||
static void close_cb(uv_handle_t* handle) {
|
||||
|
@ -110,7 +110,7 @@ static void connect_cb(uv_connect_t *req, int status) {
|
||||
}
|
||||
|
||||
|
||||
void tcp_close_cb(uv_handle_t* handle) {
|
||||
static void tcp_close_cb(uv_handle_t* handle) {
|
||||
ASSERT(handle == (uv_handle_t*) &tcp);
|
||||
|
||||
ASSERT(called_connect_cb == 1);
|
||||
@ -122,13 +122,13 @@ void tcp_close_cb(uv_handle_t* handle) {
|
||||
}
|
||||
|
||||
|
||||
void timer_close_cb(uv_handle_t* handle) {
|
||||
static void timer_close_cb(uv_handle_t* handle) {
|
||||
ASSERT(handle == (uv_handle_t*) &timer);
|
||||
called_timer_close_cb++;
|
||||
}
|
||||
|
||||
|
||||
void timer_cb(uv_timer_t* handle, int status) {
|
||||
static void timer_cb(uv_timer_t* handle, int status) {
|
||||
ASSERT(handle == &timer);
|
||||
uv_close((uv_handle_t*) handle, timer_close_cb);
|
||||
|
||||
|
@ -106,7 +106,7 @@ static uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
|
||||
}
|
||||
|
||||
|
||||
void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
|
||||
static void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
|
||||
uv_err_t err = uv_last_error(uv_default_loop());
|
||||
|
||||
if (nread > 0) {
|
||||
@ -118,7 +118,7 @@ void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
|
||||
}
|
||||
|
||||
|
||||
void write_cb(uv_write_t* req, int status) {
|
||||
static void write_cb(uv_write_t* req, int status) {
|
||||
ASSERT(status == 0);
|
||||
uv_close((uv_handle_t*)req->handle, close_cb);
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ static int close_cb_called;
|
||||
static int exit_cb_called;
|
||||
static int on_read_cb_called;
|
||||
static int after_write_cb_called;
|
||||
uv_pipe_t out, in;
|
||||
static uv_pipe_t in;
|
||||
static uv_pipe_t out;
|
||||
static uv_loop_t* loop;
|
||||
#define OUTPUT_SIZE 1024
|
||||
static char output[OUTPUT_SIZE];
|
||||
|
Loading…
x
Reference in New Issue
Block a user