aboutsummaryrefslogtreecommitdiff
path: root/src/feature/control/control_getinfo.c
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-10-21 13:49:44 +1000
committerteor <teor@torproject.org>2019-10-21 13:57:02 +1000
commit92fa5239fc357c2078bf613a875c986a3bd97710 (patch)
treeea118980fa3e4b63811d6e5d8b609ce1633c0d0d /src/feature/control/control_getinfo.c
parent3b2525c375bdd07abb31aeb498c079111e8c3595 (diff)
downloadtor-92fa5239fc357c2078bf613a875c986a3bd97710.tar.gz
tor-92fa5239fc357c2078bf613a875c986a3bd97710.zip
control/getinfo: Use standard error handling
Use BUG() for coding errors, and `< 0` for error checks. Fix to 31684.
Diffstat (limited to 'src/feature/control/control_getinfo.c')
-rw-r--r--src/feature/control/control_getinfo.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/feature/control/control_getinfo.c b/src/feature/control/control_getinfo.c
index b77869e215..979fa4480d 100644
--- a/src/feature/control/control_getinfo.c
+++ b/src/feature/control/control_getinfo.c
@@ -333,9 +333,8 @@ getinfo_helper_current_consensus(consensus_flavor_t flavor,
const char** errmsg)
{
const char *flavor_name = networkstatus_get_flavor_name(flavor);
- if (!strcmp(flavor_name, "??")) {
- *errmsg = "Could not open cached consensus. "
- "Make sure FetchUselessDescriptors is set to 1.";
+ if (BUG(!strcmp(flavor_name, "??"))) {
+ *errmsg = "Internal error: unrecognized flavor name.";
return -1;
}
if (we_want_to_fetch_flavor(get_options(), flavor)) {
@@ -615,14 +614,14 @@ getinfo_helper_dir(control_connection_t *control_conn,
} else if (!strcmp(question, "dir/status-vote/current/consensus")) {
int consensus_result = getinfo_helper_current_consensus(FLAV_NS,
answer, errmsg);
- if (consensus_result == -1) {
+ if (consensus_result < 0) {
return -1;
}
} else if (!strcmp(question,
"dir/status-vote/current/consensus-microdesc")) {
int consensus_result = getinfo_helper_current_consensus(FLAV_MICRODESC,
answer, errmsg);
- if (consensus_result == -1) {
+ if (consensus_result < 0) {
return -1;
}
} else if (!strcmp(question, "network-status")) { /* v1 */