Skip to content

Commit

Permalink
SIZE_MAX is not defined on MSVC6, use (size_t) ~0
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Mar 17, 2015
1 parent 05c88a9 commit 2d1d2e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mongoose.c
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,7 @@ static size_t parse_http_message(char *buf, size_t len,
ri->request_method = ri->uri = ri->http_version = ri->query_string = NULL;
ri->num_headers = ri->status_code = ri->is_websocket = ri->content_len = 0;

if (len < 1) return SIZE_MAX;
if (len < 1) return ~0;

buf[len - 1] = '\0';

Expand All @@ -2502,7 +2502,7 @@ static size_t parse_http_message(char *buf, size_t len,
is_request = is_valid_http_method(ri->request_method);
if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) ||
(!is_request && memcmp(ri->request_method, "HTTP/", 5) != 0)) {
len = SIZE_MAX;
len = ~0;
} else {
if (is_request) {
ri->http_version += 5;
Expand Down
4 changes: 2 additions & 2 deletions test/unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ static const char *test_parse_http_message() {
ASSERT(strcmp(ri.http_version, "1.1") == 0);
ASSERT(ri.num_headers == 0);

ASSERT(parse_http_message(req2, sizeof(req2) - 1, &ri) == SIZE_MAX);
ASSERT(parse_http_message(req6, 0, &ri) == SIZE_MAX);
ASSERT(parse_http_message(req2, sizeof(req2) - 1, &ri) == (size_t) ~0);
ASSERT(parse_http_message(req6, 0, &ri) == (size_t) ~0);
ASSERT(parse_http_message(req8, sizeof(req8) - 1, &ri) == sizeof(req8) - 1);

// TODO(lsm): Fix this. Header value may span multiple lines.
Expand Down

0 comments on commit 2d1d2e6

Please sign in to comment.