summaryrefslogtreecommitdiff
path: root/src/node_http_parser.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2016-03-31 12:54:09 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2016-04-05 11:37:05 +0200
commitea63f79752e286c2987740a52b81cd289d125806 (patch)
tree83c4ccc08ca8b300ac71dd06ad507e3db6ac2b20 /src/node_http_parser.cc
parenta7581d0859ce5139b2d7795c5ac1f8df0e85815c (diff)
downloadandroid-node-v8-ea63f79752e286c2987740a52b81cd289d125806.tar.gz
android-node-v8-ea63f79752e286c2987740a52b81cd289d125806.tar.bz2
android-node-v8-ea63f79752e286c2987740a52b81cd289d125806.zip
src: use size_t for http parser array size fields
Make the `num_values_` and `num_fields_` unsigned and remove an erroneous comment. PR-URL: https://github.com/nodejs/node/pull/5969 Reviewed-By: Colin Ihrig <cjihrig@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.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc
index a9081dc674..4087ed263f 100644
--- a/src/node_http_parser.cc
+++ b/src/node_http_parser.cc
@@ -193,7 +193,7 @@ class Parser : public AsyncWrap {
if (num_fields_ == num_values_) {
// start of new field name
num_fields_++;
- if (num_fields_ == static_cast<int>(arraysize(fields_))) {
+ if (num_fields_ == arraysize(fields_)) {
// ran out of space - flush to javascript land
Flush();
num_fields_ = 1;
@@ -202,7 +202,7 @@ class Parser : public AsyncWrap {
fields_[num_fields_ - 1].Reset();
}
- CHECK_LT(num_fields_, static_cast<int>(arraysize(fields_)));
+ CHECK_LT(num_fields_, arraysize(fields_));
CHECK_EQ(num_fields_, num_values_ + 1);
fields_[num_fields_ - 1].Update(at, length);
@@ -218,7 +218,7 @@ class Parser : public AsyncWrap {
values_[num_values_ - 1].Reset();
}
- CHECK_LT(num_values_, static_cast<int>(arraysize(values_)));
+ CHECK_LT(num_values_, arraysize(values_));
CHECK_EQ(num_values_, num_fields_);
values_[num_values_ - 1].Update(at, length);
@@ -385,11 +385,11 @@ class Parser : public AsyncWrap {
url_.Save();
status_message_.Save();
- for (int i = 0; i < num_fields_; i++) {
+ for (size_t i = 0; i < num_fields_; i++) {
fields_[i].Save();
}
- for (int i = 0; i < num_values_; i++) {
+ for (size_t i = 0; i < num_values_; i++) {
values_[i].Save();
}
}
@@ -637,12 +637,10 @@ class Parser : public AsyncWrap {
}
Local<Array> CreateHeaders() {
- // num_values_ is either -1 or the entry # of the last header
- // so num_values_ == 0 means there's a single header
Local<Array> headers = Array::New(env()->isolate());
Local<Function> fn = env()->push_values_to_array_function();
Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX * 2];
- int i = 0;
+ size_t i = 0;
do {
size_t j = 0;
@@ -702,8 +700,8 @@ class Parser : public AsyncWrap {
StringPtr values_[32]; // header values
StringPtr url_;
StringPtr status_message_;
- int num_fields_;
- int num_values_;
+ size_t num_fields_;
+ size_t num_values_;
bool have_flushed_;
bool got_exception_;
Local<Object> current_buffer_;