Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 20bb92f

Browse filesBrowse files
bnoordhuisMyles Borins
authored andcommitted
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: #5969 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2fd8be2 commit 20bb92f
Copy full SHA for 20bb92f

File tree

Expand file treeCollapse file tree

1 file changed

+8
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-10
lines changed
Open diff view settings
Collapse file

‎src/node_http_parser.cc‎

Copy file name to clipboardExpand all lines: src/node_http_parser.cc
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class Parser : public AsyncWrap {
193193
if (num_fields_ == num_values_) {
194194
// start of new field name
195195
num_fields_++;
196-
if (num_fields_ == static_cast<int>(arraysize(fields_))) {
196+
if (num_fields_ == arraysize(fields_)) {
197197
// ran out of space - flush to javascript land
198198
Flush();
199199
num_fields_ = 1;
@@ -202,7 +202,7 @@ class Parser : public AsyncWrap {
202202
fields_[num_fields_ - 1].Reset();
203203
}
204204

205-
CHECK_LT(num_fields_, static_cast<int>(arraysize(fields_)));
205+
CHECK_LT(num_fields_, arraysize(fields_));
206206
CHECK_EQ(num_fields_, num_values_ + 1);
207207

208208
fields_[num_fields_ - 1].Update(at, length);
@@ -218,7 +218,7 @@ class Parser : public AsyncWrap {
218218
values_[num_values_ - 1].Reset();
219219
}
220220

221-
CHECK_LT(num_values_, static_cast<int>(arraysize(values_)));
221+
CHECK_LT(num_values_, arraysize(values_));
222222
CHECK_EQ(num_values_, num_fields_);
223223

224224
values_[num_values_ - 1].Update(at, length);
@@ -385,11 +385,11 @@ class Parser : public AsyncWrap {
385385
url_.Save();
386386
status_message_.Save();
387387

388-
for (int i = 0; i < num_fields_; i++) {
388+
for (size_t i = 0; i < num_fields_; i++) {
389389
fields_[i].Save();
390390
}
391391

392-
for (int i = 0; i < num_values_; i++) {
392+
for (size_t i = 0; i < num_values_; i++) {
393393
values_[i].Save();
394394
}
395395
}
@@ -637,12 +637,10 @@ class Parser : public AsyncWrap {
637637
}
638638

639639
Local<Array> CreateHeaders() {
640-
// num_values_ is either -1 or the entry # of the last header
641-
// so num_values_ == 0 means there's a single header
642640
Local<Array> headers = Array::New(env()->isolate());
643641
Local<Function> fn = env()->push_values_to_array_function();
644642
Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX * 2];
645-
int i = 0;
643+
size_t i = 0;
646644

647645
do {
648646
size_t j = 0;
@@ -702,8 +700,8 @@ class Parser : public AsyncWrap {
702700
StringPtr values_[32]; // header values
703701
StringPtr url_;
704702
StringPtr status_message_;
705-
int num_fields_;
706-
int num_values_;
703+
size_t num_fields_;
704+
size_t num_values_;
707705
bool have_flushed_;
708706
bool got_exception_;
709707
Local<Object> current_buffer_;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.