From 847182cdf1a4fd3cf2f6cecac53ab12e138347e7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 6 Jan 2013 21:50:00 +0100 Subject: [PATCH] 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. --- test/benchmark-getaddrinfo.c | 2 +- test/benchmark-pump.c | 12 +++--------- test/benchmark-spawn.c | 10 +++++----- test/dns-server.c | 15 ++++++++++++--- test/test-async.c | 2 +- test/test-connection-fail.c | 2 +- test/test-fs.c | 2 +- test/test-ipc.c | 2 +- test/test-shutdown-eof.c | 6 +++--- test/test-spawn.c | 4 ++-- test/test-stdio-over-pipes.c | 3 ++- 11 files changed, 32 insertions(+), 28 deletions(-) diff --git a/test/benchmark-getaddrinfo.c b/test/benchmark-getaddrinfo.c index 8ee0c50a..4a57b441 100644 --- a/test/benchmark-getaddrinfo.c +++ b/test/benchmark-getaddrinfo.c @@ -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; diff --git a/test/benchmark-pump.c b/test/benchmark-pump.c index 8ad9f4fa..bf81c4f8 100644 --- a/test/benchmark-pump.c +++ b/test/benchmark-pump.c @@ -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; diff --git a/test/benchmark-spawn.c b/test/benchmark-spawn.c index b78fd7e8..ca0e8569 100644 --- a/test/benchmark-spawn.c +++ b/test/benchmark-spawn.c @@ -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) { diff --git a/test/dns-server.c b/test/dns-server.c index e541e781..f89c3bcf 100644 --- a/test/dns-server.c +++ b/test/dns-server.c @@ -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) { diff --git a/test/test-async.c b/test/test-async.c index 26194a1f..6ab510bf 100644 --- a/test/test-async.c +++ b/test/test-async.c @@ -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; diff --git a/test/test-connection-fail.c b/test/test-connection-fail.c index 4219f4c6..d5cd82b2 100644 --- a/test/test-connection-fail.c +++ b/test/test-connection-fail.c @@ -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; diff --git a/test/test-fs.c b/test/test-fs.c index 597ef971..ccf7793b 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -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; diff --git a/test/test-ipc.c b/test/test-ipc.c index ff71b0ab..3bdc8ea8 100644 --- a/test/test-ipc.c +++ b/test/test-ipc.c @@ -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) { diff --git a/test/test-shutdown-eof.c b/test/test-shutdown-eof.c index 22f6da53..6e55a7de 100644 --- a/test/test-shutdown-eof.c +++ b/test/test-shutdown-eof.c @@ -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); diff --git a/test/test-spawn.c b/test/test-spawn.c index 48ab239b..c97595f1 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -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); } diff --git a/test/test-stdio-over-pipes.c b/test/test-stdio-over-pipes.c index d412dd6f..c0028eec 100644 --- a/test/test-stdio-over-pipes.c +++ b/test/test-stdio-over-pipes.c @@ -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];