From 6d41b7f68a6574550f032c8a35554dfaf8a7b2c9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 19 Mar 2025 13:39:54 -0400 Subject: [PATCH] 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. --- changes/bug41032 | 2 ++ src/feature/nodelist/networkstatus.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changes/bug41032 diff --git a/changes/bug41032 b/changes/bug41032 new file mode 100644 index 0000000000..25c337c9d5 --- /dev/null +++ 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 index 61eef5bfa5..240756acb6 100644 --- 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); -- 2.47.3