diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-01-13 14:43:51 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-01-13 14:43:51 +0000 |
commit | a33452c40149842fda3ce2a201a722009e7e1456 (patch) | |
tree | 5bc3efc1704b0fb1dafface01fbda1e6a8da6e3b /src/or/control.c | |
parent | c32a4ce6b3ac5d24ff53639d2c00d9864e9bf22c (diff) | |
download | tor-a33452c40149842fda3ce2a201a722009e7e1456.tar.gz tor-a33452c40149842fda3ce2a201a722009e7e1456.zip |
Fix up (I hope) most ot the things that coverity suddenly claimed were REVERSE_INULL. This is what we get for bragging about being down to 0 issues.
svn:r18096
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/or/control.c b/src/or/control.c index 7e8cbfcf6b..0236d1ea88 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -823,24 +823,21 @@ static int handle_control_getconf(control_connection_t *conn, uint32_t body_len, const char *body) { - smartlist_t *questions = NULL; - smartlist_t *answers = NULL; - smartlist_t *unrecognized = NULL; + smartlist_t *questions = smartlist_create(); + smartlist_t *answers = smartlist_create(); + smartlist_t *unrecognized = smartlist_create(); char *msg = NULL; size_t msg_len; or_options_t *options = get_options(); int i, len; - questions = smartlist_create(); (void) body_len; /* body is nul-terminated; so we can ignore len. */ smartlist_split_string(questions, body, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); - answers = smartlist_create(); - unrecognized = smartlist_create(); - SMARTLIST_FOREACH(questions, char *, q, + SMARTLIST_FOREACH(questions, const char *, q, { if (!option_is_recognized(q)) { - smartlist_add(unrecognized, q); + smartlist_add(unrecognized, (char*) q); } else { config_line_t *answer = option_get_assignment(options,q); if (!answer) { @@ -886,15 +883,12 @@ handle_control_getconf(control_connection_t *conn, uint32_t body_len, connection_write_str_to_buf("250 OK\r\n", conn); } - if (answers) { - SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); - smartlist_free(answers); - } - if (questions) { - SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); - smartlist_free(questions); - } + SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); + smartlist_free(answers); + SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); + smartlist_free(questions); smartlist_free(unrecognized); + tor_free(msg); return 0; @@ -2020,18 +2014,15 @@ static int handle_control_getinfo(control_connection_t *conn, uint32_t len, const char *body) { - smartlist_t *questions = NULL; - smartlist_t *answers = NULL; - smartlist_t *unrecognized = NULL; + smartlist_t *questions = smartlist_create(); + smartlist_t *answers = smartlist_create(); + smartlist_t *unrecognized = smartlist_create(); char *msg = NULL, *ans = NULL; int i; (void) len; /* body is nul-terminated, so it's safe to ignore the length. */ - questions = smartlist_create(); smartlist_split_string(questions, body, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); - answers = smartlist_create(); - unrecognized = smartlist_create(); SMARTLIST_FOREACH(questions, const char *, q, { if (handle_getinfo_helper(conn, q, &ans) < 0) { @@ -2075,14 +2066,10 @@ handle_control_getinfo(control_connection_t *conn, uint32_t len, connection_write_str_to_buf("250 OK\r\n", conn); done: - if (answers) { - SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); - smartlist_free(answers); - } - if (questions) { - SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); - smartlist_free(questions); - } + SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp)); + smartlist_free(answers); + SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp)); + smartlist_free(questions); smartlist_free(unrecognized); tor_free(msg); |