Skip to content
This repository
Browse code

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.
  • Loading branch information...
commit 847182cdf1a4fd3cf2f6cecac53ab12e138347e7 1 parent 7ff6f29
Ben Noordhuis bnoordhuis authored
2  test/benchmark-getaddrinfo.c
@@ -26,7 +26,7 @@
26 26 #define CONCURRENT_CALLS 10
27 27 #define TOTAL_CALLS 10000
28 28
29   -const char* name = "localhost";
  29 +static const char* name = "localhost";
30 30
31 31 static uv_loop_t* loop;
32 32
12 test/benchmark-pump.c
@@ -129,13 +129,7 @@ static void read_show_stats(void) {
129 129
130 130
131 131
132   -void write_sockets_close_cb(uv_handle_t* handle) {
133   - /* If any client closes, the process is done. */
134   - exit(0);
135   -}
136   -
137   -
138   -void read_sockets_close_cb(uv_handle_t* handle) {
  132 +static void read_sockets_close_cb(uv_handle_t* handle) {
139 133 free(handle);
140 134 read_sockets--;
141 135
@@ -407,7 +401,7 @@ HELPER_IMPL(pipe_pump_server) {
407 401 }
408 402
409 403
410   -void tcp_pump(int n) {
  404 +static void tcp_pump(int n) {
411 405 ASSERT(n <= MAX_WRITE_HANDLES);
412 406 TARGET_CONNECTIONS = n;
413 407 type = TCP;
@@ -425,7 +419,7 @@ void tcp_pump(int n) {
425 419 }
426 420
427 421
428   -void pipe_pump(int n) {
  422 +static void pipe_pump(int n) {
429 423 ASSERT(n <= MAX_WRITE_HANDLES);
430 424 TARGET_CONNECTIONS = n;
431 425 type = PIPE;
10 test/benchmark-spawn.c
@@ -44,10 +44,10 @@ static int process_open;
44 44 static int pipe_open;
45 45
46 46
47   -static void spawn();
  47 +static void spawn(void);
48 48
49 49
50   -void maybe_spawn() {
  50 +static void maybe_spawn(void) {
51 51 if (process_open == 0 && pipe_open == 0) {
52 52 done++;
53 53 if (done < N) {
@@ -71,7 +71,7 @@ static void exit_cb(uv_process_t* process, int exit_status, int term_signal) {
71 71 }
72 72
73 73
74   -uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
  74 +static uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
75 75 uv_buf_t buf;
76 76 buf.base = output + output_used;
77 77 buf.len = OUTPUT_SIZE - output_used;
@@ -79,14 +79,14 @@ uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
79 79 }
80 80
81 81
82   -void pipe_close_cb(uv_handle_t* pipe) {
  82 +static void pipe_close_cb(uv_handle_t* pipe) {
83 83 ASSERT(pipe_open == 1);
84 84 pipe_open = 0;
85 85 maybe_spawn();
86 86 }
87 87
88 88
89   -void on_read(uv_stream_t* pipe, ssize_t nread, uv_buf_t buf) {
  89 +static void on_read(uv_stream_t* pipe, ssize_t nread, uv_buf_t buf) {
90 90 uv_err_t err = uv_last_error(loop);
91 91
92 92 if (nread > 0) {
15 test/dns-server.c
@@ -63,9 +63,18 @@ static void on_connection(uv_stream_t*, int status);
63 63
64 64 #define LEN_OFFSET 0
65 65 #define QUERYID_OFFSET 2
66   -unsigned char DNSRsp[] = {0, 43, 0, 0, 0x81, 0x80, 0, 1, 0, 1, 0, 0, 0, 0 };
67   -unsigned char qrecord[] = {5, 'e', 'c', 'h', 'o', 's', 3, 's', 'r', 'v', 0, 0, 1, 0, 1};
68   -unsigned char arecord[] = {0xc0, 0x0c, 0, 1, 0, 1, 0, 0, 5, 0xbd, 0, 4, 10, 0, 1, 1 };
  66 +
  67 +static unsigned char DNSRsp[] = {
  68 + 0, 43, 0, 0, 0x81, 0x80, 0, 1, 0, 1, 0, 0, 0, 0
  69 +};
  70 +
  71 +static unsigned char qrecord[] = {
  72 + 5, 'e', 'c', 'h', 'o', 's', 3, 's', 'r', 'v', 0, 0, 1, 0, 1
  73 +};
  74 +
  75 +static unsigned char arecord[] = {
  76 + 0xc0, 0x0c, 0, 1, 0, 1, 0, 0, 5, 0xbd, 0, 4, 10, 0, 1, 1
  77 +};
69 78
70 79
71 80 static void after_write(uv_write_t* req, int status) {
2  test/test-async.c
@@ -35,7 +35,7 @@ static int prepare_cb_called;
35 35 static int close_cb_called;
36 36
37 37
38   -void thread_cb(void *arg) {
  38 +static void thread_cb(void *arg) {
39 39 int n;
40 40 int r;
41 41
2  test/test-connection-fail.c
@@ -88,7 +88,7 @@ static void on_connect_without_close(uv_connect_t *req, int status) {
88 88 }
89 89
90 90
91   -void connection_fail(uv_connect_cb connect_cb) {
  91 +static void connection_fail(uv_connect_cb connect_cb) {
92 92 struct sockaddr_in client_addr, server_addr;
93 93 int r;
94 94
2  test/test-fs.c
@@ -104,7 +104,7 @@ static char buf[32];
104 104 static char test_buf[] = "test-buffer\n";
105 105
106 106
107   -void check_permission(const char* filename, int mode) {
  107 +static void check_permission(const char* filename, int mode) {
108 108 int r;
109 109 uv_fs_t req;
110 110 struct stat* s;
2  test/test-ipc.c
@@ -406,7 +406,7 @@ TEST_IMPL(listen_no_simultaneous_accepts) {
406 406
407 407 /* Everything here runs in a child process. */
408 408
409   -tcp_conn conn;
  409 +static tcp_conn conn;
410 410
411 411
412 412 static void close_cb(uv_handle_t* handle) {
6 test/test-shutdown-eof.c
@@ -110,7 +110,7 @@ static void connect_cb(uv_connect_t *req, int status) {
110 110 }
111 111
112 112
113   -void tcp_close_cb(uv_handle_t* handle) {
  113 +static void tcp_close_cb(uv_handle_t* handle) {
114 114 ASSERT(handle == (uv_handle_t*) &tcp);
115 115
116 116 ASSERT(called_connect_cb == 1);
@@ -122,13 +122,13 @@ void tcp_close_cb(uv_handle_t* handle) {
122 122 }
123 123
124 124
125   -void timer_close_cb(uv_handle_t* handle) {
  125 +static void timer_close_cb(uv_handle_t* handle) {
126 126 ASSERT(handle == (uv_handle_t*) &timer);
127 127 called_timer_close_cb++;
128 128 }
129 129
130 130
131   -void timer_cb(uv_timer_t* handle, int status) {
  131 +static void timer_cb(uv_timer_t* handle, int status) {
132 132 ASSERT(handle == &timer);
133 133 uv_close((uv_handle_t*) handle, timer_close_cb);
134 134
4 test/test-spawn.c
@@ -106,7 +106,7 @@ static uv_buf_t on_alloc(uv_handle_t* handle, size_t suggested_size) {
106 106 }
107 107
108 108
109   -void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
  109 +static void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
110 110 uv_err_t err = uv_last_error(uv_default_loop());
111 111
112 112 if (nread > 0) {
@@ -118,7 +118,7 @@ void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) {
118 118 }
119 119
120 120
121   -void write_cb(uv_write_t* req, int status) {
  121 +static void write_cb(uv_write_t* req, int status) {
122 122 ASSERT(status == 0);
123 123 uv_close((uv_handle_t*)req->handle, close_cb);
124 124 }
3  test/test-stdio-over-pipes.c
@@ -34,7 +34,8 @@ static int close_cb_called;
34 34 static int exit_cb_called;
35 35 static int on_read_cb_called;
36 36 static int after_write_cb_called;
37   -uv_pipe_t out, in;
  37 +static uv_pipe_t in;
  38 +static uv_pipe_t out;
38 39 static uv_loop_t* loop;
39 40 #define OUTPUT_SIZE 1024
40 41 static char output[OUTPUT_SIZE];

0 comments on commit 847182c

Please sign in to comment.
Something went wrong with that request. Please try again.