aboutsummaryrefslogtreecommitdiff
path: root/src/core/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-16 09:57:52 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-16 09:57:52 -0400
commitb0d7b100886ef14a785f6ca1de968df9a884d0a7 (patch)
tree931f94cbc9dd273a6df31ef3e93623babfc1ec2b /src/core/or
parent10d8555e7db2f4835b4fc9a0f4592e470a974c5f (diff)
downloadtor-b0d7b100886ef14a785f6ca1de968df9a884d0a7.tar.gz
tor-b0d7b100886ef14a785f6ca1de968df9a884d0a7.zip
Improve documentation for our TO_*_CONN() cast functions.
Preliminary work for #40046.
Diffstat (limited to 'src/core/or')
-rw-r--r--src/core/or/connection_edge.c20
-rw-r--r--src/core/or/connection_or.c7
2 files changed, 23 insertions, 4 deletions
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c
index 8eb9f8ba0f..30cfb18f0f 100644
--- a/src/core/or/connection_edge.c
+++ b/src/core/or/connection_edge.c
@@ -166,8 +166,12 @@ static int connection_exit_connect_dir(edge_connection_t *exitconn);
static int consider_plaintext_ports(entry_connection_t *conn, uint16_t port);
static int connection_ap_supports_optimistic_data(const entry_connection_t *);
-/** Convert a connection_t* to an edge_connection_t*; assert if the cast is
- * invalid. */
+/**
+ * Cast a `connection_t *` to an `edge_connection_t *`.
+ *
+ * Exit with an assertion failure if the input is not an
+ * `edge_connection_t`.
+ **/
edge_connection_t *
TO_EDGE_CONN(connection_t *c)
{
@@ -176,6 +180,12 @@ TO_EDGE_CONN(connection_t *c)
return DOWNCAST(edge_connection_t, c);
}
+/**
+ * Cast a `connection_t *` to an `entry_connection_t *`.
+ *
+ * Exit with an assertion failure if the input is not an
+ * `entry_connection_t`.
+ **/
entry_connection_t *
TO_ENTRY_CONN(connection_t *c)
{
@@ -183,6 +193,12 @@ TO_ENTRY_CONN(connection_t *c)
return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
}
+/**
+ * Cast an `edge_connection_t *` to an `entry_connection_t *`.
+ *
+ * Exit with an assertion failure if the input is not an
+ * `entry_connection_t`.
+ **/
entry_connection_t *
EDGE_TO_ENTRY_CONN(edge_connection_t *c)
{
diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c
index e62c28821a..e6dc62a475 100644
--- a/src/core/or/connection_or.c
+++ b/src/core/or/connection_or.c
@@ -99,8 +99,11 @@ static void connection_or_check_canonicity(or_connection_t *conn,
/**************************************************************/
-/** Convert a connection_t* to an or_connection_t*; assert if the cast is
- * invalid. */
+/**
+ * Cast a `connection_t *` to an `or_connection_t *`.
+ *
+ * Exit with an assertion failure if the input is not an `or_connnection_t`.
+ **/
or_connection_t *
TO_OR_CONN(connection_t *c)
{