diff options
author | Roger Dingledine <arma@torproject.org> | 2016-03-07 19:29:05 -0500 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2016-03-11 10:49:57 -0500 |
commit | edeba3d472e303a9a3263582d1e4c0fbcb5a28b8 (patch) | |
tree | 7fc0743c3ca4f8da4c1c07a6a32f432ec235f5bf /src/or/rendcache.c | |
parent | dc500c8cb4dc7643230d160d1b458a0acdadd242 (diff) | |
download | tor-edeba3d472e303a9a3263582d1e4c0fbcb5a28b8.tar.gz tor-edeba3d472e303a9a3263582d1e4c0fbcb5a28b8.zip |
simplify rend_cache_store_status_t back to a boolean
it used to be a tri-state, but now it's just a bi-state, so we can
take out all the machinery like the enum.
Diffstat (limited to 'src/or/rendcache.c')
-rw-r--r-- | src/or/rendcache.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/or/rendcache.c b/src/or/rendcache.c index dad4b2b5ba..7c5844262b 100644 --- a/src/or/rendcache.c +++ b/src/or/rendcache.c @@ -622,9 +622,9 @@ rend_cache_lookup_v2_desc_as_dir(const char *desc_id, const char **desc) * If we have a newer descriptor with the same ID, ignore this one. * If we have an older descriptor with the same ID, replace it. * - * Return an appropriate rend_cache_store_status_t. + * Return 0 on success, or -1 if we couldn't parse any of them. */ -rend_cache_store_status_t +int rend_cache_store_v2_desc_as_dir(const char *desc) { const or_options_t *options = get_options(); @@ -717,11 +717,11 @@ rend_cache_store_v2_desc_as_dir(const char *desc) } if (!number_parsed) { log_info(LD_REND, "Could not parse any descriptor."); - return RCS_BADDESC; + return -1; } log_info(LD_REND, "Parsed %d and added %d descriptor%s.", number_parsed, number_stored, number_stored != 1 ? "s" : ""); - return RCS_OKAY; + return 0; } /** Parse the v2 service descriptor in <b>desc</b> and store it to the @@ -731,9 +731,9 @@ rend_cache_store_v2_desc_as_dir(const char *desc) * If we have a newer descriptor with the same ID, ignore this one. * If we have an older descriptor with the same ID, replace it. * -* Return an appropriate rend_cache_store_status_t. +* Return 0 on success, or -1 if we couldn't understand the descriptor. */ -rend_cache_store_status_t +int rend_cache_store_v2_desc_as_service(const char *desc) { rend_service_descriptor_t *parsed = NULL; @@ -744,7 +744,7 @@ rend_cache_store_v2_desc_as_service(const char *desc) const char *next_desc; char service_id[REND_SERVICE_ID_LEN_BASE32+1]; rend_cache_entry_t *e; - rend_cache_store_status_t retval = RCS_BADDESC; + int retval = -1; tor_assert(rend_cache_local_service); tor_assert(desc); @@ -787,10 +787,10 @@ rend_cache_store_v2_desc_as_service(const char *desc) rend_cache_increment_allocation(rend_cache_entry_allocation(e)); log_debug(LD_REND,"Successfully stored rend desc '%s', len %d.", safe_str_client(service_id), (int)encoded_size); - return RCS_OKAY; + return 0; okay: - retval = RCS_OKAY; + retval = 0; err: rend_service_descriptor_free(parsed); @@ -811,10 +811,10 @@ rend_cache_store_v2_desc_as_service(const char *desc) * If the descriptor's descriptor ID doesn't match <b>desc_id_base32</b>, * reject it. * - * Return an appropriate rend_cache_store_status_t. If entry is not NULL, - * set it with the cache entry pointer of the descriptor. + * Return 0 on success, or -1 if we rejected the descriptor. + * If entry is not NULL, set it with the cache entry pointer of the descriptor. */ -rend_cache_store_status_t +int rend_cache_store_v2_desc_as_client(const char *desc, const char *desc_id_base32, const rend_data_t *rend_query, @@ -846,7 +846,7 @@ rend_cache_store_v2_desc_as_client(const char *desc, char service_id[REND_SERVICE_ID_LEN_BASE32+1]; char want_desc_id[DIGEST_LEN]; rend_cache_entry_t *e; - rend_cache_store_status_t retval = RCS_BADDESC; + int retval = -1; tor_assert(rend_cache); tor_assert(desc); tor_assert(desc_id_base32); @@ -993,13 +993,13 @@ rend_cache_store_v2_desc_as_client(const char *desc, if (entry) { *entry = e; } - return RCS_OKAY; + return 0; okay: if (entry) { *entry = e; } - retval = RCS_OKAY; + retval = 0; err: rend_service_descriptor_free(parsed); |