Skip to content

Commit

Permalink
doveadm: Code cleanup - remove unnecessary NULL sets and checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Feb 22, 2016
1 parent f9d2a1f commit 3d27e11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
14 changes: 2 additions & 12 deletions src/doveadm/client-connection-http.c
Expand Up @@ -138,7 +138,6 @@ doveadm_http_server_request_destroy(void *context)
http_server_request_unref(&(conn->http_server_request));
http_server_switch_ioloop(doveadm_http_server);
http_server_connection_unref(&(conn->http_client));
conn->http_client = NULL;
}

static void doveadm_http_server_json_error(void *context, const char *error)
Expand Down Expand Up @@ -330,7 +329,6 @@ doveadm_http_server_command_execute(struct client_connection_http *conn)
}

is = iostream_temp_finish(&doveadm_print_ostream, 4096);
doveadm_print_ostream = NULL;

if (conn->first_row == TRUE) {
conn->first_row = FALSE;
Expand Down Expand Up @@ -374,9 +372,7 @@ doveadm_http_server_read_request(struct client_connection_http *conn)
}
if (type != JSON_TYPE_ARRAY) break;
conn->method_err = 0;
if (conn->method_id != NULL)
p_free(conn->client.pool, conn->method_id);
conn->method_id = NULL;
p_free_and_null(conn->client.pool, conn->method_id);
conn->cmd = NULL;
array_clear(&conn->pargv);
conn->json_state = JSON_STATE_COMMAND_NAME;
Expand Down Expand Up @@ -464,9 +460,7 @@ doveadm_http_server_read_request(struct client_connection_http *conn)

if (!conn->client.input->eof && rc == 0)
return;

io_remove(&conn->client.io);
conn->client.io = NULL;

if (rc == -2 || (rc == 1 && conn->json_state != JSON_STATE_DONE)) {
/* this will happen if the parser above runs into unexpected element, but JSON is OK */
Expand All @@ -491,11 +485,7 @@ doveadm_http_server_read_request(struct client_connection_http *conn)
i_info("doveadm(%s): %s", i_stream_get_name(conn->client.input), error);
return;
}

conn->json_parser = NULL;

if (conn->client.output != NULL)
o_stream_nsend_str(conn->client.output,"]");
o_stream_nsend_str(conn->client.output,"]");

doveadm_http_server_process_request(conn);
}
Expand Down
6 changes: 1 addition & 5 deletions src/doveadm/doveadm-cmd.c
Expand Up @@ -330,11 +330,7 @@ static void doveadm_fill_param(struct doveadm_cmd_param *param,
}
break;
case CMD_PARAM_STR:
if (value != NULL) {
param->value.v_string = p_strdup(pool, value);
} else {
param->value.v_string = NULL;
}
param->value.v_string = p_strdup(pool, value);
break;
case CMD_PARAM_ARRAY:
if (!array_is_created(&param->value.v_array))
Expand Down

0 comments on commit 3d27e11

Please sign in to comment.