]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
Revert "Merge branch 'doh-remove-asserts' into 'master'"
authorTomas Krizek <tomas.krizek@nic.cz>
Tue, 30 Mar 2021 11:28:54 +0000 (13:28 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 30 Mar 2021 11:28:54 +0000 (13:28 +0200)
This reverts commit 99e6e75427031918adeabd8da6b151a5170d3f57, reversing
changes made to 65bed85f897dd004fbe5234d40aaa60d9cabee1e.

daemon/http.c

index f7621568281d287793dafe669a7b35f076e2c836..b0417635029fd32e2b65eb477caf16a8ab4c85ea 100644 (file)
@@ -6,6 +6,7 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
+#include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -56,8 +57,8 @@ static void http_stream_status_free(struct http_stream_status *stat)
 
 static int status_free(trie_val_t *stat, void *null)
 {
-       if (stat)  // TODO use kr_assume()
-               http_stream_status_free(*stat);
+       assert(stat);
+       http_stream_status_free(*stat);
        return 0;
 }
 
@@ -139,8 +140,7 @@ static int send_data_callback(nghttp2_session *h2, nghttp2_frame *frame, const u
        if (ret < 0)
                return NGHTTP2_ERR_CALLBACK_FAILURE;
        data->pos += length;
-       if (data->pos > data->len)  // TODO use kr_assume()
-               return NGHTTP2_ERR_CALLBACK_FAILURE;
+       assert(data->pos <= data->len);
 
        ret = send_padding(ctx, (uint8_t)frame->data.padlen);
        if (ret < 0)
@@ -585,8 +585,9 @@ static int on_frame_recv_callback(nghttp2_session *h2, const nghttp2_frame *fram
        struct http_ctx *ctx = (struct http_ctx *)user_data;
        ssize_t len;
        int32_t stream_id = frame->hd.stream_id;
+       assert(stream_id != -1);
 
-       if (stream_id <= 0 || ctx == NULL)
+       if (stream_id == 0 || ctx == NULL)
                return 0;
 
        if (ctx->current_method == HTTP_METHOD_NONE) {
@@ -607,7 +608,8 @@ static int on_frame_recv_callback(nghttp2_session *h2, const nghttp2_frame *fram
 
        if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
                struct http_stream_status *stat = ctx->current_stream;
-               if (stat && stat->stream_id == stream_id) {
+               assert(stat);
+               if (stat->stream_id == stream_id) {
                        if (stat->err_status == 200) {
                                if (ctx->current_method == HTTP_METHOD_GET) {
                                        if (process_uri_path(ctx, stream_id) < 0) {
@@ -761,8 +763,7 @@ ssize_t http_process_input_data(struct session *session, const uint8_t *buf,
 
        if (!ctx->h2)
                return kr_error(ENOSYS);
-       if (ctx->session != session)  // TODO use kr_assume()
-               return kr_error(EINVAL);
+       assert(ctx->session == session);
 
        ctx->submitted = 0;
        ctx->buf = session_wirebuf_get_free_start(session);