mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Normalize a few more kinds of whitespace. We now dislike:
- func (args) - if (x){ This doesn't normalize if(x), for(x); while(x), and friends. svn:r2943
This commit is contained in:
parent
fe32c2d141
commit
22dba27d8d
@ -239,9 +239,9 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
|
|||||||
listener = socket(AF_INET, type, 0);
|
listener = socket(AF_INET, type, 0);
|
||||||
if (listener == -1)
|
if (listener == -1)
|
||||||
return -1;
|
return -1;
|
||||||
memset (&listen_addr, 0, sizeof (listen_addr));
|
memset(&listen_addr, 0, sizeof(listen_addr));
|
||||||
listen_addr.sin_family = AF_INET;
|
listen_addr.sin_family = AF_INET;
|
||||||
listen_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
listen_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||||
listen_addr.sin_port = 0; /* kernel choses port. */
|
listen_addr.sin_port = 0; /* kernel choses port. */
|
||||||
if (bind(listener, (struct sockaddr *) &listen_addr, sizeof (listen_addr))
|
if (bind(listener, (struct sockaddr *) &listen_addr, sizeof (listen_addr))
|
||||||
== -1)
|
== -1)
|
||||||
@ -253,16 +253,16 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
|
|||||||
if (connector == -1)
|
if (connector == -1)
|
||||||
goto tidy_up_and_fail;
|
goto tidy_up_and_fail;
|
||||||
/* We want to find out the port number to connect to. */
|
/* We want to find out the port number to connect to. */
|
||||||
size = sizeof (connect_addr);
|
size = sizeof(connect_addr);
|
||||||
if (getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -1)
|
if (getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -1)
|
||||||
goto tidy_up_and_fail;
|
goto tidy_up_and_fail;
|
||||||
if (size != sizeof (connect_addr))
|
if (size != sizeof (connect_addr))
|
||||||
goto abort_tidy_up_and_fail;
|
goto abort_tidy_up_and_fail;
|
||||||
if (connect(connector, (struct sockaddr *) &connect_addr,
|
if (connect(connector, (struct sockaddr *) &connect_addr,
|
||||||
sizeof (connect_addr)) == -1)
|
sizeof(connect_addr)) == -1)
|
||||||
goto tidy_up_and_fail;
|
goto tidy_up_and_fail;
|
||||||
|
|
||||||
size = sizeof (listen_addr);
|
size = sizeof(listen_addr);
|
||||||
acceptor = accept(listener, (struct sockaddr *) &listen_addr, &size);
|
acceptor = accept(listener, (struct sockaddr *) &listen_addr, &size);
|
||||||
if (acceptor == -1)
|
if (acceptor == -1)
|
||||||
goto tidy_up_and_fail;
|
goto tidy_up_and_fail;
|
||||||
@ -468,7 +468,8 @@ get_uname(void)
|
|||||||
* unix calls fork, on win32 calls beginthread. Returns -1 on failure.
|
* unix calls fork, on win32 calls beginthread. Returns -1 on failure.
|
||||||
* func should not return, but rather should call spawn_exit.
|
* func should not return, but rather should call spawn_exit.
|
||||||
*/
|
*/
|
||||||
int spawn_func(int (*func)(void *), void *data)
|
int
|
||||||
|
spawn_func(int (*func)(void *), void *data)
|
||||||
{
|
{
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
/* GCC can check printf types on arbitrary functions. */
|
/* GCC can check printf types on arbitrary functions. */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define CHECK_PRINTF(formatIdx, firstArg) \
|
#define CHECK_PRINTF(formatIdx, firstArg) \
|
||||||
__attribute__ ((format (printf, formatIdx, firstArg)))
|
__attribute__ ((format(printf, formatIdx, firstArg)))
|
||||||
#else
|
#else
|
||||||
#define CHECK_PRINTF(formatIdx, firstArg)
|
#define CHECK_PRINTF(formatIdx, firstArg)
|
||||||
#endif
|
#endif
|
||||||
|
@ -597,7 +597,8 @@ int strmap_iter_done(strmap_iter_t *iter)
|
|||||||
/** Remove all entries from <b>map</b>, and deallocate storage for those entries.
|
/** Remove all entries from <b>map</b>, and deallocate storage for those entries.
|
||||||
* If free_val is provided, it is invoked on every value in <b>map</b>.
|
* If free_val is provided, it is invoked on every value in <b>map</b>.
|
||||||
*/
|
*/
|
||||||
void strmap_free(strmap_t *map, void (*free_val)(void*))
|
void
|
||||||
|
strmap_free(strmap_t *map, void (*free_val)(void*))
|
||||||
{
|
{
|
||||||
strmap_entry_t *ent, *next;
|
strmap_entry_t *ent, *next;
|
||||||
for (ent = SPLAY_MIN(strmap_tree, &map->head); ent != NULL; ent = next) {
|
for (ent = SPLAY_MIN(strmap_tree, &map->head); ent != NULL; ent = next) {
|
||||||
|
@ -540,7 +540,8 @@ static const int days_per_month[] =
|
|||||||
/** Return a time_t given a struct tm. The result is given in GMT, and
|
/** Return a time_t given a struct tm. The result is given in GMT, and
|
||||||
* does not account for leap seconds.
|
* does not account for leap seconds.
|
||||||
*/
|
*/
|
||||||
time_t tor_timegm (struct tm *tm) {
|
time_t
|
||||||
|
tor_timegm(struct tm *tm) {
|
||||||
/* This is a pretty ironclad timegm implementation, snarfed from Python2.2.
|
/* This is a pretty ironclad timegm implementation, snarfed from Python2.2.
|
||||||
* It's way more brute-force than fiddling with tzset().
|
* It's way more brute-force than fiddling with tzset().
|
||||||
*/
|
*/
|
||||||
|
@ -761,7 +761,7 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) {
|
|||||||
log_fn(LOG_WARN,"relay begin cell has no \\0. Dropping.");
|
log_fn(LOG_WARN,"relay begin cell has no \\0. Dropping.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (parse_addr_port(cell->payload+RELAY_HEADER_SIZE, &address, NULL,&port)<0){
|
if (parse_addr_port(cell->payload+RELAY_HEADER_SIZE,&address,NULL,&port)<0) {
|
||||||
log_fn(LOG_WARN,"Unable to parse addr:port in relay begin cell. Dropping.");
|
log_fn(LOG_WARN,"Unable to parse addr:port in relay begin cell. Dropping.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +594,7 @@ connection_dir_client_reached_eof(connection_t *conn)
|
|||||||
tor_free(body); tor_free(headers);
|
tor_free(body); tor_free(headers);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(router_load_routerlist_from_directory(body, NULL, 1) < 0){
|
if(router_load_routerlist_from_directory(body, NULL, 1) < 0) {
|
||||||
log_fn(LOG_WARN,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
|
log_fn(LOG_WARN,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
|
||||||
} else {
|
} else {
|
||||||
log_fn(LOG_INFO,"updated routers.");
|
log_fn(LOG_INFO,"updated routers.");
|
||||||
|
@ -604,8 +604,9 @@ dirserv_dump_directory_to_string(char *s, size_t maxlen,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{ int l;
|
{
|
||||||
if(crypto_pk_write_public_key_to_string(private_key, &identity_pkey, &l)<0){
|
int l;
|
||||||
|
if(crypto_pk_write_public_key_to_string(private_key,&identity_pkey,&l)<0) {
|
||||||
log_fn(LOG_WARN,"write identity_pkey to string failed!");
|
log_fn(LOG_WARN,"write identity_pkey to string failed!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -847,8 +848,9 @@ static int generate_runningrouters(crypto_pk_env_t *private_key)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{ int l;
|
{
|
||||||
if(crypto_pk_write_public_key_to_string(private_key, &identity_pkey, &l)<0){
|
int l;
|
||||||
|
if(crypto_pk_write_public_key_to_string(private_key,&identity_pkey,&l)<0) {
|
||||||
log_fn(LOG_WARN,"write identity_pkey to string failed!");
|
log_fn(LOG_WARN,"write identity_pkey to string failed!");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ rend_service_introduce(circuit_t *circuit, const char *request, size_t request_l
|
|||||||
|
|
||||||
/* min key length plus digest length plus nickname length */
|
/* min key length plus digest length plus nickname length */
|
||||||
if (request_len < DIGEST_LEN+REND_COOKIE_LEN+(MAX_NICKNAME_LEN+1)+
|
if (request_len < DIGEST_LEN+REND_COOKIE_LEN+(MAX_NICKNAME_LEN+1)+
|
||||||
DH_KEY_LEN+42){
|
DH_KEY_LEN+42) {
|
||||||
log_fn(LOG_WARN, "Got a truncated INTRODUCE2 cell on circ %d",
|
log_fn(LOG_WARN, "Got a truncated INTRODUCE2 cell on circ %d",
|
||||||
circuit->n_circ_id);
|
circuit->n_circ_id);
|
||||||
return -1;
|
return -1;
|
||||||
@ -816,7 +816,8 @@ void rend_services_introduce(void) {
|
|||||||
/* One period has elapsed; we can try building circuits again. */
|
/* One period has elapsed; we can try building circuits again. */
|
||||||
service->intro_period_started = now;
|
service->intro_period_started = now;
|
||||||
service->n_intro_circuits_launched = 0;
|
service->n_intro_circuits_launched = 0;
|
||||||
} else if (service->n_intro_circuits_launched>=MAX_INTRO_CIRCS_PER_PERIOD){
|
} else if (service->n_intro_circuits_launched >=
|
||||||
|
MAX_INTRO_CIRCS_PER_PERIOD) {
|
||||||
/* We have failed too many times in this period; wait for the next
|
/* We have failed too many times in this period; wait for the next
|
||||||
* one before we try again. */
|
* one before we try again. */
|
||||||
continue;
|
continue;
|
||||||
|
@ -366,7 +366,7 @@ int init_keys(void) {
|
|||||||
if(!cp) {
|
if(!cp) {
|
||||||
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
|
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
|
||||||
} else {
|
} else {
|
||||||
if(dirserv_load_from_directory_string(cp) < 0){
|
if(dirserv_load_from_directory_string(cp) < 0) {
|
||||||
log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
|
log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
|
||||||
tor_free(cp);
|
tor_free(cp);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -886,7 +886,7 @@ routerinfo_t *router_parse_entry_from_string(const char *s,
|
|||||||
}
|
}
|
||||||
router->identity_pkey = tok->key;
|
router->identity_pkey = tok->key;
|
||||||
tok->key = NULL; /* Prevent free */
|
tok->key = NULL; /* Prevent free */
|
||||||
if (crypto_pk_get_digest(router->identity_pkey,router->identity_digest)){
|
if (crypto_pk_get_digest(router->identity_pkey,router->identity_digest)) {
|
||||||
log_fn(LOG_WARN, "Couldn't calculate key digest"); goto err;
|
log_fn(LOG_WARN, "Couldn't calculate key digest"); goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1218,7 @@ test_rend_fns(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int c, char**v){
|
main(int c, char**v) {
|
||||||
or_options_t *options = tor_malloc_zero(sizeof(or_options_t));
|
or_options_t *options = tor_malloc_zero(sizeof(or_options_t));
|
||||||
options_init(options);
|
options_init(options);
|
||||||
set_options(options);
|
set_options(options);
|
||||||
|
Loading…
Reference in New Issue
Block a user