From d795ed5871010b8ad6d216f5f4381e4191cb147c Mon Sep 17 00:00:00 2001 From: George Kadianakis Date: Thu, 25 Aug 2016 01:44:34 +0300 Subject: [PATCH] Make check-spaces happy :) Signed-off-by: David Goulet Signed-off-by: George Kadianakis --- src/or/directory.c | 8 ++++---- src/or/hs_cache.c | 5 +++-- src/or/hs_cache.h | 1 + src/or/hs_common.c | 3 ++- src/or/hs_common.h | 1 + src/or/hs_descriptor.c | 24 +++++++++++++----------- src/or/hs_descriptor.h | 1 + src/or/parsecommon.c | 5 +---- src/or/parsecommon.h | 2 +- src/or/rendclient.c | 2 +- src/or/rendcommon.c | 1 + src/test/test_hs.c | 3 ++- src/test/test_hs_cache.c | 8 ++++---- src/test/test_hs_descriptor.c | 17 ++++++++++------- 14 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/or/directory.c b/src/or/directory.c index 8afb241520..29022fab4f 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -2350,10 +2350,10 @@ connection_dir_client_reached_eof(dir_connection_t *conn) conn->identity_digest, \ reason) ) #define SEND_HS_DESC_FAILED_CONTENT() ( \ - control_event_hs_descriptor_content(rend_data_get_address(conn->rend_data), \ - conn->requested_resource, \ - conn->identity_digest, \ - NULL) ) + control_event_hs_descriptor_content(rend_data_get_address(conn->rend_data), \ + conn->requested_resource, \ + conn->identity_digest, \ + NULL) ) tor_assert(conn->rend_data); log_info(LD_REND,"Received rendezvous descriptor (size %d, status %d " "(%s))", diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c index 9b68045e89..6d33201469 100644 --- a/src/or/hs_cache.c +++ b/src/or/hs_cache.c @@ -81,7 +81,7 @@ cache_dir_desc_new(const char *desc) dir_desc->created_ts = time(NULL); return dir_desc; -err: + err: cache_dir_desc_free(dir_desc); return NULL; } @@ -173,7 +173,7 @@ cache_lookup_v3_as_dir(const char *query, char **desc_out) return found; -err: + err: return -1; } @@ -365,3 +365,4 @@ hs_cache_init(void) tor_assert(!hs_cache_v3_dir); hs_cache_v3_dir = digest256map_new(); } + diff --git a/src/or/hs_cache.h b/src/or/hs_cache.h index f0573175d3..466c33db09 100644 --- a/src/or/hs_cache.h +++ b/src/or/hs_cache.h @@ -57,3 +57,4 @@ STATIC size_t cache_clean_v3_as_dir(time_t now, time_t global_cutoff); #endif /* HS_CACHE_PRIVATE */ #endif /* TOR_HS_CACHE_H */ + diff --git a/src/or/hs_common.c b/src/or/hs_common.c index 2166005e71..c78af531a7 100644 --- a/src/or/hs_common.c +++ b/src/or/hs_common.c @@ -127,7 +127,7 @@ compute_desc_id(rend_data_t *rend_data) tor_assert(0); } -end: + end: return ret; } @@ -262,3 +262,4 @@ rend_data_get_pk_digest(const rend_data_t *rend_data, size_t *len_out) tor_assert(0); } } + diff --git a/src/or/hs_common.h b/src/or/hs_common.h index 824e5405f2..1d3a15df5a 100644 --- a/src/or/hs_common.h +++ b/src/or/hs_common.h @@ -34,3 +34,4 @@ const uint8_t *rend_data_get_pk_digest(const rend_data_t *rend_data, size_t *len_out); #endif /* TOR_HS_COMMON_H */ + diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c index 9714d52f8c..a87a8605ec 100644 --- a/src/or/hs_descriptor.c +++ b/src/or/hs_descriptor.c @@ -167,7 +167,7 @@ encode_cert(const tor_cert_t *cert, char **cert_str_out) /* Success! */ ret = 0; -err: + err: tor_free(ed_cert_b64); return ret; } @@ -821,7 +821,7 @@ desc_encode_v3(const hs_descriptor_t *desc, char **encoded_out) /* Success! */ ret = 0; -err: + err: SMARTLIST_FOREACH(lines, char *, l, tor_free(l)); smartlist_free(lines); return ret; @@ -1177,14 +1177,14 @@ desc_decrypt_data_v3(const hs_descriptor_t *desc, char **decrypted_out) *decrypted_out = (char *) decrypted; goto done; -err: + err: if (decrypted) { tor_free(decrypted); } *decrypted_out = NULL; result_len = 0; -done: + done: memwipe(secret_key, 0, sizeof(secret_key)); memwipe(secret_iv, 0, sizeof(secret_iv)); return result_len; @@ -1326,9 +1326,9 @@ decode_introduction_point(const hs_descriptor_t *desc, const char *start) return ip; } -/* Given a descriptor string at data, decode all possible introduction points - * that we can find. Add the introduction point object to desc_enc as we find - * them. Return 0 on success. +/* Given a descriptor string at data, decode all possible introduction + * points that we can find. Add the introduction point object to desc_enc as we + * find them. Return 0 on success. * * On error, a negative value is returned. It is possible that some intro * point object have been added to the desc_enc, they should be considered @@ -1455,7 +1455,7 @@ desc_sig_is_valid(const char *b64_sig, const ed25519_keypair_t *signing_kp, /* Valid signature! All is good. */ ret = 1; -err: + err: return ret; } @@ -1557,7 +1557,8 @@ desc_decode_plaintext_v3(smartlist_t *tokens, } return 0; -err: + + err: return -1; } @@ -1778,7 +1779,7 @@ hs_desc_decode_plaintext(const char *encoded, /* Success. Descriptor has been populated with the data. */ ret = 0; -err: + err: if (tokens) { SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t)); smartlist_free(tokens); @@ -1885,7 +1886,7 @@ hs_desc_encode_descriptor(const hs_descriptor_t *desc, char **encoded_out) return 0; -err: + err: *encoded_out = NULL; return ret; } @@ -1930,3 +1931,4 @@ hs_desc_plaintext_obj_size(const hs_desc_plaintext_data_t *data) return (sizeof(*data) + sizeof(*data->signing_key_cert) + data->encrypted_blob_size); } + diff --git a/src/or/hs_descriptor.h b/src/or/hs_descriptor.h index 1213597984..b48079e219 100644 --- a/src/or/hs_descriptor.h +++ b/src/or/hs_descriptor.h @@ -235,3 +235,4 @@ STATIC int desc_sig_is_valid(const char *b64_sig, #endif /* HS_DESCRIPTOR_PRIVATE */ #endif /* TOR_HS_DESCRIPTOR_H */ + diff --git a/src/or/parsecommon.c b/src/or/parsecommon.c index 72e69e8ea3..6622d7d671 100644 --- a/src/or/parsecommon.c +++ b/src/or/parsecommon.c @@ -146,7 +146,6 @@ tokenize_string(memarea_t *area, return 0; } - /** Helper: parse space-separated arguments from the string s ending at * eol, and store them in the args field of tok. Store the * number of parsed elements into the n_args field of tok. Allocate @@ -243,8 +242,6 @@ token_check_object(memarea_t *area, const char *kwd, return tok; } - - /** Helper function: read the next token from *s, advance *s to the end of the * token, and return the parsed token. Parse *s according to the list * of tokens in table. @@ -408,7 +405,6 @@ get_next_token(memarea_t *area, #undef STRNDUP } - /** Find the first token in s whose keyword is keyword; fail * with an assert if no such keyword is found. */ @@ -451,3 +447,4 @@ find_all_by_keyword(smartlist_t *s, directory_keyword k) }); return out; } + diff --git a/src/or/parsecommon.h b/src/or/parsecommon.h index f87e62de98..be7cba47d1 100644 --- a/src/or/parsecommon.h +++ b/src/or/parsecommon.h @@ -6,7 +6,6 @@ * \brief Header file for parsecommon.c **/ - #ifndef TOR_PARSECOMMON_H #define TOR_PARSECOMMON_H @@ -304,3 +303,4 @@ directory_token_t *find_opt_by_keyword(smartlist_t *s, smartlist_t * find_all_by_keyword(smartlist_t *s, directory_keyword k); #endif /* TOR_PARSECOMMON_H */ + diff --git a/src/or/rendclient.c b/src/or/rendclient.c index ad47ca6242..0bfc1a1805 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -151,7 +151,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc, tor_assert(introcirc->rend_data); tor_assert(rendcirc->rend_data); tor_assert(!rend_cmp_service_ids(rend_data_get_address(introcirc->rend_data), - rend_data_get_address(rendcirc->rend_data))); + rend_data_get_address(rendcirc->rend_data))); #ifndef NON_ANONYMOUS_MODE_ENABLED tor_assert(!(introcirc->build_state->onehop_tunnel)); tor_assert(!(rendcirc->build_state->onehop_tunnel)); diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index e6a7bbc28c..125aa0f5ef 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -978,3 +978,4 @@ rend_circuit_pk_digest_eq(const origin_circuit_t *ocirc, match: return 1; } + diff --git a/src/test/test_hs.c b/src/test/test_hs.c index a09e99ffc0..3bf4e6db98 100644 --- a/src/test/test_hs.c +++ b/src/test/test_hs.c @@ -350,7 +350,8 @@ test_hs_rend_data(void *arg) tt_str_op(client_dup_v2->onion_address, OP_EQ, client_v2->onion_address); tt_mem_op(client_dup_v2->desc_id_fetch, OP_EQ, client_v2->desc_id_fetch, sizeof(client_dup_v2->desc_id_fetch)); - tt_mem_op(client_dup_v2->descriptor_cookie, OP_EQ, client_v2->descriptor_cookie, + tt_mem_op(client_dup_v2->descriptor_cookie, OP_EQ, + client_v2->descriptor_cookie, sizeof(client_dup_v2->descriptor_cookie)); tt_assert(client_dup->hsdirs_fp); diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c index ab4d2b94de..33887aedd9 100644 --- a/src/test/test_hs_cache.c +++ b/src/test/test_hs_cache.c @@ -58,7 +58,7 @@ helper_build_intro_point(const ed25519_keypair_t *blinded_kp, tt_int_op(ret, ==, 0); ip->enc_key_type = HS_DESC_KEY_TYPE_CURVE25519; intro_point = ip; -done: + done: return intro_point; } @@ -101,7 +101,7 @@ helper_build_hs_desc(uint64_t revision_counter, uint32_t lifetime, "1.2.3.4")); descp = desc; -done: + done: return descp; } @@ -257,8 +257,8 @@ test_clean_as_dir(void *arg) tt_assert(desc1); ret = hs_desc_encode_descriptor(desc1, &desc1_str); tt_int_op(ret, OP_EQ, 0); - ret = hs_cache_store_as_dir(desc1_str); - tt_int_op(ret, OP_EQ, 0); + ret = hs_cache_store_as_dir(desc1_str); + tt_int_op(ret, OP_EQ, 0); /* With the lifetime being 3 hours, a cleanup shouldn't remove it. */ ret = cache_clean_v3_as_dir(now, 0); diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c index d9030c1fc5..086d755bd3 100644 --- a/src/test/test_hs_descriptor.c +++ b/src/test/test_hs_descriptor.c @@ -29,7 +29,8 @@ helper_build_intro_point(const ed25519_keypair_t *blinded_kp, time_t now, hs_desc_link_specifier_t *ls = tor_malloc_zero(sizeof(*ls)); if (legacy) { ls->type = LS_LEGACY_ID; - memcpy(ls->u.legacy_id, "0299F268FCA9D55CD157976D39AE92B4B455B3A8", DIGEST_LEN); + memcpy(ls->u.legacy_id, "0299F268FCA9D55CD157976D39AE92B4B455B3A8", + DIGEST_LEN); } else { ls->u.ap.port = 9001; int family = tor_addr_parse(&ls->u.ap.addr, addr); @@ -106,16 +107,16 @@ helper_build_hs_desc(unsigned int no_ip) if (!no_ip) { /* Add four intro points. */ smartlist_add(desc->encrypted_data.intro_points, - helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, + helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, "1.2.3.4", 0)); smartlist_add(desc->encrypted_data.intro_points, - helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, + helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, "[2600::1]", 0)); smartlist_add(desc->encrypted_data.intro_points, - helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, + helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, "3.2.1.4", 1)); smartlist_add(desc->encrypted_data.intro_points, - helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, + helper_build_intro_point(&desc->plaintext_data.blinded_kp, now, "", 1)); } @@ -171,7 +172,7 @@ helper_compare_hs_desc(const hs_descriptor_t *desc1, tt_assert(desc2->encrypted_data.intro_points); tt_int_op(smartlist_len(desc1->encrypted_data.intro_points), ==, smartlist_len(desc2->encrypted_data.intro_points)); - for (int i = 0; i < smartlist_len(desc1->encrypted_data.intro_points); i++) { + for (int i=0; i < smartlist_len(desc1->encrypted_data.intro_points); i++) { hs_desc_intro_point_t *ip1 = smartlist_get(desc1->encrypted_data .intro_points, i), *ip2 = smartlist_get(desc2->encrypted_data @@ -948,7 +949,8 @@ test_decode_plaintext(void *arg) "-----BEGIN %s-----\n" \ "UNICORN\n" \ "-----END MESSAGE-----\n" \ - "signature m20WJH5agqvwhq7QeuEZ1mYyPWQDO+eJOZUjLhAiKu8DbL17DsDfJE6kXbWyHimbNj2we0enV3cCOOAsmPOaAw\n" + "signature m20WJH5agqvwhq7QeuEZ1mYyPWQDO+eJOZUjLhAiKu8DbL17DsDfJE6kXbWy" \ + "HimbNj2we0enV3cCOOAsmPOaAw\n" /* Invalid version. */ { @@ -1125,3 +1127,4 @@ struct testcase_t hs_descriptor[] = { END_OF_TESTCASES }; +