Browse Source

Improve code based on Nick review:

- Fix some more crazy ternary ops.
- Fix the order of disaster SRV computation.
- Whitespace fixes.
- Remove a redundant warn.
- Better docs.
George Kadianakis 6 years ago
parent
commit
c62da5cf95
5 changed files with 10 additions and 8 deletions
  1. 5 2
      src/or/hs_circuit.c
  2. 2 2
      src/or/hs_common.c
  3. 0 1
      src/or/hs_descriptor.c
  4. 2 2
      src/or/hs_service.c
  5. 1 1
      src/or/networkstatus.c

+ 5 - 2
src/or/hs_circuit.c

@@ -699,8 +699,11 @@ hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ)
   circ->hs_service_side_rend_circ_has_been_relaunched = 1;
 
   /* Legacy service don't have an hidden service ident. */
-  (circ->hs_ident) ? retry_service_rendezvous_point(circ) :
-                     rend_service_relaunch_rendezvous(circ);
+  if (circ->hs_ident) {
+    retry_service_rendezvous_point(circ);
+  } else {
+    rend_service_relaunch_rendezvous(circ);
+  }
 
  done:
   return;

+ 2 - 2
src/or/hs_common.c

@@ -521,9 +521,9 @@ get_disaster_srv(uint64_t time_period_num, uint8_t *srv_out)
     uint64_t time_period_length = get_time_period_length();
     char period_stuff[sizeof(uint64_t)*2];
     size_t offset = 0;
-    set_uint64(period_stuff, tor_htonll(time_period_num));
+    set_uint64(period_stuff, tor_htonll(time_period_length));
     offset += sizeof(uint64_t);
-    set_uint64(period_stuff+offset, tor_htonll(time_period_length));
+    set_uint64(period_stuff+offset, tor_htonll(time_period_num));
     offset += sizeof(uint64_t);
     tor_assert(offset == sizeof(period_stuff));
 

+ 0 - 1
src/or/hs_descriptor.c

@@ -1007,7 +1007,6 @@ desc_encode_v3(const hs_descriptor_t *desc,
   tor_assert(desc->plaintext_data.version == 3);
 
   if (BUG(desc->subcredential == NULL)) {
-    log_warn(LD_GENERAL, "Asked to encode desc with no subcred. No!");
     goto err;
   }
 

+ 2 - 2
src/or/hs_service.c

@@ -2881,14 +2881,14 @@ hs_service_circuit_has_opened(origin_circuit_t *circ)
     if (circ->hs_ident) {
       service_intro_circ_has_opened(circ);
     } else {
-                       rend_service_intro_has_opened(circ);
+      rend_service_intro_has_opened(circ);
     }
     break;
   case CIRCUIT_PURPOSE_S_CONNECT_REND:
     if (circ->hs_ident) {
       service_rendezvous_circ_has_opened(circ);
     } else {
-                       rend_service_rendezvous_has_opened(circ);
+      rend_service_rendezvous_has_opened(circ);
     }
     break;
   default:

+ 1 - 1
src/or/networkstatus.c

@@ -1400,7 +1400,7 @@ networkstatus_get_live_consensus,(time_t now))
     return NULL;
 }
 
-/** Given a consensus in <b>ns</b>, validate that it's currently live and
+/** Given a consensus in <b>ns</b>, return true iff currently live and
  *  unexpired. */
 int
 networkstatus_is_live(const networkstatus_t *ns, time_t now)