diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2021-01-30 16:59:54 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2021-02-07 17:51:41 -0800 |
commit | b346cd1760dfad560d89cb797be2cf6f9f77bb77 (patch) | |
tree | d5a8ab6889d72e8090cd5198905db8635fe37008 /src/node_http_parser.cc | |
parent | 907d6b6b40a62c5ae831bbd7551e7c57c3a27b6b (diff) | |
download | node-new-b346cd1760dfad560d89cb797be2cf6f9f77bb77.tar.gz |
src: avoid implicit type conversions
This fixes a bunch of C4244 ('conversion' conversion from 'type1' to
'type2', possible loss of data) MSVC warnings in the code base.
PR-URL: https://github.com/nodejs/node/pull/37149
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r-- | src/node_http_parser.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index affc66585e..b2841772aa 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -380,7 +380,7 @@ class Parser : public AsyncWrap, public StreamListener { return -1; } - return val; + return static_cast<int>(val); } @@ -403,10 +403,10 @@ class Parser : public AsyncWrap, public StreamListener { } Local<Value> argv[3] = { - current_buffer_, - Integer::NewFromUnsigned(env()->isolate(), at - current_buffer_data_), - Integer::NewFromUnsigned(env()->isolate(), length) - }; + current_buffer_, + Integer::NewFromUnsigned( + env()->isolate(), static_cast<uint32_t>(at - current_buffer_data_)), + Integer::NewFromUnsigned(env()->isolate(), length)}; MaybeLocal<Value> r = MakeCallback(cb.As<Function>(), arraysize(argv), @@ -549,7 +549,8 @@ class Parser : public AsyncWrap, public StreamListener { if (args.Length() > 2) { CHECK(args[2]->IsNumber()); - max_http_header_size = args[2].As<Number>()->Value(); + max_http_header_size = + static_cast<uint64_t>(args[2].As<Number>()->Value()); } if (max_http_header_size == 0) { max_http_header_size = env->options()->max_http_header_size; @@ -557,7 +558,7 @@ class Parser : public AsyncWrap, public StreamListener { if (args.Length() > 4) { CHECK(args[4]->IsInt32()); - headers_timeout = args[4].As<Number>()->Value(); + headers_timeout = args[4].As<Int32>()->Value(); } llhttp_type_t type = @@ -683,7 +684,7 @@ class Parser : public AsyncWrap, public StreamListener { // check header parsing time if (header_parsing_start_time_ != 0 && headers_timeout_ != 0) { uint64_t now = uv_hrtime(); - uint64_t parsing_time = (now - header_parsing_start_time_) / 1e6; + uint64_t parsing_time = (now - header_parsing_start_time_) / 1000000; if (parsing_time > headers_timeout_) { Local<Value> cb = @@ -781,8 +782,9 @@ class Parser : public AsyncWrap, public StreamListener { if (err == HPE_USER) { const char* colon = strchr(errno_reason, ':'); CHECK_NOT_NULL(colon); - code = OneByteString(env()->isolate(), errno_reason, - colon - errno_reason); + code = OneByteString(env()->isolate(), + errno_reason, + static_cast<int>(colon - errno_reason)); reason = OneByteString(env()->isolate(), colon + 1); } else { code = OneByteString(env()->isolate(), llhttp_errno_name(err)); |