From: Timo Sirainen Date: Mon, 22 Feb 2016 20:23:08 +0000 (+0200) Subject: doveadm: Code cleanup - remove duplicate code X-Git-Tag: 2.2.22.rc1~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17bfcf534dc30994a3940c2727d8b3691e85610b;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Code cleanup - remove duplicate code --- diff --git a/src/doveadm/client-connection-http.c b/src/doveadm/client-connection-http.c index 0cd0fdb142..044264def3 100644 --- a/src/doveadm/client-connection-http.c +++ b/src/doveadm/client-connection-http.c @@ -206,24 +206,21 @@ static int doveadm_http_server_json_parse_next(struct client_connection_http *co rc = doveadm_http_server_istream_read(conn); if (rc != 1) return rc; conn->json_state = JSON_STATE_COMMAND_PARAMETER_KEY; - return json_parse_next(conn->json_parser, type, value); } else if (conn->json_state == JSON_STATE_COMMAND_PARAMETER_VALUE_ARRAY) { /* reading through parameters in an array */ while ((rc = json_parse_next(conn->json_parser, type, value)) > 0) { - if (*type == JSON_TYPE_ARRAY_END) { - conn->json_state = JSON_STATE_COMMAND_PARAMETER_KEY; - return json_parse_next(conn->json_parser, type, value); - } + if (*type == JSON_TYPE_ARRAY_END) + break; if (*type != JSON_TYPE_STRING) return -2; tmp = p_strdup(conn->client.pool,*value); array_append(&conn->cmd_param->value.v_array, &tmp, 1); } - return rc; + if (rc <= 0) + return rc; + conn->json_state = JSON_STATE_COMMAND_PARAMETER_KEY; } else if (conn->json_state == JSON_STATE_COMMAND_PARAMETER_VALUE) { if (conn->cmd_param->type == CMD_PARAM_ISTREAM) { - if (conn->cmd_param->value_set == TRUE) - return json_parse_next(conn->json_parser, type, value); struct istream* is[2] = {0}; rc = json_parse_next_stream(conn->json_parser, &is[0]); if (rc != 1) return rc; @@ -250,8 +247,6 @@ static int doveadm_http_server_json_parse_next(struct client_connection_http *co } tmp = p_strdup(conn->client.pool,*value); array_append(&conn->cmd_param->value.v_array, &tmp, 1); - conn->json_state = JSON_STATE_COMMAND_PARAMETER_KEY; - return json_parse_next(conn->json_parser, type, value); } else { conn->cmd_param->value_set = TRUE; switch(conn->cmd_param->type) { @@ -268,13 +263,9 @@ static int doveadm_http_server_json_parse_next(struct client_connection_http *co break; } } - rc = json_parse_next(conn->json_parser, type, value); conn->json_state = JSON_STATE_COMMAND_PARAMETER_KEY; - return rc; - } else { - rc = json_parse_next(conn->json_parser, type, value); /* just get next */ - return rc; } + return json_parse_next(conn->json_parser, type, value); /* just get next */ } static void