]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
relay/circuitbuild: Refactor circuit_extend()
authorteor <teor@torproject.org>
Mon, 6 Apr 2020 09:21:13 +0000 (19:21 +1000)
committerteor <teor@torproject.org>
Thu, 9 Apr 2020 01:00:04 +0000 (11:00 +1000)
Make the "else" case explicit at the end of the function.

Part of 33633.

src/feature/relay/circuitbuild_relay.c

index ae8581075fea10386cef4420841e8d03edadeb3c..2fa92eeac194d6c3a5c01ec9abc5cf2d6b4f6fc8 100644 (file)
@@ -295,18 +295,20 @@ circuit_extend(struct cell_t *cell, struct circuit_t *circ)
      * OR_CONN_STATE_OPEN.
      */
     return 0;
-  }
-
-  tor_assert(!circ->n_hop); /* Connection is already established. */
-  circ->n_chan = n_chan;
-  log_debug(LD_CIRC,
-            "n_chan is %s.",
-            channel_get_canonical_remote_descr(n_chan));
-
-  if (circuit_deliver_create_cell(circ, &ec.create_cell, 1) < 0)
-    return -1;
+  } else {
+    /* Connection is already established.
+     * So we need to extend the circuit to the next hop. */
+    tor_assert(!circ->n_hop);
+    circ->n_chan = n_chan;
+    log_debug(LD_CIRC,
+              "n_chan is %s.",
+              channel_get_canonical_remote_descr(n_chan));
+
+    if (circuit_deliver_create_cell(circ, &ec.create_cell, 1) < 0)
+      return -1;
 
-  return 0;
+    return 0;
+  }
 }
 
 /** On a relay, accept a create cell, initialise a circuit, and send a