[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/release-0.3.3] Adjust tor_assert_unreached()
commit 796e36e535d1713fd1168772669199ea9189ba61
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon Oct 15 10:46:24 2018 -0400
Adjust tor_assert_unreached()
This version of the macro makes it obvious to the compiler that
"tor_assert_unreached()" will always abort().
---
src/common/util_bug.h | 7 ++++++-
src/or/hs_common.c | 7 +++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/common/util_bug.h b/src/common/util_bug.h
index c274355f3..be0001e84 100644
--- a/src/common/util_bug.h
+++ b/src/common/util_bug.h
@@ -102,7 +102,12 @@
} STMT_END
#endif /* defined(TOR_UNIT_TESTS) && defined(DISABLE_ASSERTS_IN_UNIT_TESTS) */
-#define tor_assert_unreached() tor_assert(0)
+#define tor_assert_unreached() \
+ STMT_BEGIN { \
+ tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, \
+ "line should be unreached"); \
+ abort(); \
+ } STMT_END
/* Non-fatal bug assertions. The "unreached" variants mean "this line should
* never be reached." The "once" variants mean "Don't log a warning more than
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index 10b56c0ba..e586516c8 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -523,7 +523,7 @@ rend_data_get_address(const rend_data_t *rend_data)
return TO_REND_DATA_V2(rend_data)->onion_address;
default:
/* We should always have a supported version. */
- tor_assert(0);
+ tor_assert_unreached();
}
}
@@ -546,7 +546,7 @@ rend_data_get_desc_id(const rend_data_t *rend_data, uint8_t replica,
return TO_REND_DATA_V2(rend_data)->descriptor_id[replica];
default:
/* We should always have a supported version. */
- tor_assert(0);
+ tor_assert_unreached();
}
}
@@ -569,7 +569,7 @@ rend_data_get_pk_digest(const rend_data_t *rend_data, size_t *len_out)
}
default:
/* We should always have a supported version. */
- tor_assert(0);
+ tor_assert_unreached();
}
}
@@ -1814,4 +1814,3 @@ hs_inc_rdv_stream_counter(origin_circuit_t *circ)
tor_assert_nonfatal_unreached();
}
}
-
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits