]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Un-parenthesize checks wrt connection_edge_process_ordered_relay_cell()
authorNick Mathewson <nickm@torproject.org>
Thu, 8 May 2025 01:16:35 +0000 (21:16 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 8 May 2025 01:16:35 +0000 (21:16 -0400)
Previously, one of these checks had the parentheses in the wrong
place, given an incorrect result.  The code is hard enough to read
that I refactored both instances to be more obviously right.

I've grepped for similar errors elsewhere, but didn't find them.

Fixed #41070.  Bug not in any released Tor.

src/core/or/relay.c

index 7a79bb38888f885565fbe616857dd5c6772ae53e..f116cb59722c47355cc9ba3698baf3fb502e7afc 100644 (file)
@@ -2107,12 +2107,11 @@ connection_edge_process_relay_cell(const relay_msg_t *msg, circuit_t *circ,
     if (conflux_process_relay_msg(circ->conflux, circ, layer_hint,
                                   (relay_msg_t *) msg)) {
       conflux_msg_t *c_msg = NULL;
-      int ret = 0;
 
       /* First, process this cell */
-      if ((ret = connection_edge_process_ordered_relay_cell(msg, circ,
-                                                            conn,
-                                                            layer_hint) < 0)) {
+      int ret = connection_edge_process_ordered_relay_cell(
+                 msg, circ, conn, layer_hint);
+      if (ret < 0) {
         return ret;
       }
 
@@ -2120,10 +2119,10 @@ connection_edge_process_relay_cell(const relay_msg_t *msg, circuit_t *circ,
       while ((c_msg = conflux_dequeue_relay_msg(circ->conflux))) {
         conn = relay_lookup_conn(circ, c_msg->msg, CELL_DIRECTION_OUT,
                                  layer_hint);
-        if ((ret =
-             connection_edge_process_ordered_relay_cell(c_msg->msg, circ,
-                                                        conn,
-                                                        layer_hint)) < 0) {
+        ret = connection_edge_process_ordered_relay_cell(c_msg->msg, circ,
+                                                         conn,
+                                                         layer_hint);
+        if (ret < 0) {
           /* Negative return value is a fatal error. Return early and tear down
            * circuit */
           conflux_relay_msg_free(c_msg);