commit 6d41b7f68a6574550f032c8a35554dfaf8a7b2c9
parent 2cfa7e0fc0a8e6563598014d5dd3e3b8fcc45f32
Author: Nick Mathewson <nickm@torproject.org>
Date: Wed, 19 Mar 2025 13:39:54 -0400
Fix a compilation warning in networkstatus.c
I have no idea why this just showed up for me.
I guess it has something to do with GCC, but I'm not sure.
Closes #41032.
Diffstat:
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/changes/bug41032 b/changes/bug41032
@@ -0,0 +1,2 @@
+ o Minor features (compilation):
+ - Fix a warning when compiling with GCC 14.2. Closes 41032.
diff --git a/src/feature/nodelist/networkstatus.c b/src/feature/nodelist/networkstatus.c
@@ -1954,7 +1954,7 @@ networkstatus_set_current_consensus(const char *consensus,
int free_consensus = 1; /* Free 'c' at the end of the function */
int checked_protocols_already = 0;
- if (flav < 0) {
+ if (flav < 0 || flav >= N_CONSENSUS_FLAVORS) {
/* XXXX we don't handle unrecognized flavors yet. */
log_warn(LD_BUG, "Unrecognized consensus flavor %s", flavor);
return -2;
@@ -1982,6 +1982,7 @@ networkstatus_set_current_consensus(const char *consensus,
if ((int)c->flavor != flav) {
/* This wasn't the flavor we thought we were getting. */
+ tor_assert(c->flavor < N_CONSENSUS_FLAVORS);
if (require_flavor) {
log_warn(LD_DIR, "Got consensus with unexpected flavor %s (wanted %s)",
networkstatus_get_flavor_name(c->flavor), flavor);