diff options
author | Roger Dingledine <arma@torproject.org> | 2003-09-27 07:28:44 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-09-27 07:28:44 +0000 |
commit | deac70439953008450fd1c17cad12c2a78a7c04b (patch) | |
tree | fe5f84e1bcdd9259ccac9ac2a3f47580cfe57287 /src | |
parent | 9899e09b3b0d8249ba1edd97153a46a4e0c4dea3 (diff) | |
download | tor-deac70439953008450fd1c17cad12c2a78a7c04b.tar tor-deac70439953008450fd1c17cad12c2a78a7c04b.tar.gz |
connection_new() can't ever fail
svn:r497
Diffstat (limited to 'src')
-rw-r--r-- | src/or/buffers.c | 2 | ||||
-rw-r--r-- | src/or/connection.c | 13 | ||||
-rw-r--r-- | src/or/connection_edge.c | 4 | ||||
-rw-r--r-- | src/or/connection_or.c | 4 | ||||
-rw-r--r-- | src/or/cpuworker.c | 4 | ||||
-rw-r--r-- | src/or/directory.c | 2 | ||||
-rw-r--r-- | src/or/dns.c | 4 |
7 files changed, 3 insertions, 30 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index e23270e85..eba73a233 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -44,7 +44,7 @@ int find_on_inbuf(char *string, int string_len, buf_t *buf) { /* Create and return a new buf of size 'size' */ -buf_t *buf_new_with_capacity(size_t size) { +static buf_t *buf_new_with_capacity(size_t size) { buf_t *buf; buf = (buf_t*)tor_malloc(sizeof(buf_t)); buf->buf = (char *)tor_malloc(size); diff --git a/src/or/connection.c b/src/or/connection.c index 79125d774..4ca535e12 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -80,9 +80,8 @@ connection_t *connection_new(int type) { memset(conn,0,sizeof(connection_t)); /* zero it out to start */ conn->type = type; - if(!(conn->inbuf = buf_new()) || - !(conn->outbuf = buf_new())) - return NULL; + conn->inbuf = buf_new(); + conn->outbuf = buf_new(); conn->receiver_bucket = 50000; /* should be enough to do the handshake */ conn->bandwidth = conn->receiver_bucket / 10; /* give it a default */ @@ -149,10 +148,6 @@ int connection_create_listener(struct sockaddr_in *bindaddr, int type) { set_socket_nonblocking(s); conn = connection_new(type); - if(!conn) { - log_fn(LOG_WARNING,"connection_new failed. Giving up."); - return -1; - } conn->s = s; conn->receiver_bucket = -1; /* non-cell connections don't do receiver buckets */ conn->bandwidth = -1; @@ -200,10 +195,6 @@ int connection_handle_listener_read(connection_t *conn, int new_type) { set_socket_nonblocking(news); newconn = connection_new(new_type); - if(!newconn) { - log_fn(LOG_WARNING,"connection_new failed. Giving up."); - return 0; - } newconn->s = news; if(!connection_speaks_cells(newconn)) { diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index ee4c0dd0a..1e4b91a50 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -548,10 +548,6 @@ static int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) { log_fn(LOG_DEBUG,"Creating new exit connection."); n_stream = connection_new(CONN_TYPE_EXIT); - if(!n_stream) { - log_fn(LOG_WARNING,"connection_new failed. Dropping."); - return 0; - } memcpy(n_stream->stream_id, cell->payload + RELAY_HEADER_SIZE, STREAM_ID_SIZE); n_stream->address = strdup(cell->payload + RELAY_HEADER_SIZE + STREAM_ID_SIZE); diff --git a/src/or/connection_or.c b/src/or/connection_or.c index bdee553bb..6e31966dc 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -104,10 +104,6 @@ connection_t *connection_or_connect(routerinfo_t *router) { return conn; conn = connection_new(CONN_TYPE_OR); - if(!conn) { - log_fn(LOG_WARNING,"connection_new failed; skipping."); - return NULL; - } /* set up conn so it's got all the data we need to remember */ connection_or_init_conn_from_router(conn, router); diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index b67e4ca8f..4d3764798 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -179,10 +179,6 @@ static int spawn_cpuworker(void) { close(fd[1]); /* we don't need the worker's side of the pipe */ conn = connection_new(CONN_TYPE_CPUWORKER); - if(!conn) { - close(fd[0]); - return -1; - } set_socket_nonblocking(fd[0]); diff --git a/src/or/directory.c b/src/or/directory.c index 898e79c6c..c410821e0 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -43,8 +43,6 @@ void directory_initiate_command(routerinfo_t *router, int command) { log_fn(LOG_DEBUG,"initiating directory upload"); conn = connection_new(CONN_TYPE_DIR); - if(!conn) - return; /* set up conn so it's got all the data we need to remember */ conn->addr = router->addr; diff --git a/src/or/dns.c b/src/or/dns.c index f10b3f7e9..1b955cc00 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -382,10 +382,6 @@ static int spawn_dnsworker(void) { close(fd[1]); /* we don't need the worker's side of the pipe */ conn = connection_new(CONN_TYPE_DNSWORKER); - if(!conn) { - close(fd[0]); - return -1; - } set_socket_nonblocking(fd[0]); |