From: Nick Mathewson Date: Wed, 19 Mar 2025 17:39:54 +0000 (-0400) Subject: Fix a compilation warning in networkstatus.c X-Git-Tag: tor-0.4.9.2-alpha~28^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d41b7f68a6574550f032c8a35554dfaf8a7b2c9;p=thirdparty%2Ftor.git 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. --- 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);