]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Code cleanup - remove duplicate code
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 22 Feb 2016 20:23:08 +0000 (22:23 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 22 Feb 2016 20:28:26 +0000 (22:28 +0200)
src/doveadm/client-connection-http.c

index 0cd0fdb142e9f046c2220b83c2a21ef3be3aab5d..044264def3ff5dd87442d8803f96d3d3dec30004 100644 (file)
@@ -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