From 38d2ec897014739af16b93f127f578c0d2ba6bf8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 May 2025 21:16:35 -0400 Subject: [PATCH] Un-parenthesize checks wrt connection_edge_process_ordered_relay_cell() 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 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 7a79bb3888..f116cb5972 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -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); -- 2.47.3